improvements: address feedback progress

This commit is contained in:
Scott Wilson
2025-09-17 18:36:15 -07:00
parent 8f8e8d3f88
commit 5a4b83d900
5 changed files with 35 additions and 41 deletions

View File

@@ -446,9 +446,10 @@ export const secretV2BridgeDALFactory = ({ db, keyStore }: TSecretV2DalArg) => {
}
})
.where((bd) => {
void bd
.whereNull(`${TableName.SecretV2}.userId`)
.orWhere({ [`${TableName.SecretV2}.userId` as "userId"]: userId || null });
void bd.whereNull(`${TableName.SecretV2}.userId`);
// scott: removing this as we don't need to count overrides
// and there is currently a bug when you move secrets that doesn't move the override so this can skew count
// .orWhere({ [`${TableName.SecretV2}.userId` as "userId"]: userId || null });
})
.countDistinct(`${TableName.SecretV2}.key`);

View File

@@ -130,6 +130,14 @@ export const SecretReferenceTree = ({ secretPath, environment, secretKey }: Prop
);
}
if (tree?.children?.length === 0) {
return (
<div className="flex items-center justify-center py-4">
<span className="text-mineshaft-400">This secret does not contain references</span>
</div>
);
}
return (
<div>
<FormControl label="Expanded value">

View File

@@ -119,6 +119,7 @@ export const mergePersonalSecrets = (rawSecrets: SecretV3Raw[]) => {
sec.valueOverride = personalSecret.value;
sec.overrideAction = "modified";
sec.isEmpty = personalSecret.isEmpty;
sec.secretValueHidden = false;
}
});

View File

@@ -1,4 +1,4 @@
import { useCallback, useState } from "react";
import { useCallback, useEffect, useState } from "react";
import { Controller, useForm } from "react-hook-form";
import { subject } from "@casl/ability";
import {
@@ -15,10 +15,7 @@ import { twMerge } from "tailwind-merge";
import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
import {
hasSecretReference,
SecretReferenceTree
} from "@app/components/secrets/SecretReferenceDetails";
import { SecretReferenceTree } from "@app/components/secrets/SecretReferenceDetails";
import {
DeleteActionModal,
IconButton,
@@ -150,13 +147,20 @@ export const SecretEditRow = ({
control,
reset,
getValues,
setValue,
formState: { isDirty, isSubmitting }
} = useForm({
values: {
defaultValues: {
value: (secretValueData?.valueOverride ?? secretValueData?.value) || null
}
});
useEffect(() => {
if (secretValueData && !isDirty) {
setValue("value", secretValueData.valueOverride ?? secretValueData.value);
}
}, [secretValueData]);
const { permission } = useProjectPermission();
const [isDeleting, setIsDeleting] = useToggle();
@@ -171,7 +175,7 @@ export const SecretEditRow = ({
};
const handleCopySecretToClipboard = async () => {
if (!isSecretValueFetched) {
if (!isSecretValueFetched && !isDirty) {
try {
const data = await fetchSecretValue(fetchSecretValueParams);
@@ -402,18 +406,12 @@ export const SecretEditRow = ({
<Modal>
<ModalTrigger asChild>
<div className="opacity-0 group-hover:opacity-100">
<Tooltip
content={
hasSecretReference(defaultValue || "")
? "Secret Reference Tree"
: "Secret does not contain references"
}
>
<Tooltip content="Secret Reference Tree">
<IconButton
variant="plain"
ariaLabel="reference-tree"
className="h-full"
isDisabled={!hasSecretReference(defaultValue || "") || !canReadSecretValue}
isDisabled={!canReadSecretValue || !secretId || isEmpty}
>
<FontAwesomeIcon icon={faProjectDiagram} />
</IconButton>

View File

@@ -21,10 +21,7 @@ import { Link } from "@tanstack/react-router";
import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";
import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
import {
hasSecretReference,
SecretReferenceTree
} from "@app/components/secrets/SecretReferenceDetails";
import { SecretReferenceTree } from "@app/components/secrets/SecretReferenceDetails";
import {
Button,
Drawer,
@@ -843,26 +840,15 @@ export const SecretDetailSidebar = ({
)}
</div>
<div className="mt-auto flex items-center space-x-2 pb-4">
<Tooltip
content={
hasSecretReference(secret?.value)
? undefined
: "Secret does not contain any references."
}
className="z-[100] text-center"
<Button
className="flex-1"
variant="outline_bg"
isDisabled={cannotReadSecretValue || secret.isEmpty}
leftIcon={<FontAwesomeIcon icon={faProjectDiagram} />}
onClick={() => handlePopUpOpen("secretReferenceTree", secretKey)}
>
<div className="flex-1">
<Button
className="w-full"
variant="outline_bg"
isDisabled={cannotReadSecretValue || !hasSecretReference(secret?.value)}
leftIcon={<FontAwesomeIcon icon={faProjectDiagram} />}
onClick={() => handlePopUpOpen("secretReferenceTree", secretKey)}
>
Secret Reference Tree
</Button>
</div>
</Tooltip>
Secret Reference Tree
</Button>
<Tooltip content="Copy Secret ID" className="z-[100]">
<IconButton
variant="outline_bg"