From 1e5244b2c3cb5b79bcd4b190c2f32aca81b8d73a Mon Sep 17 00:00:00 2001 From: Scott Wilson Date: Mon, 15 Sep 2025 14:45:21 -0700 Subject: [PATCH] improvements: address feedback --- .../app-connection/app-connection-fns.ts | 9 +++---- .../CreateSecretRotationV2Modal.tsx | 15 ++++++++--- .../CreateSecretScanningDataSourceModal.tsx | 26 +++++++++++++------ .../components/ProjectAccessError.tsx | 6 +---- 4 files changed, 34 insertions(+), 22 deletions(-) diff --git a/backend/src/services/app-connection/app-connection-fns.ts b/backend/src/services/app-connection/app-connection-fns.ts index bfad05213..f88b5a357 100644 --- a/backend/src/services/app-connection/app-connection-fns.ts +++ b/backend/src/services/app-connection/app-connection-fns.ts @@ -149,6 +149,9 @@ const SECRET_SCANNING_APP_CONNECTION_MAP = Object.fromEntries( Object.entries(SECRET_SCANNING_DATA_SOURCE_CONNECTION_MAP).map(([key, value]) => [value, key]) ); +// scott: ideally this would be derived from a utilized map like the above +const PKI_APP_CONNECTIONS = [AppConnection.AWS, AppConnection.Cloudflare, AppConnection.AzureADCS]; + export const listAppConnectionOptions = (projectType?: ProjectType) => { return [ getAwsConnectionListItem(), @@ -200,11 +203,7 @@ export const listAppConnectionOptions = (projectType?: ProjectType) => { case ProjectType.SecretScanning: return Boolean(SECRET_SCANNING_APP_CONNECTION_MAP[option.app]); case ProjectType.CertificateManager: - return ( - option.app === AppConnection.AWS || - option.app === AppConnection.Cloudflare || - option.app === AppConnection.AzureADCS - ); + return PKI_APP_CONNECTIONS.includes(option.app); case ProjectType.KMS: return false; case ProjectType.SSH: diff --git a/frontend/src/components/secret-rotations-v2/CreateSecretRotationV2Modal.tsx b/frontend/src/components/secret-rotations-v2/CreateSecretRotationV2Modal.tsx index 9666c3c52..89ced26b7 100644 --- a/frontend/src/components/secret-rotations-v2/CreateSecretRotationV2Modal.tsx +++ b/frontend/src/components/secret-rotations-v2/CreateSecretRotationV2Modal.tsx @@ -27,18 +27,20 @@ type ContentProps = { selectedRotation: SecretRotation | null; setSelectedRotation: (selectedRotation: SecretRotation | null) => void; initialFormData?: Partial; + onCancel: () => void; } & SharedProps; const Content = ({ setSelectedRotation, selectedRotation, initialFormData, + onCancel, ...props }: ContentProps) => { if (selectedRotation) { return ( setSelectedRotation(null)} + onCancel={onCancel} type={selectedRotation} initialFormData={initialFormData} {...props} @@ -93,13 +95,17 @@ export const CreateSecretRotationV2Modal = ({ onOpenChange, isOpen, ...props }: } }, [connectionId, connectionName]); + const handleReset = () => { + setSelectedRotation(null); + setInitialFormData(undefined); + }; + return ( { if (!open) { - setSelectedRotation(null); - setInitialFormData(undefined); + handleReset(); } onOpenChange(open); }} @@ -137,9 +143,10 @@ export const CreateSecretRotationV2Modal = ({ onOpenChange, isOpen, ...props }: > { - setSelectedRotation(null); + handleReset(); onOpenChange(false); }} + onCancel={handleReset} initialFormData={initialFormData} selectedRotation={selectedRotation} setSelectedRotation={setSelectedRotation} diff --git a/frontend/src/components/secret-scanning/CreateSecretScanningDataSourceModal.tsx b/frontend/src/components/secret-scanning/CreateSecretScanningDataSourceModal.tsx index 520aa0365..fb1081d02 100644 --- a/frontend/src/components/secret-scanning/CreateSecretScanningDataSourceModal.tsx +++ b/frontend/src/components/secret-scanning/CreateSecretScanningDataSourceModal.tsx @@ -24,16 +24,18 @@ type ContentProps = { selectedDataSource: SecretScanningDataSource | null; setSelectedDataSource: (selectedDataSource: SecretScanningDataSource | null) => void; initialFormData?: Partial; + onCancel: () => void; }; -const Content = ({ setSelectedDataSource, selectedDataSource, ...props }: ContentProps) => { +const Content = ({ + setSelectedDataSource, + selectedDataSource, + onCancel, + ...props +}: ContentProps) => { if (selectedDataSource) { return ( - setSelectedDataSource(null)} - type={selectedDataSource} - {...props} - /> + ); } @@ -86,11 +88,18 @@ export const CreateSecretScanningDataSourceModal = ({ onOpenChange, isOpen, ...p } }, [connectionId, connectionName]); + const resetModal = () => { + setSelectedDataSource(null); + setInitialFormData(undefined); + }; + return ( { - if (!open) setSelectedDataSource(null); + if (!open) { + resetModal(); + } onOpenChange(open); }} > @@ -127,9 +136,10 @@ export const CreateSecretScanningDataSourceModal = ({ onOpenChange, isOpen, ...p > { - setSelectedDataSource(null); + resetModal(); onOpenChange(false); }} + onCancel={resetModal} selectedDataSource={selectedDataSource} setSelectedDataSource={setSelectedDataSource} initialFormData={initialFormData} diff --git a/frontend/src/pages/public/ErrorPage/components/ProjectAccessError.tsx b/frontend/src/pages/public/ErrorPage/components/ProjectAccessError.tsx index 95a7d3729..d6fd57d56 100644 --- a/frontend/src/pages/public/ErrorPage/components/ProjectAccessError.tsx +++ b/frontend/src/pages/public/ErrorPage/components/ProjectAccessError.tsx @@ -8,7 +8,6 @@ import { RequestProjectAccessModal } from "@app/components/projects"; import { AccessRestrictedBanner, Button } from "@app/components/v2"; import { OrgPermissionSubjects } from "@app/context"; import { OrgPermissionAdminConsoleAction } from "@app/context/OrgPermissionContext/types"; -import { getProjectHomePage } from "@app/helpers/project"; import { usePopUp } from "@app/hooks"; import { useOrgAdminAccessProject, useSearchProjects } from "@app/hooks/api"; @@ -41,10 +40,7 @@ export const ProjectAccessError = () => { projectId: project.id }); await navigate({ - to: getProjectHomePage(project.type, project.environments), - params: { - projectId: project.id - } + to: "." }); } catch { createNotification({