mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 02:27:39 +00:00
improvements: address more feedback
This commit is contained in:
@@ -223,7 +223,7 @@ export const useGetProjectSecretsOverview = (
|
|||||||
environments
|
environments
|
||||||
});
|
});
|
||||||
|
|
||||||
queryClient.resetQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: dashboardKeys.getSecretValuesRoot()
|
queryKey: dashboardKeys.getSecretValuesRoot()
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -335,7 +335,7 @@ export const useGetProjectSecretsDetails = (
|
|||||||
tags
|
tags
|
||||||
});
|
});
|
||||||
|
|
||||||
queryClient.resetQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: dashboardKeys.getSecretValuesRoot()
|
queryKey: dashboardKeys.getSecretValuesRoot()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import axios from "axios";
|
|||||||
import { createNotification } from "@app/components/notifications";
|
import { createNotification } from "@app/components/notifications";
|
||||||
import { apiRequest } from "@app/config/request";
|
import { apiRequest } from "@app/config/request";
|
||||||
import { useToggle } from "@app/hooks/useToggle";
|
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 { ERROR_NOT_ALLOWED_READ_SECRETS } from "./constants";
|
||||||
import {
|
import {
|
||||||
@@ -81,7 +82,7 @@ export const mergePersonalSecrets = (rawSecrets: SecretV3Raw[]) => {
|
|||||||
id: el.id,
|
id: el.id,
|
||||||
env: el.environment,
|
env: el.environment,
|
||||||
key: el.secretKey,
|
key: el.secretKey,
|
||||||
value: el.secretValue,
|
value: el.secretValueHidden ? HIDDEN_SECRET_VALUE : el.secretValue,
|
||||||
secretValueHidden: el.secretValueHidden,
|
secretValueHidden: el.secretValueHidden,
|
||||||
tags: el.tags || [],
|
tags: el.tags || [],
|
||||||
comment: el.secretComment || "",
|
comment: el.secretComment || "",
|
||||||
|
|||||||
+1
-1
@@ -151,7 +151,7 @@ export const SecretEditRow = ({
|
|||||||
formState: { isDirty, isSubmitting }
|
formState: { isDirty, isSubmitting }
|
||||||
} = useForm({
|
} = useForm({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
value: (secretValueData?.valueOverride ?? secretValueData?.value) || null
|
value: secretValueData?.valueOverride ?? secretValueData?.value ?? (defaultValue || null)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -47,10 +47,12 @@ import {
|
|||||||
useGetWsTags
|
useGetWsTags
|
||||||
} from "@app/hooks/api";
|
} from "@app/hooks/api";
|
||||||
import { useGetProjectSecretsDetails } from "@app/hooks/api/dashboard";
|
import { useGetProjectSecretsDetails } from "@app/hooks/api/dashboard";
|
||||||
|
import { dashboardKeys } from "@app/hooks/api/dashboard/queries";
|
||||||
import { DashboardSecretsOrderBy } from "@app/hooks/api/dashboard/types";
|
import { DashboardSecretsOrderBy } from "@app/hooks/api/dashboard/types";
|
||||||
import { useGetFolderCommitsCount } from "@app/hooks/api/folderCommits";
|
import { useGetFolderCommitsCount } from "@app/hooks/api/folderCommits";
|
||||||
import { OrderByDirection } from "@app/hooks/api/generic/types";
|
import { OrderByDirection } from "@app/hooks/api/generic/types";
|
||||||
import { ProjectVersion } from "@app/hooks/api/projects/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 { PendingAction } from "@app/hooks/api/secretFolders/types";
|
||||||
import { useCreateCommit } from "@app/hooks/api/secrets/mutations";
|
import { useCreateCommit } from "@app/hooks/api/secrets/mutations";
|
||||||
import { SecretV3RawSanitized } from "@app/hooks/api/types";
|
import { SecretV3RawSanitized } from "@app/hooks/api/types";
|
||||||
@@ -152,6 +154,10 @@ const Page = () => {
|
|||||||
}
|
}
|
||||||
}, [isBatchMode, projectId, environment, secretPath, loadPendingChanges]);
|
}, [isBatchMode, projectId, environment, secretPath, loadPendingChanges]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isVisible) setIsVisible(false);
|
||||||
|
}, [environment]);
|
||||||
|
|
||||||
const canReadSecret = hasSecretReadValueOrDescribePermission(
|
const canReadSecret = hasSecretReadValueOrDescribePermission(
|
||||||
permission,
|
permission,
|
||||||
ProjectPermissionSecretActions.DescribeSecret,
|
ProjectPermissionSecretActions.DescribeSecret,
|
||||||
@@ -335,6 +341,24 @@ const Page = () => {
|
|||||||
pendingChanges: changes,
|
pendingChanges: changes,
|
||||||
message
|
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({
|
createNotification({
|
||||||
text: isProtectedBranch
|
text: isProtectedBranch
|
||||||
? "Requested changes have been sent for review"
|
? "Requested changes have been sent for review"
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ export interface PendingSecretDelete extends BasePendingChange {
|
|||||||
type: PendingAction.Delete;
|
type: PendingAction.Delete;
|
||||||
secretKey: string;
|
secretKey: string;
|
||||||
secretValue: string;
|
secretValue: string;
|
||||||
|
secretValueHidden: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Folder-related change types
|
// Folder-related change types
|
||||||
|
|||||||
+14
-3
@@ -13,6 +13,7 @@ import { AnimatePresence, motion } from "framer-motion";
|
|||||||
import { Badge, Button, Input, Modal, ModalContent } from "@app/components/v2";
|
import { Badge, Button, Input, Modal, ModalContent } from "@app/components/v2";
|
||||||
import { PendingAction } from "@app/hooks/api/secretFolders/types";
|
import { PendingAction } from "@app/hooks/api/secretFolders/types";
|
||||||
import { SecretVersionDiffView } from "@app/pages/secret-manager/CommitDetailsPage/components/SecretVersionDiffView";
|
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 {
|
import {
|
||||||
PendingChange,
|
PendingChange,
|
||||||
@@ -105,7 +106,12 @@ const RenderSecretChanges = ({ onDiscard, change }: RenderResourceProps) => {
|
|||||||
version: 1, // placeholder, not used
|
version: 1, // placeholder, not used
|
||||||
secretKey: change.newSecretName ? existingSecret.key : undefined,
|
secretKey: change.newSecretName ? existingSecret.key : undefined,
|
||||||
secretValue:
|
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,
|
tags: change.tags ? (existingSecret.tags?.map((tag) => tag.slug) ?? []) : undefined,
|
||||||
secretMetadata: change.secretMetadata ? existingSecret.secretMetadata : undefined,
|
secretMetadata: change.secretMetadata ? existingSecret.secretMetadata : undefined,
|
||||||
skipMultilineEncoding:
|
skipMultilineEncoding:
|
||||||
@@ -130,7 +136,7 @@ const RenderSecretChanges = ({ onDiscard, change }: RenderResourceProps) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (change.type === PendingAction.Delete) {
|
if (change.type === PendingAction.Delete) {
|
||||||
const { secretKey, secretValue } = change;
|
const { secretKey, secretValue, secretValueHidden } = change;
|
||||||
return (
|
return (
|
||||||
<SecretVersionDiffView
|
<SecretVersionDiffView
|
||||||
onDiscard={onDiscard}
|
onDiscard={onDiscard}
|
||||||
@@ -143,7 +149,12 @@ const RenderSecretChanges = ({ onDiscard, change }: RenderResourceProps) => {
|
|||||||
{
|
{
|
||||||
version: 1, // placeholder, not used
|
version: 1, // placeholder, not used
|
||||||
secretKey,
|
secretKey,
|
||||||
secretValue: secretValue || undefined
|
// eslint-disable-next-line no-nested-ternary
|
||||||
|
secretValue: secretValue
|
||||||
|
? secretValueHidden
|
||||||
|
? HIDDEN_SECRET_VALUE_API_MASK
|
||||||
|
: secretValue
|
||||||
|
: undefined
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}}
|
}}
|
||||||
|
|||||||
+3
-2
@@ -212,7 +212,8 @@ export const SecretItem = memo(
|
|||||||
reset,
|
reset,
|
||||||
getValues,
|
getValues,
|
||||||
trigger,
|
trigger,
|
||||||
formState: { isDirty, isSubmitting, errors }
|
formState: { isDirty, isSubmitting, errors },
|
||||||
|
getFieldState
|
||||||
} = useForm<TFormSchema>({
|
} = useForm<TFormSchema>({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
...secret,
|
...secret,
|
||||||
@@ -497,7 +498,7 @@ export const SecretItem = memo(
|
|||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
role="button"
|
role="button"
|
||||||
>
|
>
|
||||||
{secretValueHidden && !isOverridden && !isPending && (
|
{secretValueHidden && !getFieldState("value").isDirty && (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
content={`You do not have access to view the current value${canEditSecretValue && !isRotatedSecret ? ", but you can set a new one" : "."}`}
|
content={`You do not have access to view the current value${canEditSecretValue && !isRotatedSecret ? ", but you can set a new one" : "."}`}
|
||||||
>
|
>
|
||||||
|
|||||||
+8
-2
@@ -466,7 +466,12 @@ export const SecretListView = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const handleSecretDelete = useCallback(async () => {
|
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 {
|
try {
|
||||||
if (isBatchMode) {
|
if (isBatchMode) {
|
||||||
const deleteChange: PendingSecretDelete = {
|
const deleteChange: PendingSecretDelete = {
|
||||||
@@ -475,7 +480,8 @@ export const SecretListView = ({
|
|||||||
secretKey: key,
|
secretKey: key,
|
||||||
secretValue: value || "",
|
secretValue: value || "",
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
resourceType: "secret"
|
resourceType: "secret",
|
||||||
|
secretValueHidden
|
||||||
};
|
};
|
||||||
|
|
||||||
addPendingChange(deleteChange, {
|
addPendingChange(deleteChange, {
|
||||||
|
|||||||
Reference in New Issue
Block a user