From 72d4490ee7e954a604670c3d09a250e0b9a91d14 Mon Sep 17 00:00:00 2001 From: Tuan Dang Date: Mon, 19 Feb 2024 15:04:42 -0800 Subject: [PATCH] Fix lint/type issues --- backend/src/ee/services/audit-log/audit-log-types.ts | 5 ++++- backend/src/server/plugins/audit-log.ts | 3 ++- frontend/src/hooks/api/scim/index.tsx | 4 ++-- frontend/src/hooks/api/scim/mutations.tsx | 9 ++++----- frontend/src/hooks/api/scim/queries.tsx | 4 +++- .../components/OrgAuthTab/OrgAuthTab.tsx | 2 +- .../components/OrgAuthTab/ScimTokenModal.tsx | 11 +++++------ 7 files changed, 21 insertions(+), 17 deletions(-) diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.ts index 4ed86b292..2aaaf7562 100644 --- a/backend/src/ee/services/audit-log/audit-log-types.ts +++ b/backend/src/ee/services/audit-log/audit-log-types.ts @@ -15,7 +15,7 @@ export type TListProjectAuditLogDTO = { export type TCreateAuditLogDTO = { event: Event; - actor: UserActor | IdentityActor | ServiceActor; + actor: UserActor | IdentityActor | ServiceActor | ScimClientActor; orgId?: string; projectId?: string; } & BaseAuthData; @@ -105,6 +105,8 @@ interface IdentityActorMetadata { name: string; } +interface ScimClientActorMetadata {} + export interface UserActor { type: ActorType.USER; metadata: UserActorMetadata; @@ -122,6 +124,7 @@ export interface IdentityActor { export interface ScimClientActor { type: ActorType.SCIM_CLIENT; + metadata: ScimClientActorMetadata; } export type Actor = UserActor | ServiceActor | IdentityActor | ScimClientActor; diff --git a/backend/src/server/plugins/audit-log.ts b/backend/src/server/plugins/audit-log.ts index 33144683c..de352a9bc 100644 --- a/backend/src/server/plugins/audit-log.ts +++ b/backend/src/server/plugins/audit-log.ts @@ -65,7 +65,8 @@ export const injectAuditLogInfo = fp(async (server: FastifyZodProvider) => { }; } else if (req.auth.actor === ActorType.SCIM_CLIENT) { payload.actor = { - type: ActorType.SCIM_CLIENT + type: ActorType.SCIM_CLIENT, + metadata: {} }; } else { throw new BadRequestError({ message: "Missing logic for other actor" }); diff --git a/frontend/src/hooks/api/scim/index.tsx b/frontend/src/hooks/api/scim/index.tsx index 389518173..1981659d1 100644 --- a/frontend/src/hooks/api/scim/index.tsx +++ b/frontend/src/hooks/api/scim/index.tsx @@ -1,5 +1,5 @@ -export { useGetScimTokens } from "./queries"; export { useCreateScimToken, useDeleteScimToken -} from "./mutations"; \ No newline at end of file +} from "./mutations"; +export { useGetScimTokens } from "./queries"; \ No newline at end of file diff --git a/frontend/src/hooks/api/scim/mutations.tsx b/frontend/src/hooks/api/scim/mutations.tsx index 3ac5ab3a7..7469fb532 100644 --- a/frontend/src/hooks/api/scim/mutations.tsx +++ b/frontend/src/hooks/api/scim/mutations.tsx @@ -1,11 +1,13 @@ import { useMutation, useQueryClient } from "@tanstack/react-query"; + import { apiRequest } from "@app/config/request"; + +import { scimKeys } from "./queries"; import { CreateScimTokenDTO, CreateScimTokenRes, DeleteScimTokenDTO } from "./types"; -import { scimKeys } from "./queries"; export const useCreateScimToken = () => { const queryClient = useQueryClient(); @@ -32,10 +34,7 @@ export const useCreateScimToken = () => { export const useDeleteScimToken = () => { const queryClient = useQueryClient(); return useMutation({ - mutationFn: async ({ - organizationId, - scimTokenId - }) => { + mutationFn: async ({ scimTokenId }) => { const { data } = await apiRequest.delete(`/api/v1/scim/scim-tokens/${scimTokenId}`); return data; }, diff --git a/frontend/src/hooks/api/scim/queries.tsx b/frontend/src/hooks/api/scim/queries.tsx index 4c88ebc2f..f76018c01 100644 --- a/frontend/src/hooks/api/scim/queries.tsx +++ b/frontend/src/hooks/api/scim/queries.tsx @@ -1,5 +1,7 @@ -import { useQuery, useQueryClient } from "@tanstack/react-query"; +import { useQuery } from "@tanstack/react-query"; + import { apiRequest } from "@app/config/request"; + import { ScimTokenData } from "./types"; export const scimKeys = { diff --git a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgAuthTab.tsx b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgAuthTab.tsx index 4a18fcd41..e1e0e0702 100644 --- a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgAuthTab.tsx +++ b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgAuthTab.tsx @@ -1,8 +1,8 @@ import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context"; import { withPermission } from "@app/hoc"; -import { OrgScimSection } from "./OrgScimSection"; import { OrgGeneralAuthSection } from "./OrgGeneralAuthSection"; +import { OrgScimSection } from "./OrgSCIMSection"; import { OrgSSOSection } from "./OrgSSOSection"; export const OrgAuthTab = withPermission( diff --git a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/ScimTokenModal.tsx b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/ScimTokenModal.tsx index 586b07049..6ef6c9355 100644 --- a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/ScimTokenModal.tsx +++ b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/ScimTokenModal.tsx @@ -26,14 +26,13 @@ import { THead, Tr } from "@app/components/v2"; +import { useOrganization } from "@app/context"; import { useToggle } from "@app/hooks"; import { - useGetScimTokens, useCreateScimToken, - useDeleteScimToken -} from "@app/hooks/api"; + useDeleteScimToken, + useGetScimTokens} from "@app/hooks/api"; import { UsePopUpState } from "@app/hooks/usePopUp"; -import { useOrganization } from "@app/context"; const schema = yup.object({ description: yup.string(), @@ -162,7 +161,7 @@ export const ScimTokenModal = ({ setToken(""); }} > - +

SCIM URL

{scimUrl}

@@ -326,7 +325,7 @@ export const ScimTokenModal = ({ handlePopUpToggle("scimToken", isOpen)} deleteKey="confirm" onDeleteApproved={() => {