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
@@ -446,9 +446,10 @@ export const secretV2BridgeDALFactory = ({ db, keyStore }: TSecretV2DalArg) => {
} }
}) })
.where((bd) => { .where((bd) => {
void bd void bd.whereNull(`${TableName.SecretV2}.userId`);
.whereNull(`${TableName.SecretV2}.userId`) // scott: removing this as we don't need to count overrides
.orWhere({ [`${TableName.SecretV2}.userId` as "userId"]: userId || null }); // 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`); .countDistinct(`${TableName.SecretV2}.key`);
@@ -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 ( return (
<div> <div>
<FormControl label="Expanded value"> <FormControl label="Expanded value">
@@ -119,6 +119,7 @@ export const mergePersonalSecrets = (rawSecrets: SecretV3Raw[]) => {
sec.valueOverride = personalSecret.value; sec.valueOverride = personalSecret.value;
sec.overrideAction = "modified"; sec.overrideAction = "modified";
sec.isEmpty = personalSecret.isEmpty; sec.isEmpty = personalSecret.isEmpty;
sec.secretValueHidden = false;
} }
}); });
@@ -1,4 +1,4 @@
import { useCallback, useState } from "react"; import { useCallback, useEffect, useState } from "react";
import { Controller, useForm } from "react-hook-form"; import { Controller, useForm } from "react-hook-form";
import { subject } from "@casl/ability"; import { subject } from "@casl/ability";
import { import {
@@ -15,10 +15,7 @@ import { twMerge } from "tailwind-merge";
import { createNotification } from "@app/components/notifications"; import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions"; import { ProjectPermissionCan } from "@app/components/permissions";
import { import { SecretReferenceTree } from "@app/components/secrets/SecretReferenceDetails";
hasSecretReference,
SecretReferenceTree
} from "@app/components/secrets/SecretReferenceDetails";
import { import {
DeleteActionModal, DeleteActionModal,
IconButton, IconButton,
@@ -150,13 +147,20 @@ export const SecretEditRow = ({
control, control,
reset, reset,
getValues, getValues,
setValue,
formState: { isDirty, isSubmitting } formState: { isDirty, isSubmitting }
} = useForm({ } = useForm({
values: { defaultValues: {
value: (secretValueData?.valueOverride ?? secretValueData?.value) || null value: (secretValueData?.valueOverride ?? secretValueData?.value) || null
} }
}); });
useEffect(() => {
if (secretValueData && !isDirty) {
setValue("value", secretValueData.valueOverride ?? secretValueData.value);
}
}, [secretValueData]);
const { permission } = useProjectPermission(); const { permission } = useProjectPermission();
const [isDeleting, setIsDeleting] = useToggle(); const [isDeleting, setIsDeleting] = useToggle();
@@ -171,7 +175,7 @@ export const SecretEditRow = ({
}; };
const handleCopySecretToClipboard = async () => { const handleCopySecretToClipboard = async () => {
if (!isSecretValueFetched) { if (!isSecretValueFetched && !isDirty) {
try { try {
const data = await fetchSecretValue(fetchSecretValueParams); const data = await fetchSecretValue(fetchSecretValueParams);
@@ -402,18 +406,12 @@ export const SecretEditRow = ({
<Modal> <Modal>
<ModalTrigger asChild> <ModalTrigger asChild>
<div className="opacity-0 group-hover:opacity-100"> <div className="opacity-0 group-hover:opacity-100">
<Tooltip <Tooltip content="Secret Reference Tree">
content={
hasSecretReference(defaultValue || "")
? "Secret Reference Tree"
: "Secret does not contain references"
}
>
<IconButton <IconButton
variant="plain" variant="plain"
ariaLabel="reference-tree" ariaLabel="reference-tree"
className="h-full" className="h-full"
isDisabled={!hasSecretReference(defaultValue || "") || !canReadSecretValue} isDisabled={!canReadSecretValue || !secretId || isEmpty}
> >
<FontAwesomeIcon icon={faProjectDiagram} /> <FontAwesomeIcon icon={faProjectDiagram} />
</IconButton> </IconButton>
@@ -21,10 +21,7 @@ import { Link } from "@tanstack/react-router";
import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal"; import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";
import { createNotification } from "@app/components/notifications"; import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions"; import { ProjectPermissionCan } from "@app/components/permissions";
import { import { SecretReferenceTree } from "@app/components/secrets/SecretReferenceDetails";
hasSecretReference,
SecretReferenceTree
} from "@app/components/secrets/SecretReferenceDetails";
import { import {
Button, Button,
Drawer, Drawer,
@@ -843,26 +840,15 @@ export const SecretDetailSidebar = ({
)} )}
</div> </div>
<div className="mt-auto flex items-center space-x-2 pb-4"> <div className="mt-auto flex items-center space-x-2 pb-4">
<Tooltip <Button
content={ className="flex-1"
hasSecretReference(secret?.value) variant="outline_bg"
? undefined isDisabled={cannotReadSecretValue || secret.isEmpty}
: "Secret does not contain any references." leftIcon={<FontAwesomeIcon icon={faProjectDiagram} />}
} onClick={() => handlePopUpOpen("secretReferenceTree", secretKey)}
className="z-[100] text-center"
> >
<div className="flex-1"> Secret Reference Tree
<Button </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>
<Tooltip content="Copy Secret ID" className="z-[100]"> <Tooltip content="Copy Secret ID" className="z-[100]">
<IconButton <IconButton
variant="outline_bg" variant="outline_bg"