improvements: resolve more commit state issues form value reveal change

This commit is contained in:
Scott Wilson
2025-09-18 12:09:28 -07:00
parent 120b767f16
commit 999ce3fec6
6 changed files with 13 additions and 14 deletions
+1 -7
View File
@@ -272,13 +272,7 @@ export const useGetSecretVersion = (dto: GetSecretVersionsDTO) =>
export const fetchSecretVersionValue = async (secretId: string, version: number) => { export const fetchSecretVersionValue = async (secretId: string, version: number) => {
const { data } = await apiRequest.get<TSecretVersionValue>( const { data } = await apiRequest.get<TSecretVersionValue>(
`/api/v1/dashboard/secret-versions/${secretId}/value/${version}`, `/api/v1/dashboard/secret-versions/${secretId}/value/${version}`
{
params: {
secretId,
version
}
}
); );
return data.value; return data.value;
}; };
@@ -29,7 +29,7 @@ export const SecretOverviewRotationSecretRow = ({
const { data: secretValueData, isError } = useGetSecretValue( const { data: secretValueData, isError } = useGetSecretValue(
{ {
secretKey: secret!.key, secretKey: secret?.key ?? "",
environment, environment,
secretPath, secretPath,
projectId: currentProject.id projectId: currentProject.id
@@ -117,7 +117,7 @@ export const SecretEditRow = ({
? { ? {
environment: importedSecret.environment, environment: importedSecret.environment,
secretPath: importedSecret.secretPath, secretPath: importedSecret.secretPath,
secretKey: importedSecret.secret!.key, secretKey: importedSecret.secret?.key ?? "",
projectId: currentProject.id projectId: currentProject.id
} }
: { : {
@@ -143,7 +143,7 @@ const RenderSecretChanges = ({ onDiscard, change }: RenderResourceProps) => {
{ {
version: 1, // placeholder, not used version: 1, // placeholder, not used
secretKey, secretKey,
secretValue secretValue: secretValue || undefined
} }
] ]
}} }}
@@ -126,7 +126,10 @@ export const SecretItem = memo(
const [isFieldFocused, setIsFieldFocused] = useToggle(); const [isFieldFocused, setIsFieldFocused] = useToggle();
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const canFetchSecretValue = !originalSecret.secretValueHidden && !originalSecret.isEmpty; const canFetchSecretValue =
!originalSecret.secretValueHidden &&
!originalSecret.isEmpty &&
pendingAction !== PendingAction.Create;
const fetchSecretValueParams = { const fetchSecretValueParams = {
environment, environment,
@@ -508,13 +511,15 @@ export const SecretItem = memo(
control={control} control={control}
render={({ field }) => ( render={({ field }) => (
<SecretInput <SecretInput
isLoadingValue={isLoadingSecretValue} isLoadingValue={isLoadingSecretValue && Boolean(secret.idOverride)}
isErrorLoadingValue={isErrorFetchingSecretValue} isErrorLoadingValue={isErrorFetchingSecretValue}
key="value-overriden" key="value-overriden"
isVisible={isVisible} isVisible={isVisible}
isReadOnly={isReadOnly} isReadOnly={isReadOnly}
{...field} {...field}
onFocus={() => setIsFieldFocused.on()} onFocus={() => {
if (secret.idOverride) setIsFieldFocused.on();
}}
onBlur={() => { onBlur={() => {
setIsFieldFocused.off(); setIsFieldFocused.off();
field.onBlur(); field.onBlur();
@@ -27,7 +27,7 @@ export const SecretRotationSecretRow = ({
{ {
environment, environment,
secretPath, secretPath,
secretKey: secret!.key, secretKey: secret?.key ?? "",
projectId: currentProject.id projectId: currentProject.id
}, },
{ {