mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 15:27:46 +00:00
Merge pull request #4491 from Infisical/secrets-page-ui-optimization
Optimize re-render issue on secrets page
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
import { apiRequest } from "@app/config/request";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
|
||||||
|
import { apiRequest } from "@app/config/request";
|
||||||
|
|
||||||
import { ExternalMigrationProviders } from "./types";
|
import { ExternalMigrationProviders } from "./types";
|
||||||
|
|
||||||
const externalMigrationQueryKeys = {
|
const externalMigrationQueryKeys = {
|
||||||
|
|||||||
+1
-1
@@ -15,8 +15,8 @@ import {
|
|||||||
OrgPermissionSubjects
|
OrgPermissionSubjects
|
||||||
} from "@app/context/OrgPermissionContext/types";
|
} from "@app/context/OrgPermissionContext/types";
|
||||||
import { gatewaysQueryKeys } from "@app/hooks/api";
|
import { gatewaysQueryKeys } from "@app/hooks/api";
|
||||||
import { useImportVault } from "@app/hooks/api/migration/mutations";
|
|
||||||
import { useHasCustomMigrationAvailable } from "@app/hooks/api/migration";
|
import { useHasCustomMigrationAvailable } from "@app/hooks/api/migration";
|
||||||
|
import { useImportVault } from "@app/hooks/api/migration/mutations";
|
||||||
import { ExternalMigrationProviders } from "@app/hooks/api/migration/types";
|
import { ExternalMigrationProviders } from "@app/hooks/api/migration/types";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|||||||
+3
-3
@@ -75,7 +75,7 @@ type Props = {
|
|||||||
onCreateTag: () => void;
|
onCreateTag: () => void;
|
||||||
environment: string;
|
environment: string;
|
||||||
secretPath: string;
|
secretPath: string;
|
||||||
handleSecretShare: () => void;
|
onShareSecret: (sec: SecretV3RawSanitized) => void;
|
||||||
importedBy?: {
|
importedBy?: {
|
||||||
environment: { name: string; slug: string };
|
environment: { name: string; slug: string };
|
||||||
folders: {
|
folders: {
|
||||||
@@ -102,7 +102,7 @@ export const SecretItem = memo(
|
|||||||
onToggleSecretSelect,
|
onToggleSecretSelect,
|
||||||
environment,
|
environment,
|
||||||
secretPath,
|
secretPath,
|
||||||
handleSecretShare,
|
onShareSecret,
|
||||||
importedBy,
|
importedBy,
|
||||||
isPending,
|
isPending,
|
||||||
pendingAction,
|
pendingAction,
|
||||||
@@ -682,7 +682,7 @@ export const SecretItem = memo(
|
|||||||
variant="plain"
|
variant="plain"
|
||||||
size="md"
|
size="md"
|
||||||
ariaLabel="share-secret"
|
ariaLabel="share-secret"
|
||||||
onClick={handleSecretShare}
|
onClick={() => onShareSecret(secret)}
|
||||||
>
|
>
|
||||||
<Tooltip content="Share Secret">
|
<Tooltip content="Share Secret">
|
||||||
<FontAwesomeSymbol
|
<FontAwesomeSymbol
|
||||||
|
|||||||
+19
-16
@@ -1,4 +1,4 @@
|
|||||||
import { useCallback } from "react";
|
import { useCallback, useEffect, useRef } from "react";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { useQueryClient } from "@tanstack/react-query";
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
|
|
||||||
@@ -100,6 +100,11 @@ export const SecretListView = ({
|
|||||||
});
|
});
|
||||||
const { addPendingChange } = useBatchModeActions();
|
const { addPendingChange } = useBatchModeActions();
|
||||||
|
|
||||||
|
const pendingChangesRef = useRef(pendingChanges);
|
||||||
|
useEffect(() => {
|
||||||
|
pendingChangesRef.current = pendingChanges;
|
||||||
|
}, [pendingChanges]);
|
||||||
|
|
||||||
const handleSecretOperation = async (
|
const handleSecretOperation = async (
|
||||||
operation: "create" | "update" | "delete",
|
operation: "create" | "update" | "delete",
|
||||||
type: SecretType,
|
type: SecretType,
|
||||||
@@ -337,7 +342,10 @@ export const SecretListView = ({
|
|||||||
secretPath
|
secretPath
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const trueOriginalSecret = getTrueOriginalSecret(orgSecret, pendingChanges.secrets);
|
const trueOriginalSecret = getTrueOriginalSecret(
|
||||||
|
orgSecret,
|
||||||
|
pendingChangesRef.current.secrets
|
||||||
|
);
|
||||||
|
|
||||||
const updateChange: PendingSecretUpdate = {
|
const updateChange: PendingSecretUpdate = {
|
||||||
id: orgSecret.id,
|
id: orgSecret.id,
|
||||||
@@ -442,15 +450,7 @@ export const SecretListView = ({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[
|
[environment, secretPath, isProtectedBranch, isBatchMode, workspaceId, addPendingChange]
|
||||||
environment,
|
|
||||||
secretPath,
|
|
||||||
isProtectedBranch,
|
|
||||||
isBatchMode,
|
|
||||||
workspaceId,
|
|
||||||
addPendingChange,
|
|
||||||
pendingChanges.secrets
|
|
||||||
]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleSecretDelete = useCallback(async () => {
|
const handleSecretDelete = useCallback(async () => {
|
||||||
@@ -535,6 +535,13 @@ export const SecretListView = ({
|
|||||||
(sec: SecretV3RawSanitized) => handlePopUpOpen("secretDetail", sec),
|
(sec: SecretV3RawSanitized) => handlePopUpOpen("secretDetail", sec),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
const onShareSecret = useCallback(
|
||||||
|
(sec: SecretV3RawSanitized) =>
|
||||||
|
handlePopUpOpen("createSharedSecret", {
|
||||||
|
value: sec.valueOverride ?? sec.value
|
||||||
|
}),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -557,11 +564,7 @@ export const SecretListView = ({
|
|||||||
onDetailViewSecret={onDetailViewSecret}
|
onDetailViewSecret={onDetailViewSecret}
|
||||||
importedBy={importedBy}
|
importedBy={importedBy}
|
||||||
onCreateTag={onCreateTag}
|
onCreateTag={onCreateTag}
|
||||||
handleSecretShare={() =>
|
onShareSecret={onShareSecret}
|
||||||
handlePopUpOpen("createSharedSecret", {
|
|
||||||
value: secret.valueOverride ?? secret.value
|
|
||||||
})
|
|
||||||
}
|
|
||||||
isPending={secret.isPending}
|
isPending={secret.isPending}
|
||||||
pendingAction={secret.pendingAction}
|
pendingAction={secret.pendingAction}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user