From 750c1b46da2ad62d93a8eef438d6e09680181fb7 Mon Sep 17 00:00:00 2001 From: Akhil Mohan Date: Sat, 16 Sep 2023 16:47:41 +0530 Subject: [PATCH] fix: integration bot deactive resolved and redis type error --- backend/src/services/RedisService.ts | 8 ++--- backend/src/validation/secrets.ts | 1 - .../IntegrationsPage/IntegrationsPage.tsx | 35 ++++++++++--------- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/backend/src/services/RedisService.ts b/backend/src/services/RedisService.ts index a6ae5b026..23f945bb7 100644 --- a/backend/src/services/RedisService.ts +++ b/backend/src/services/RedisService.ts @@ -1,12 +1,12 @@ -import { Redis } from "ioredis" +import Redis, { Redis as TRedis } from "ioredis"; -let redisClient: Redis | null; +let redisClient: TRedis | null; if (process.env.REDIS_URL) { redisClient = new Redis(process.env.REDIS_URL as string); } else { console.warn("Redis URL not set, skipping Redis initialization."); - redisClient = null + redisClient = null; } -export { redisClient } \ No newline at end of file +export { redisClient }; diff --git a/backend/src/validation/secrets.ts b/backend/src/validation/secrets.ts index cc541ab9e..28e7f469d 100644 --- a/backend/src/validation/secrets.ts +++ b/backend/src/validation/secrets.ts @@ -270,7 +270,6 @@ export const UpdateSecretByNameRawV3 = z.object({ workspaceId: z.string().trim(), environment: z.string().trim(), secretValue: z.string().trim(), - secretName: z.string().trim(), secretPath: z.string().trim().default("/"), type: z.enum([SECRET_SHARED, SECRET_PERSONAL]).default(SECRET_SHARED) }) diff --git a/frontend/src/views/IntegrationsPage/IntegrationsPage.tsx b/frontend/src/views/IntegrationsPage/IntegrationsPage.tsx index 0f2f8a97d..8a2ae014b 100644 --- a/frontend/src/views/IntegrationsPage/IntegrationsPage.tsx +++ b/frontend/src/views/IntegrationsPage/IntegrationsPage.tsx @@ -51,17 +51,20 @@ export const IntegrationsPage = withProjectPermission( const { data: cloudIntegrations, isLoading: isCloudIntegrationsLoading } = useGetCloudIntegrations(); - const { data: integrationAuths, isLoading: isIntegrationAuthLoading } = - useGetWorkspaceAuthorizations( - workspaceId, - useCallback((data: IntegrationAuth[]) => { - const groupBy: Record = {}; - data.forEach((el) => { - groupBy[el.integration] = el; - }); - return groupBy; - }, []) - ); + const { + data: integrationAuths, + isLoading: isIntegrationAuthLoading, + isFetching: isIntegrationAuthFetching + } = useGetWorkspaceAuthorizations( + workspaceId, + useCallback((data: IntegrationAuth[]) => { + const groupBy: Record = {}; + data.forEach((el) => { + groupBy[el.integration] = el; + }); + return groupBy; + }, []) + ); // mutation const { data: integrations, @@ -77,18 +80,18 @@ export const IntegrationsPage = withProjectPermission( const { mutateAsync: deleteIntegration } = useDeleteIntegration(); const { mutateAsync: deleteIntegrationAuth, - isLoading: isDeleteIntegrationAuthSuccess, + isSuccess: isDeleteIntegrationAuthSuccess, reset: resetDeleteIntegrationAuth } = useDeleteIntegrationAuth(); // summary: this use effect is trigger when all integration auths are removed thus deactivate bot - // details: so onsuccessfully deleting an integration auth, immediately integration list is refeteched - // After the refetch is completed check if its empty. Then set bot active and reset the submit hook + // details: so on successfully deleting an integration auth, immediately integration list is refeteched + // After the refetch is completed check if its empty. Then set bot active and reset the submit hook for isSuccess to go back to false useEffect(() => { if ( isDeleteIntegrationAuthSuccess && !isIntegrationFetching && - !isIntegrationAuthLoading && + !isIntegrationAuthFetching && !integrations?.length && !integrationAuths?.length ) { @@ -103,7 +106,7 @@ export const IntegrationsPage = withProjectPermission( }, [ isIntegrationFetching, isDeleteIntegrationAuthSuccess, - isIntegrationAuthLoading, + isIntegrationAuthFetching, integrationAuths?.length, integrations?.length ]);