mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
improvements: address more feedback
This commit is contained in:
@@ -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()
|
||||
});
|
||||
|
||||
|
||||
@@ -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 || "",
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -54,6 +54,7 @@ export interface PendingSecretDelete extends BasePendingChange {
|
||||
type: PendingAction.Delete;
|
||||
secretKey: string;
|
||||
secretValue: string;
|
||||
secretValueHidden: boolean;
|
||||
}
|
||||
|
||||
// Folder-related change types
|
||||
|
||||
@@ -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 (
|
||||
<SecretVersionDiffView
|
||||
onDiscard={onDiscard}
|
||||
@@ -143,7 +149,12 @@ const RenderSecretChanges = ({ onDiscard, change }: RenderResourceProps) => {
|
||||
{
|
||||
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
|
||||
}
|
||||
]
|
||||
}}
|
||||
|
||||
@@ -212,7 +212,8 @@ export const SecretItem = memo(
|
||||
reset,
|
||||
getValues,
|
||||
trigger,
|
||||
formState: { isDirty, isSubmitting, errors }
|
||||
formState: { isDirty, isSubmitting, errors },
|
||||
getFieldState
|
||||
} = useForm<TFormSchema>({
|
||||
defaultValues: {
|
||||
...secret,
|
||||
@@ -497,7 +498,7 @@ export const SecretItem = memo(
|
||||
tabIndex={0}
|
||||
role="button"
|
||||
>
|
||||
{secretValueHidden && !isOverridden && !isPending && (
|
||||
{secretValueHidden && !getFieldState("value").isDirty && (
|
||||
<Tooltip
|
||||
content={`You do not have access to view the current value${canEditSecretValue && !isRotatedSecret ? ", but you can set a new one" : "."}`}
|
||||
>
|
||||
|
||||
@@ -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, {
|
||||
|
||||
Reference in New Issue
Block a user