Merge pull request #407 from gitroomhq/feat/refresh-v

Refresh changes
This commit is contained in:
Nevo David 2024-10-29 12:39:06 +07:00 committed by GitHub
commit 526b761405
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 20 additions and 18 deletions

View File

@ -1,12 +1,5 @@
import {
Body,
Controller,
Delete,
Get,
Param,
Post,
Query,
UseFilters,
Body, Controller, Delete, Get, Param, Post, Query, UseFilters
} from '@nestjs/common';
import { ioRedis } from '@gitroom/nestjs-libraries/redis/redis.service';
import { ConnectIntegrationDto } from '@gitroom/nestjs-libraries/dtos/integrations/connect.integration.dto';
@ -29,6 +22,7 @@ import { PostsService } from '@gitroom/nestjs-libraries/database/prisma/posts/po
import { IntegrationTimeDto } from '@gitroom/nestjs-libraries/dtos/integrations/integration.time.dto';
import { AuthService } from '@gitroom/helpers/auth/auth.service';
import { AuthTokenDetails } from '@gitroom/nestjs-libraries/integrations/social/social.integrations.interface';
import { NotEnoughScopes } from '@gitroom/nestjs-libraries/integrations/social.abstract';
@ApiTags('Integrations')
@Controller('/integrations')
@ -354,7 +348,11 @@ export class IntegrationsController {
});
if (!id) {
throw new Error('Invalid api key');
throw new NotEnoughScopes('Invalid API key');
}
if (refresh && id !== refresh) {
throw new NotEnoughScopes('Please refresh the channel that needs to be refreshed');
}
return this._integrationService.createOrUpdateIntegration(

View File

@ -28,7 +28,8 @@ export default async function Page({
});
if (data.status === HttpStatusCode.NotAcceptable) {
return redirect(`/launches?scope=missing`);
const { msg } = await data.json();
return redirect(`/launches?msg=${msg}`);
}
if (
@ -50,8 +51,8 @@ export default async function Page({
const { inBetweenSteps, id } = await data.json();
if (inBetweenSteps && !searchParams.refresh) {
return redirect(`/launches?added=${provider}&continue=${id}`);
return redirect(`/launches?msg=Channel Refreshed&added=${provider}&continue=${id}`);
}
return redirect(`/launches?added=${provider}`);
return redirect(`/launches?added=${provider}&msg=Channel Added`);
}

View File

@ -96,8 +96,8 @@ export const LaunchesComponent = () => {
if (typeof window === 'undefined') {
return;
}
if (search.get('scope') === 'missing') {
toast.show('You have to approve all the channel permissions', 'warning');
if (search.get('msg')) {
toast.show(search.get('msg')!, 'warning');
}
if (search.get('added')) {
fireEvents('channel_added');

View File

@ -1,4 +1,4 @@
import { FC, useCallback, useState } from 'react';
import { FC, MouseEventHandler, useCallback, useState } from 'react';
import { useClickOutside } from '@mantine/hooks';
import { useFetch } from '@gitroom/helpers/utils/custom.fetch';
import { deleteDialog } from '@gitroom/react/helpers/delete.dialog';
@ -36,7 +36,8 @@ export const Menu: FC<{
setShow(false);
});
const changeShow = useCallback(() => {
const changeShow: MouseEventHandler<HTMLDivElement> = useCallback((e) => {
e.stopPropagation();
setShow(!show);
}, [show]);

View File

@ -9,6 +9,6 @@ export class NotEnoughScopesFilter implements ExceptionFilter {
const ctx = host.switchToHttp();
const response = ctx.getResponse<Response>();
response.status(HttpStatusCode.NotAcceptable).json({ invalid: true });
response.status(HttpStatusCode.NotAcceptable).json({ msg: exception.message });
}
}

View File

@ -13,7 +13,9 @@ export class BadBody {
) {}
}
export class NotEnoughScopes {}
export class NotEnoughScopes {
constructor(public message = 'Not enough scopes') {}
}
export abstract class SocialAbstract {
async fetch(url: string, options: RequestInit = {}, identifier = '') {