From 0f892d4670225aec7e868ffaa5633e4bb0692e25 Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia Date: Wed, 13 Dec 2023 20:15:50 +0530 Subject: [PATCH 1/2] chore: analytics permission validation added --- web/components/headers/cycle-issues.tsx | 29 +++++++++++++---------- web/components/headers/module-issues.tsx | 29 +++++++++++++---------- web/components/headers/project-issues.tsx | 29 +++++++++++++---------- web/components/workspace/sidebar-menu.tsx | 11 +++++++-- 4 files changed, 57 insertions(+), 41 deletions(-) diff --git a/web/components/headers/cycle-issues.tsx b/web/components/headers/cycle-issues.tsx index e5b1167b2..241259648 100644 --- a/web/components/headers/cycle-issues.tsx +++ b/web/components/headers/cycle-issues.tsx @@ -192,20 +192,23 @@ export const CycleIssuesHeader: React.FC = observer(() => { handleDisplayPropertiesUpdate={handleDisplayProperties} /> - + {canUserCreateIssue && ( - + <> + + + )} + {canUserCreateIssue && ( - + <> + + + )} + {canUserCreateIssue && ( - + <> + + + )} diff --git a/web/components/workspace/sidebar-menu.tsx b/web/components/workspace/sidebar-menu.tsx index 792e7e6a0..573b10541 100644 --- a/web/components/workspace/sidebar-menu.tsx +++ b/web/components/workspace/sidebar-menu.tsx @@ -9,6 +9,8 @@ import { BarChart2, Briefcase, CheckCircle, LayoutGrid } from "lucide-react"; // mobx store import { useMobxStore } from "lib/mobx/store-provider"; import { observer } from "mobx-react-lite"; +// constants +import { EUserWorkspaceRoles } from "constants/workspace"; const workspaceLinks = (workspaceSlug: string) => [ { @@ -34,16 +36,21 @@ const workspaceLinks = (workspaceSlug: string) => [ ]; export const WorkspaceSidebarMenu = observer(() => { - const { theme: themeStore } = useMobxStore(); + const { + theme: themeStore, + user: { currentWorkspaceRole }, + } = useMobxStore(); // router const router = useRouter(); const { workspaceSlug } = router.query; + const isAuthorizedUser = !!currentWorkspaceRole && currentWorkspaceRole >= EUserWorkspaceRoles.MEMBER; + return (
{workspaceLinks(workspaceSlug as string).map((link, index) => { const isActive = link.name === "Settings" ? router.asPath.includes(link.href) : router.asPath === link.href; - + if (!isAuthorizedUser && link.name === "Analytics") return; return ( From 13d7832d352852f4b2fc01f55df26b6f39b7e760 Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia Date: Wed, 13 Dec 2023 20:32:39 +0530 Subject: [PATCH 2/2] chore: app sidebar quick action permission validation added --- .../workspace/sidebar-quick-action.tsx | 106 ++++++++++-------- 1 file changed, 59 insertions(+), 47 deletions(-) diff --git a/web/components/workspace/sidebar-quick-action.tsx b/web/components/workspace/sidebar-quick-action.tsx index 6427e4692..d2245090f 100644 --- a/web/components/workspace/sidebar-quick-action.tsx +++ b/web/components/workspace/sidebar-quick-action.tsx @@ -10,6 +10,8 @@ import { CreateUpdateDraftIssueModal } from "components/issues"; import { useMobxStore } from "lib/mobx/store-provider"; import { observer } from "mobx-react-lite"; import { EProjectStore } from "store/command-palette.store"; +// constants +import { EUserWorkspaceRoles } from "constants/workspace"; export const WorkspaceSidebarQuickAction = observer(() => { // states @@ -19,12 +21,15 @@ export const WorkspaceSidebarQuickAction = observer(() => { theme: themeStore, commandPalette: commandPaletteStore, trackEvent: { setTrackElement }, + user: { currentWorkspaceRole }, } = useMobxStore(); const { storedValue, clearValue } = useLocalStorage("draftedIssue", JSON.stringify({})); const isSidebarCollapsed = themeStore.sidebarCollapsed; + const isAuthorizedUser = !!currentWorkspaceRole && currentWorkspaceRole >= EUserWorkspaceRoles.MEMBER; + return ( <> { isSidebarCollapsed ? "flex-col gap-1" : "gap-2" }`} > -
- + - {storedValue && Object.keys(JSON.parse(storedValue)).length > 0 && ( - <> -
+ {storedValue && Object.keys(JSON.parse(storedValue)).length > 0 && ( + <> +
- + -
-
- +
+
+ +
-
- - )} -
+ + )} +
+ )}