Merge pull request #2004 from Infisical/daniel/show-imported-overwritten-values-overview

feat(platform): Show imported/overwritten values in secret overview
This commit is contained in:
Maidul Islam
2024-06-21 17:13:02 -04:00
committed by GitHub
18 changed files with 152 additions and 65 deletions
@@ -6,6 +6,8 @@ import { faUpload } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { parseDocument, Scalar, YAMLMap } from "yaml";
import { SecretType } from "@app/hooks/api/types";
import Button from "../basic/buttons/Button";
import Error from "../basic/Error";
import { createNotification } from "../notifications";
@@ -33,7 +35,6 @@ const DropZone = ({
numCurrentRows
}: DropZoneProps) => {
const { t } = useTranslation();
const handleDragEnter = (e: DragEvent) => {
e.preventDefault();
@@ -66,7 +67,7 @@ const DropZone = ({
key,
value: keyPairs[key as keyof typeof keyPairs].value,
comment: keyPairs[key as keyof typeof keyPairs].comments.join("\n"),
type: "shared",
type: SecretType.Shared,
tags: []
}));
break;
@@ -79,7 +80,7 @@ const DropZone = ({
key,
value: keyPairs[key as keyof typeof keyPairs],
comment: "",
type: "shared",
type: SecretType.Shared,
tags: []
}));
break;
@@ -102,7 +103,7 @@ const DropZone = ({
key,
value: keyPairs[key as keyof typeof keyPairs]?.toString() ?? "",
comment,
type: "shared",
type: SecretType.Shared,
tags: []
};
});
@@ -132,7 +133,7 @@ const DropZone = ({
if (file === undefined) {
createNotification({
text: "You can't inject files from VS Code. Click 'Reveal in finder', and drag your file directly from the directory where it's located.",
type: "error",
type: "error"
});
setLoading(false);
return;
@@ -1,5 +1,7 @@
import { SecretDataProps } from "public/data/frequentInterfaces";
import { SecretType } from "@app/hooks/api/types";
/**
* This function downloads the secrets as a .env file
* @param {object} obj
@@ -10,8 +12,8 @@ const checkOverrides = async ({ data }: { data: SecretDataProps[] }) => {
let secrets: SecretDataProps[] = data!.map((secret) => Object.create(secret));
const overridenSecrets = data!.filter((secret) =>
secret.valueOverride === undefined || secret?.value !== secret?.valueOverride
? "shared"
: "personal"
? SecretType.Shared
: SecretType.Personal
);
if (overridenSecrets.length) {
overridenSecrets.forEach((secret) => {
@@ -3,6 +3,7 @@ import crypto from "crypto";
import { SecretDataProps, Tag } from "public/data/frequentInterfaces";
import { fetchUserWsKey } from "@app/hooks/api/keys/queries";
import { SecretType } from "@app/hooks/api/types";
import { decryptAssymmetric, encryptSymmetric } from "../cryptography/crypto";
@@ -20,7 +21,7 @@ interface EncryptedSecretProps {
secretValueCiphertext: string;
secretValueIV: string;
secretValueTag: string;
type: "personal" | "shared";
type: SecretType;
tags: Tag[];
}
@@ -108,8 +109,8 @@ const encryptSecrets = async ({
secretCommentTag,
type:
secret.valueOverride === undefined || secret?.value !== secret?.valueOverride
? "shared"
: "personal",
? SecretType.Shared
: SecretType.Personal,
tags: secret.tags
};
@@ -15,7 +15,7 @@ const replaceContentWithDot = (str: string) => {
};
const syntaxHighlight = (content?: string | null, isVisible?: boolean, isImport?: boolean) => {
if (isImport) return "IMPORTED";
if (isImport && !content) return "IMPORTED";
if (content === "") return "EMPTY";
if (!content) return "EMPTY";
if (!isVisible) return replaceContentWithDot(content);