From b1d049c677027f170bf0b5311200c52d63d1c123 Mon Sep 17 00:00:00 2001 From: Vladyslav Matsiiako Date: Sat, 17 Feb 2024 21:49:17 -0800 Subject: [PATCH] added ability to hide environments in the overview screen --- .../SecretListView/SecretDetaiSidebar.tsx | 2 +- .../components/SecretListView/SecretItem.tsx | 2 +- .../SecretOverviewPage/SecretOverviewPage.tsx | 82 ++++++++++++++++--- 3 files changed, 74 insertions(+), 12 deletions(-) diff --git a/frontend/src/views/SecretMainPage/components/SecretListView/SecretDetaiSidebar.tsx b/frontend/src/views/SecretMainPage/components/SecretListView/SecretDetaiSidebar.tsx index cf50e44f3..092495597 100644 --- a/frontend/src/views/SecretMainPage/components/SecretListView/SecretDetaiSidebar.tsx +++ b/frontend/src/views/SecretMainPage/components/SecretListView/SecretDetaiSidebar.tsx @@ -291,7 +291,7 @@ export const SecretDetailSidebar = ({ )} - Apply tags to this secrets + Add tags to this secret {tags.map((tag) => { const { id: tagId, name, color } = tag; diff --git a/frontend/src/views/SecretMainPage/components/SecretListView/SecretItem.tsx b/frontend/src/views/SecretMainPage/components/SecretListView/SecretItem.tsx index a72463c9a..5434de70d 100644 --- a/frontend/src/views/SecretMainPage/components/SecretListView/SecretItem.tsx +++ b/frontend/src/views/SecretMainPage/components/SecretListView/SecretItem.tsx @@ -321,7 +321,7 @@ export const SecretItem = memo( )} - Apply tags to this secrets + Add tags to this secret {tags.map((tag) => { const { id: tagId, name, color } = tag; diff --git a/frontend/src/views/SecretOverviewPage/SecretOverviewPage.tsx b/frontend/src/views/SecretOverviewPage/SecretOverviewPage.tsx index 394914a00..c95e09acb 100644 --- a/frontend/src/views/SecretOverviewPage/SecretOverviewPage.tsx +++ b/frontend/src/views/SecretOverviewPage/SecretOverviewPage.tsx @@ -2,10 +2,12 @@ import { useEffect, useRef, useState } from "react"; import { useTranslation } from "react-i18next"; import Link from "next/link"; import { useRouter } from "next/router"; +import { faCheckCircle } from "@fortawesome/free-regular-svg-icons"; import { faArrowDown, faArrowUp, faFolderBlank, + faList, faMagnifyingGlass } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; @@ -15,6 +17,11 @@ import NavHeader from "@app/components/navigation/NavHeader"; import { PermissionDeniedBanner } from "@app/components/permissions"; import { Button, + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuLabel, + DropdownMenuTrigger, EmptyState, IconButton, Input, @@ -86,6 +93,7 @@ export const SecretOverviewPage = () => { }, [isWorkspaceLoading, workspaceId, router.isReady]); const userAvailableEnvs = currentWorkspace?.environments || []; + const [visibleEnvs, setVisisbleEnvs] = useState(userAvailableEnvs); const { data: secrets, @@ -149,6 +157,14 @@ export const SecretOverviewPage = () => { } }; + const handleEnvSelect = (envId: string) => { + if (visibleEnvs.map(env => env.id).includes(envId)) { + setVisisbleEnvs(visibleEnvs.filter(env => env.id !== envId)) + } else { + setVisisbleEnvs(visibleEnvs.concat(userAvailableEnvs.filter(env => env.id === envId))) + } + }; + const handleSecretUpdate = async (env: string, key: string, value: string, secretId?: string) => { try { await updateSecretV3({ @@ -225,7 +241,7 @@ export const SecretOverviewPage = () => { } } const query: Record = { ...router.query, env: slug }; - const envIndex = userAvailableEnvs.findIndex((el) => slug === el.slug); + const envIndex = visibleEnvs.findIndex((el) => slug === el.slug); if (envIndex !== -1) { router.push({ pathname: "/project/[id]/secrets/[env]", @@ -317,7 +333,53 @@ export const SecretOverviewPage = () => {
-
+
+ + + + + + + + + + Choose visible environments + {userAvailableEnvs.map((avaiableEnv) => { + const { id: envId, name } = avaiableEnv; + + const isEnvSelected = visibleEnvs.map(env => env.id).includes(envId); + return ( + handleEnvSelect(envId)} + key={envId} + icon={isEnvSelected && } + iconPos="left" + > +
+ {name} +
+
+ ); + })} + {/* + + */} +
+
{
- {userAvailableEnvs?.map(({ name, slug }, index) => { + {visibleEnvs?.map(({ name, slug }, index) => { const envSecKeyCount = getEnvSecretKeyCount(slug); const missingKeyCount = secKeys.length - envSecKeyCount; return ( @@ -388,12 +450,12 @@ export const SecretOverviewPage = () => { )} {isTableEmpty && !isTableLoading && ( - + @@ -414,13 +476,13 @@ export const SecretOverviewPage = () => { ))} {!isTableLoading && - (userAvailableEnvs?.length > 0 ? ( + (visibleEnvs?.length > 0 ? ( filteredSecretNames.map((key, index) => ( { onSecretDelete={handleSecretDelete} onSecretUpdate={handleSecretUpdate} key={`overview-${key}-${index + 1}`} - environments={userAvailableEnvs} + environments={visibleEnvs} secretKey={key} getSecretByKey={getSecretByKey} expandableColWidth={expandableTableWidth} @@ -446,7 +508,7 @@ export const SecretOverviewPage = () => { style={{ height: "45px" }} /> - {userAvailableEnvs.map(({ name, slug }) => ( + {visibleEnvs.map(({ name, slug }) => (