From 0f10874f8039dc238e078639aff179ee1c811da7 Mon Sep 17 00:00:00 2001 From: = Date: Wed, 9 Oct 2024 22:31:49 +0530 Subject: [PATCH] feat: added no secret access views --- ...20241008172622_project-permission-split.ts | 2 +- .../services/permission/project-permission.ts | 2 +- .../views/SecretMainPage/SecretMainPage.tsx | 14 +++++- .../SecretListView/SecretListView.tsx | 11 ----- .../SecretListView/SecretListView.utils.ts | 7 ++- .../SecretListView/SecretNoAccessListView.tsx | 44 ++++++++++++++++++ .../components/SecretListView/index.tsx | 1 + .../SecretNoAccessOverviewTableRow.tsx | 45 +++++++++++++++++++ .../SecretOverviewTableRow/index.tsx | 1 + 9 files changed, 110 insertions(+), 17 deletions(-) create mode 100644 frontend/src/views/SecretMainPage/components/SecretListView/SecretNoAccessListView.tsx create mode 100644 frontend/src/views/SecretOverviewPage/components/SecretOverviewTableRow/SecretNoAccessOverviewTableRow.tsx diff --git a/backend/src/db/migrations/20241008172622_project-permission-split.ts b/backend/src/db/migrations/20241008172622_project-permission-split.ts index 508c2ea42..19ac27609 100644 --- a/backend/src/db/migrations/20241008172622_project-permission-split.ts +++ b/backend/src/db/migrations/20241008172622_project-permission-split.ts @@ -1,5 +1,5 @@ /* eslint-disable no-await-in-loop */ -import { unpackRules } from "@casl/ability/extra"; +import { packRules, unpackRules } from "@casl/ability/extra"; import { Knex } from "knex"; import { diff --git a/backend/src/ee/services/permission/project-permission.ts b/backend/src/ee/services/permission/project-permission.ts index 1803137b6..329513e0e 100644 --- a/backend/src/ee/services/permission/project-permission.ts +++ b/backend/src/ee/services/permission/project-permission.ts @@ -764,7 +764,7 @@ export const backfillPermissionV1SchemaToV2Schema = (data: z.infer ({ ...el, - subject: ProjectPermissionSub.DynamicSecrets + subject: ProjectPermissionSub.SecretFolders })); const dynamicSecretPolicies = secretSubjects.map(({ subject, ...el }) => ({ diff --git a/frontend/src/views/SecretMainPage/SecretMainPage.tsx b/frontend/src/views/SecretMainPage/SecretMainPage.tsx index 92a1b257a..813e437e4 100644 --- a/frontend/src/views/SecretMainPage/SecretMainPage.tsx +++ b/frontend/src/views/SecretMainPage/SecretMainPage.tsx @@ -38,7 +38,7 @@ import { ActionBar } from "./components/ActionBar"; import { CreateSecretForm } from "./components/CreateSecretForm"; import { PitDrawer } from "./components/PitDrawer"; import { SecretDropzone } from "./components/SecretDropzone"; -import { SecretListView } from "./components/SecretListView"; +import { SecretListView, SecretNoAccessListView } from "./components/SecretListView"; import { SnapshotView } from "./components/SnapshotView"; import { StoreProvider } from "./SecretMainPage.store"; import { Filter, RowType } from "./SecretMainPage.types"; @@ -315,7 +315,6 @@ export const SecretMainPage = () => { setFilter(defaultFilterState); setDebouncedSearchFilter(""); }; - return (
@@ -418,6 +417,17 @@ export const SecretMainPage = () => { isProtectedBranch={isProtectedBranch} /> )} + {canReadSecret && ( + totalCount ? totalCount % perPage : perPage) - + (folders?.length || 0) - + (secrets?.length || 0) - + (dynamicSecrets?.length || 0), + 0 + )} + /> + )} {!canReadSecret && !canReadDynamicSecret && !canReadSecretImports && diff --git a/frontend/src/views/SecretMainPage/components/SecretListView/SecretListView.tsx b/frontend/src/views/SecretMainPage/components/SecretListView/SecretListView.tsx index 811a9e03b..d77dbe732 100644 --- a/frontend/src/views/SecretMainPage/components/SecretListView/SecretListView.tsx +++ b/frontend/src/views/SecretMainPage/components/SecretListView/SecretListView.tsx @@ -16,7 +16,6 @@ import { WsTag } from "@app/hooks/api/types"; import { AddShareSecretModal } from "@app/views/ShareSecretPage/components/AddShareSecretModal"; import { useSelectedSecretActions, useSelectedSecrets } from "../../SecretMainPage.store"; -import { Filter } from "../../SecretMainPage.types"; import { SecretDetailSidebar } from "./SecretDetaiSidebar"; import { SecretItem } from "./SecretItem"; import { FontAwesomeSpriteSymbols } from "./SecretListView.utils"; @@ -31,16 +30,6 @@ type Props = { isProtectedBranch?: boolean; }; -export const filterSecrets = (secrets: SecretV3RawSanitized[], filter: Filter) => - secrets.filter(({ key, value, tags }) => { - const isTagFilterActive = Boolean(Object.keys(filter.tags).length); - const searchTerm = filter.searchFilter.toLowerCase(); - return ( - (!isTagFilterActive || tags?.some(({ id }) => filter.tags?.[id])) && - (key.toLowerCase().includes(searchTerm) || value?.toLowerCase().includes(searchTerm)) - ); - }); - export const SecretListView = ({ secrets = [], environment, diff --git a/frontend/src/views/SecretMainPage/components/SecretListView/SecretListView.utils.ts b/frontend/src/views/SecretMainPage/components/SecretListView/SecretListView.utils.ts index eb9e4d195..4acdd32d0 100644 --- a/frontend/src/views/SecretMainPage/components/SecretListView/SecretListView.utils.ts +++ b/frontend/src/views/SecretMainPage/components/SecretListView/SecretListView.utils.ts @@ -10,6 +10,7 @@ import { faCopy, faEllipsis, faKey, + faLock, faShare, faTags } from "@fortawesome/free-solid-svg-icons"; @@ -71,7 +72,8 @@ export enum FontAwesomeSpriteName { Close = "close", CheckedCircle = "check-circle", ReplicatedSecretKey = "secret-replicated", - ShareSecret = "share-secret" + ShareSecret = "share-secret", + KeyLock = "key-lock" } // this is an optimization technique @@ -88,5 +90,6 @@ export const FontAwesomeSpriteSymbols = [ { icon: faClose, symbol: FontAwesomeSpriteName.Close }, { icon: faCheckCircle, symbol: FontAwesomeSpriteName.CheckedCircle }, { icon: faClone, symbol: FontAwesomeSpriteName.ReplicatedSecretKey }, - { icon: faShare, symbol: FontAwesomeSpriteName.ShareSecret } + { icon: faShare, symbol: FontAwesomeSpriteName.ShareSecret }, + { icon: faLock, symbol: FontAwesomeSpriteName.KeyLock } ]; diff --git a/frontend/src/views/SecretMainPage/components/SecretListView/SecretNoAccessListView.tsx b/frontend/src/views/SecretMainPage/components/SecretListView/SecretNoAccessListView.tsx new file mode 100644 index 000000000..371b94bbe --- /dev/null +++ b/frontend/src/views/SecretMainPage/components/SecretListView/SecretNoAccessListView.tsx @@ -0,0 +1,44 @@ +import { FontAwesomeSymbol, Input } from "@app/components/v2"; + +import { FontAwesomeSpriteName } from "./SecretListView.utils"; + +type Props = { + count: number; +}; + +export const SecretNoAccessListView = ({ count }: Props) => { + return ( + <> + {Array.from(Array(count)).map((_, i) => ( +
+
+ +
+
+ +
+
+ ******** +
+
+ ))} + + ); +}; diff --git a/frontend/src/views/SecretMainPage/components/SecretListView/index.tsx b/frontend/src/views/SecretMainPage/components/SecretListView/index.tsx index bf5cbf066..e9e1f1fdd 100644 --- a/frontend/src/views/SecretMainPage/components/SecretListView/index.tsx +++ b/frontend/src/views/SecretMainPage/components/SecretListView/index.tsx @@ -1 +1,2 @@ export { SecretListView } from "./SecretListView"; +export { SecretNoAccessListView } from "./SecretNoAccessListView"; diff --git a/frontend/src/views/SecretOverviewPage/components/SecretOverviewTableRow/SecretNoAccessOverviewTableRow.tsx b/frontend/src/views/SecretOverviewPage/components/SecretOverviewTableRow/SecretNoAccessOverviewTableRow.tsx new file mode 100644 index 000000000..ef4ee2ce7 --- /dev/null +++ b/frontend/src/views/SecretOverviewPage/components/SecretOverviewTableRow/SecretNoAccessOverviewTableRow.tsx @@ -0,0 +1,45 @@ +import { faCircle } from "@fortawesome/free-regular-svg-icons"; +import { faLock } from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; + +import { Td, Tr } from "@app/components/v2"; + +type Props = { + environments: { name: string; slug: string }[]; + count: number; +}; + +export const SecretNoAccessOverviewTableRow = ({ environments = [], count }: Props) => { + return ( + <> + {Array.from(Array(count)).map((_, j) => ( + + +
+
+
+ +
+
NO ACCESS
+
+
+ + {environments.map(({ slug }, i) => { + return ( + +
+
+ +
+
+ + ); + })} + + ))} + + ); +}; diff --git a/frontend/src/views/SecretOverviewPage/components/SecretOverviewTableRow/index.tsx b/frontend/src/views/SecretOverviewPage/components/SecretOverviewTableRow/index.tsx index a87fa1c02..5b7f3847f 100644 --- a/frontend/src/views/SecretOverviewPage/components/SecretOverviewTableRow/index.tsx +++ b/frontend/src/views/SecretOverviewPage/components/SecretOverviewTableRow/index.tsx @@ -1 +1,2 @@ +export { SecretNoAccessOverviewTableRow } from "./SecretNoAccessOverviewTableRow"; export { SecretOverviewTableRow } from "./SecretOverviewTableRow";