From c6c3f2c4107a62c933af7059d82baa6003dcddbd Mon Sep 17 00:00:00 2001 From: Scott Wilson Date: Thu, 18 Sep 2025 14:29:28 -0700 Subject: [PATCH] improvements: address more feedback --- frontend/src/hooks/api/dashboard/queries.tsx | 4 ++-- frontend/src/hooks/api/secrets/queries.tsx | 3 ++- .../SecretOverviewTableRow/SecretEditRow.tsx | 2 +- .../SecretDashboardPage.tsx | 24 +++++++++++++++++++ .../SecretMainPage.store.tsx | 1 + .../components/CommitForm/CommitForm.tsx | 17 ++++++++++--- .../components/SecretListView/SecretItem.tsx | 5 ++-- .../SecretListView/SecretListView.tsx | 10 ++++++-- 8 files changed, 55 insertions(+), 11 deletions(-) diff --git a/frontend/src/hooks/api/dashboard/queries.tsx b/frontend/src/hooks/api/dashboard/queries.tsx index 0d2a0b8be..3866c6337 100644 --- a/frontend/src/hooks/api/dashboard/queries.tsx +++ b/frontend/src/hooks/api/dashboard/queries.tsx @@ -223,7 +223,7 @@ export const useGetProjectSecretsOverview = ( environments }); - queryClient.resetQueries({ + queryClient.invalidateQueries({ queryKey: dashboardKeys.getSecretValuesRoot() }); @@ -335,7 +335,7 @@ export const useGetProjectSecretsDetails = ( tags }); - queryClient.resetQueries({ + queryClient.invalidateQueries({ queryKey: dashboardKeys.getSecretValuesRoot() }); diff --git a/frontend/src/hooks/api/secrets/queries.tsx b/frontend/src/hooks/api/secrets/queries.tsx index 4eb2ba22f..95d0b9cdf 100644 --- a/frontend/src/hooks/api/secrets/queries.tsx +++ b/frontend/src/hooks/api/secrets/queries.tsx @@ -6,6 +6,7 @@ import axios from "axios"; import { createNotification } from "@app/components/notifications"; import { apiRequest } from "@app/config/request"; import { useToggle } from "@app/hooks/useToggle"; +import { HIDDEN_SECRET_VALUE } from "@app/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem"; import { ERROR_NOT_ALLOWED_READ_SECRETS } from "./constants"; import { @@ -81,7 +82,7 @@ export const mergePersonalSecrets = (rawSecrets: SecretV3Raw[]) => { id: el.id, env: el.environment, key: el.secretKey, - value: el.secretValue, + value: el.secretValueHidden ? HIDDEN_SECRET_VALUE : el.secretValue, secretValueHidden: el.secretValueHidden, tags: el.tags || [], comment: el.secretComment || "", diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewTableRow/SecretEditRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewTableRow/SecretEditRow.tsx index 9046f2ea7..a6ed5fc58 100644 --- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewTableRow/SecretEditRow.tsx +++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewTableRow/SecretEditRow.tsx @@ -151,7 +151,7 @@ export const SecretEditRow = ({ formState: { isDirty, isSubmitting } } = useForm({ defaultValues: { - value: (secretValueData?.valueOverride ?? secretValueData?.value) || null + value: secretValueData?.valueOverride ?? secretValueData?.value ?? (defaultValue || null) } }); diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/SecretDashboardPage.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/SecretDashboardPage.tsx index 953353e5f..f6712e1fc 100644 --- a/frontend/src/pages/secret-manager/SecretDashboardPage/SecretDashboardPage.tsx +++ b/frontend/src/pages/secret-manager/SecretDashboardPage/SecretDashboardPage.tsx @@ -47,10 +47,12 @@ import { useGetWsTags } from "@app/hooks/api"; import { useGetProjectSecretsDetails } from "@app/hooks/api/dashboard"; +import { dashboardKeys } from "@app/hooks/api/dashboard/queries"; import { DashboardSecretsOrderBy } from "@app/hooks/api/dashboard/types"; import { useGetFolderCommitsCount } from "@app/hooks/api/folderCommits"; import { OrderByDirection } from "@app/hooks/api/generic/types"; import { ProjectVersion } from "@app/hooks/api/projects/types"; +import { queryClient } from "@app/hooks/api/reactQuery"; import { PendingAction } from "@app/hooks/api/secretFolders/types"; import { useCreateCommit } from "@app/hooks/api/secrets/mutations"; import { SecretV3RawSanitized } from "@app/hooks/api/types"; @@ -152,6 +154,10 @@ const Page = () => { } }, [isBatchMode, projectId, environment, secretPath, loadPendingChanges]); + useEffect(() => { + if (isVisible) setIsVisible(false); + }, [environment]); + const canReadSecret = hasSecretReadValueOrDescribePermission( permission, ProjectPermissionSecretActions.DescribeSecret, @@ -335,6 +341,24 @@ const Page = () => { pendingChanges: changes, message }); + + if (!isProtectedBranch) { + pendingChanges.secrets.forEach((secret) => { + if (secret.type === "update" && secret.secretValue !== undefined) { + queryClient.setQueryData( + dashboardKeys.getSecretValue({ + projectId, + environment, + secretPath, + secretKey: secret.newSecretName ?? secret.secretKey, + isOverride: false + }), + { value: secret.secretValue } + ); + } + }); + } + createNotification({ text: isProtectedBranch ? "Requested changes have been sent for review" diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/SecretMainPage.store.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/SecretMainPage.store.tsx index 64367a7d1..06fecf169 100644 --- a/frontend/src/pages/secret-manager/SecretDashboardPage/SecretMainPage.store.tsx +++ b/frontend/src/pages/secret-manager/SecretDashboardPage/SecretMainPage.store.tsx @@ -54,6 +54,7 @@ export interface PendingSecretDelete extends BasePendingChange { type: PendingAction.Delete; secretKey: string; secretValue: string; + secretValueHidden: boolean; } // Folder-related change types diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/CommitForm/CommitForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/CommitForm/CommitForm.tsx index 59cceb9bb..dbccd93e0 100644 --- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/CommitForm/CommitForm.tsx +++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/CommitForm/CommitForm.tsx @@ -13,6 +13,7 @@ import { AnimatePresence, motion } from "framer-motion"; import { Badge, Button, Input, Modal, ModalContent } from "@app/components/v2"; import { PendingAction } from "@app/hooks/api/secretFolders/types"; import { SecretVersionDiffView } from "@app/pages/secret-manager/CommitDetailsPage/components/SecretVersionDiffView"; +import { HIDDEN_SECRET_VALUE_API_MASK } from "@app/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem"; import { PendingChange, @@ -105,7 +106,12 @@ const RenderSecretChanges = ({ onDiscard, change }: RenderResourceProps) => { version: 1, // placeholder, not used secretKey: change.newSecretName ? existingSecret.key : undefined, secretValue: - change.secretValue !== undefined ? (change.originalValue ?? "") : undefined, + // eslint-disable-next-line no-nested-ternary + change.secretValue !== undefined + ? change.existingSecret.secretValueHidden + ? HIDDEN_SECRET_VALUE_API_MASK + : (change.originalValue ?? "") + : undefined, tags: change.tags ? (existingSecret.tags?.map((tag) => tag.slug) ?? []) : undefined, secretMetadata: change.secretMetadata ? existingSecret.secretMetadata : undefined, skipMultilineEncoding: @@ -130,7 +136,7 @@ const RenderSecretChanges = ({ onDiscard, change }: RenderResourceProps) => { } if (change.type === PendingAction.Delete) { - const { secretKey, secretValue } = change; + const { secretKey, secretValue, secretValueHidden } = change; return ( { { version: 1, // placeholder, not used secretKey, - secretValue: secretValue || undefined + // eslint-disable-next-line no-nested-ternary + secretValue: secretValue + ? secretValueHidden + ? HIDDEN_SECRET_VALUE_API_MASK + : secretValue + : undefined } ] }} diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem.tsx index e8894cb79..6191e2a18 100644 --- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem.tsx +++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem.tsx @@ -212,7 +212,8 @@ export const SecretItem = memo( reset, getValues, trigger, - formState: { isDirty, isSubmitting, errors } + formState: { isDirty, isSubmitting, errors }, + getFieldState } = useForm({ defaultValues: { ...secret, @@ -497,7 +498,7 @@ export const SecretItem = memo( tabIndex={0} role="button" > - {secretValueHidden && !isOverridden && !isPending && ( + {secretValueHidden && !getFieldState("value").isDirty && ( diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretListView.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretListView.tsx index 010d6a4e2..4fc314bdd 100644 --- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretListView.tsx +++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretListView.tsx @@ -466,7 +466,12 @@ export const SecretListView = ({ ); const handleSecretDelete = useCallback(async () => { - const { key, id: secretId, value } = popUp.deleteSecret?.data as SecretV3RawSanitized; + const { + key, + id: secretId, + value, + secretValueHidden + } = popUp.deleteSecret?.data as SecretV3RawSanitized; try { if (isBatchMode) { const deleteChange: PendingSecretDelete = { @@ -475,7 +480,8 @@ export const SecretListView = ({ secretKey: key, secretValue: value || "", timestamp: Date.now(), - resourceType: "secret" + resourceType: "secret", + secretValueHidden }; addPendingChange(deleteChange, {