From 203422c1310edf99866f6b1410f09c2333d482cb Mon Sep 17 00:00:00 2001 From: = Date: Wed, 23 Oct 2024 00:10:14 +0530 Subject: [PATCH] feat: added reference tree to overview and secret main page, changed to better graph structure --- .../secret-v2-bridge/secret-v2-bridge-fns.ts | 4 +- .../SecretListView/SecretDetailSidebar.tsx | 45 +- .../components/SecretListView/SecretItem.tsx | 801 +++++++++--------- .../SecretListView/SecretListView.utils.ts | 7 +- .../SecretListView/SecretReferenceDetails.tsx | 96 --- .../SecretReferenceDetails.module.css | 79 ++ .../SecretReferenceDetails.tsx | 114 +++ .../SecretReferenceDetails/index.tsx | 1 + .../SecretOverviewTableRow/SecretEditRow.tsx | 64 +- 9 files changed, 662 insertions(+), 549 deletions(-) delete mode 100644 frontend/src/views/SecretMainPage/components/SecretListView/SecretReferenceDetails.tsx create mode 100644 frontend/src/views/SecretMainPage/components/SecretReferenceDetails/SecretReferenceDetails.module.css create mode 100644 frontend/src/views/SecretMainPage/components/SecretReferenceDetails/SecretReferenceDetails.tsx create mode 100644 frontend/src/views/SecretMainPage/components/SecretReferenceDetails/index.tsx diff --git a/backend/src/services/secret-v2-bridge/secret-v2-bridge-fns.ts b/backend/src/services/secret-v2-bridge/secret-v2-bridge-fns.ts index c2575f862..20afb85b7 100644 --- a/backend/src/services/secret-v2-bridge/secret-v2-bridge-fns.ts +++ b/backend/src/services/secret-v2-bridge/secret-v2-bridge-fns.ts @@ -11,6 +11,8 @@ import { TSecretV2BridgeDALFactory } from "./secret-v2-bridge-dal"; import { TFnSecretBulkDelete, TFnSecretBulkInsert, TFnSecretBulkUpdate } from "./secret-v2-bridge-types"; const INTERPOLATION_SYNTAX_REG = /\${([^}]+)}/g; +// akhilmhdh: JS regex with global save state in .test +const INTERPOLATION_SYNTAX_REG_NON_GLOBAL = /\${([^}]+)}/; export const shouldUseSecretV2Bridge = (version: number) => version === 3; @@ -497,7 +499,7 @@ export const expandSecretReferencesFactory = ({ trace }; - const shouldExpandMore = INTERPOLATION_SYNTAX_REG.test(referencedSecretValue); + const shouldExpandMore = INTERPOLATION_SYNTAX_REG_NON_GLOBAL.test(referencedSecretValue); if (dto.shouldStackTrace) { const stackTraceNode = { ...node, children: [], key: referencedSecretKey, trace: null }; trace?.children.push(stackTraceNode); diff --git a/frontend/src/views/SecretMainPage/components/SecretListView/SecretDetailSidebar.tsx b/frontend/src/views/SecretMainPage/components/SecretListView/SecretDetailSidebar.tsx index f948f3089..6aa7fd4e1 100644 --- a/frontend/src/views/SecretMainPage/components/SecretListView/SecretDetailSidebar.tsx +++ b/frontend/src/views/SecretMainPage/components/SecretListView/SecretDetailSidebar.tsx @@ -7,7 +7,6 @@ import { faCircleDot, faClock, faPlus, - faProjectDiagram, faShare, faTag } from "@fortawesome/free-solid-svg-icons"; @@ -29,9 +28,6 @@ import { FormControl, IconButton, Input, - Modal, - ModalContent, - ModalTrigger, Switch, Tag, TextArea, @@ -45,7 +41,6 @@ import { SecretV3RawSanitized, WsTag } from "@app/hooks/api/types"; import { CreateReminderForm } from "./CreateReminderForm"; import { formSchema, SecretActionType, TFormSchema } from "./SecretListView.utils"; -import { SecretReferenceTree } from "./SecretReferenceDetails"; type Props = { isOpen?: boolean; @@ -65,8 +60,6 @@ type Props = { handleSecretShare: (value: string) => void; }; -const INTERPOLATION_SYNTAX_REG = /\${([^}]+)}/g; - export const SecretDetailSidebar = ({ isOpen, onToggle, @@ -176,8 +169,6 @@ export const SecretDetailSidebar = ({ const secretReminderRepeatDays = watch("reminderRepeatDays"); const secretReminderNote = watch("reminderNote"); - const hasReferences = secret?.value?.match(INTERPOLATION_SYNTAX_REG); - return ( <> - - - - - - - )} - - - - + + + + + + + + + + )} + + + {(isAllowed) => ( + + + + + + + + )} + + + Add tags to this secret + {tags.map((tag) => { + const { id: tagId, slug, color } = tag; + + const isTagSelected = selectedTagsGroupById?.[tagId]; + return ( + handleTagSelect(tag)} + key={`${secret.id}-${tagId}`} + icon={ + isTagSelected && ( + + ) + } + iconPos="right" + > +
+
+ {slug} +
+ + ); + })} + + + + + + + {(isAllowed) => ( + + + + )} + + + + {(isAllowed) => ( + + + + + + + + )} + + + + + + + + +