From 22beebc5d0df7a0da10df6b139d5b0d9812b1ff2 Mon Sep 17 00:00:00 2001 From: akhilmhdh Date: Fri, 9 Jun 2023 23:42:25 +0530 Subject: [PATCH] feat(folder-scoped-st): implemented frontend ui for folder scoped service token --- frontend/src/hooks/api/serviceTokens/types.ts | 2 ++ .../ProjectSettingsPage.tsx | 4 +++- .../ServiceTokenSection.tsx | 23 +++++++++++++++++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/frontend/src/hooks/api/serviceTokens/types.ts b/frontend/src/hooks/api/serviceTokens/types.ts index 83bad9db6..0c68aea79 100644 --- a/frontend/src/hooks/api/serviceTokens/types.ts +++ b/frontend/src/hooks/api/serviceTokens/types.ts @@ -3,6 +3,7 @@ export type ServiceToken = { name: string; workspace: string; environment: string; + secretPath: string; user: string; expiresAt: string; createdAt: string; @@ -15,6 +16,7 @@ export type CreateServiceTokenDTO = { workspaceId: string; environment: string; expiresIn: number; + secretPath: string; encryptedKey: string; iv: string; tag: string; diff --git a/frontend/src/views/Settings/ProjectSettingsPage/ProjectSettingsPage.tsx b/frontend/src/views/Settings/ProjectSettingsPage/ProjectSettingsPage.tsx index 6971a0f48..fe78f5550 100644 --- a/frontend/src/views/Settings/ProjectSettingsPage/ProjectSettingsPage.tsx +++ b/frontend/src/views/Settings/ProjectSettingsPage/ProjectSettingsPage.tsx @@ -219,7 +219,8 @@ export const ProjectSettingsPage = () => { environment, expiresIn, name, - permissions + permissions, + secretPath }: CreateServiceToken) => { // type guard if (!latestFileKey) return ''; @@ -243,6 +244,7 @@ export const ProjectSettingsPage = () => { iv, tag, environment, + secretPath, expiresIn: Number(expiresIn), name, workspaceId: workspaceID, diff --git a/frontend/src/views/Settings/ProjectSettingsPage/components/ServiceTokenSection/ServiceTokenSection.tsx b/frontend/src/views/Settings/ProjectSettingsPage/components/ServiceTokenSection/ServiceTokenSection.tsx index 71be23d6b..acde69cc0 100644 --- a/frontend/src/views/Settings/ProjectSettingsPage/components/ServiceTokenSection/ServiceTokenSection.tsx +++ b/frontend/src/views/Settings/ProjectSettingsPage/components/ServiceTokenSection/ServiceTokenSection.tsx @@ -42,8 +42,9 @@ const apiTokenExpiry = [ ]; const createServiceTokenSchema = yup.object({ - name: yup.string().required().label('Service Token Name'), - environment: yup.string().required().label('Environment'), + name: yup.string().max(100).required().label('Service Token Name'), + environment: yup.string().max(50).required().label('Environment'), + secretPath: yup.string().required().default('/').label('Secret Path'), expiresIn: yup.string().optional().label('Service Token Expiration'), permissions: yup .object() @@ -201,6 +202,22 @@ export const ServiceTokenSection = ({ )} /> + ( + + + + )} + /> + Token Name Environment + Secret Path Valid Until @@ -340,6 +358,7 @@ export const ServiceTokenSection = ({ {row.name} {row.environment} + {row.secretPath} {row.expiresAt && new Date(row.expiresAt).toUTCString()}