forked from github/plane
Merge pull request #3119 from makeplane/chore/analytics_permission_validation
chore: analytics permission validation added
This commit is contained in:
commit
f949d57fa0
@ -192,20 +192,23 @@ export const CycleIssuesHeader: React.FC = observer(() => {
|
|||||||
handleDisplayPropertiesUpdate={handleDisplayProperties}
|
handleDisplayPropertiesUpdate={handleDisplayProperties}
|
||||||
/>
|
/>
|
||||||
</FiltersDropdown>
|
</FiltersDropdown>
|
||||||
<Button onClick={() => setAnalyticsModal(true)} variant="neutral-primary" size="sm">
|
|
||||||
Analytics
|
|
||||||
</Button>
|
|
||||||
{canUserCreateIssue && (
|
{canUserCreateIssue && (
|
||||||
<Button
|
<>
|
||||||
onClick={() => {
|
<Button onClick={() => setAnalyticsModal(true)} variant="neutral-primary" size="sm">
|
||||||
setTrackElement("CYCLE_PAGE_HEADER");
|
Analytics
|
||||||
commandPaletteStore.toggleCreateIssueModal(true, EProjectStore.CYCLE);
|
</Button>
|
||||||
}}
|
<Button
|
||||||
size="sm"
|
onClick={() => {
|
||||||
prependIcon={<Plus />}
|
setTrackElement("CYCLE_PAGE_HEADER");
|
||||||
>
|
commandPaletteStore.toggleCreateIssueModal(true, EProjectStore.CYCLE);
|
||||||
Add Issue
|
}}
|
||||||
</Button>
|
size="sm"
|
||||||
|
prependIcon={<Plus />}
|
||||||
|
>
|
||||||
|
Add Issue
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
@ -193,20 +193,23 @@ export const ModuleIssuesHeader: React.FC = observer(() => {
|
|||||||
handleDisplayPropertiesUpdate={handleDisplayProperties}
|
handleDisplayPropertiesUpdate={handleDisplayProperties}
|
||||||
/>
|
/>
|
||||||
</FiltersDropdown>
|
</FiltersDropdown>
|
||||||
<Button onClick={() => setAnalyticsModal(true)} variant="neutral-primary" size="sm">
|
|
||||||
Analytics
|
|
||||||
</Button>
|
|
||||||
{canUserCreateIssue && (
|
{canUserCreateIssue && (
|
||||||
<Button
|
<>
|
||||||
onClick={() => {
|
<Button onClick={() => setAnalyticsModal(true)} variant="neutral-primary" size="sm">
|
||||||
setTrackElement("MODULE_PAGE_HEADER");
|
Analytics
|
||||||
commandPaletteStore.toggleCreateIssueModal(true, EProjectStore.MODULE);
|
</Button>
|
||||||
}}
|
<Button
|
||||||
size="sm"
|
onClick={() => {
|
||||||
prependIcon={<Plus />}
|
setTrackElement("MODULE_PAGE_HEADER");
|
||||||
>
|
commandPaletteStore.toggleCreateIssueModal(true, EProjectStore.MODULE);
|
||||||
Add Issue
|
}}
|
||||||
</Button>
|
size="sm"
|
||||||
|
prependIcon={<Plus />}
|
||||||
|
>
|
||||||
|
Add Issue
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
@ -202,20 +202,23 @@ export const ProjectIssuesHeader: React.FC = observer(() => {
|
|||||||
</span>
|
</span>
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
<Button onClick={() => setAnalyticsModal(true)} variant="neutral-primary" size="sm">
|
|
||||||
Analytics
|
|
||||||
</Button>
|
|
||||||
{canUserCreateIssue && (
|
{canUserCreateIssue && (
|
||||||
<Button
|
<>
|
||||||
onClick={() => {
|
<Button onClick={() => setAnalyticsModal(true)} variant="neutral-primary" size="sm">
|
||||||
setTrackElement("PROJECT_PAGE_HEADER");
|
Analytics
|
||||||
commandPaletteStore.toggleCreateIssueModal(true, EProjectStore.PROJECT);
|
</Button>
|
||||||
}}
|
<Button
|
||||||
size="sm"
|
onClick={() => {
|
||||||
prependIcon={<Plus />}
|
setTrackElement("PROJECT_PAGE_HEADER");
|
||||||
>
|
commandPaletteStore.toggleCreateIssueModal(true, EProjectStore.PROJECT);
|
||||||
Add Issue
|
}}
|
||||||
</Button>
|
size="sm"
|
||||||
|
prependIcon={<Plus />}
|
||||||
|
>
|
||||||
|
Add Issue
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -9,6 +9,8 @@ import { BarChart2, Briefcase, CheckCircle, LayoutGrid } from "lucide-react";
|
|||||||
// mobx store
|
// mobx store
|
||||||
import { useMobxStore } from "lib/mobx/store-provider";
|
import { useMobxStore } from "lib/mobx/store-provider";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
|
// constants
|
||||||
|
import { EUserWorkspaceRoles } from "constants/workspace";
|
||||||
|
|
||||||
const workspaceLinks = (workspaceSlug: string) => [
|
const workspaceLinks = (workspaceSlug: string) => [
|
||||||
{
|
{
|
||||||
@ -34,16 +36,21 @@ const workspaceLinks = (workspaceSlug: string) => [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export const WorkspaceSidebarMenu = observer(() => {
|
export const WorkspaceSidebarMenu = observer(() => {
|
||||||
const { theme: themeStore } = useMobxStore();
|
const {
|
||||||
|
theme: themeStore,
|
||||||
|
user: { currentWorkspaceRole },
|
||||||
|
} = useMobxStore();
|
||||||
// router
|
// router
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { workspaceSlug } = router.query;
|
const { workspaceSlug } = router.query;
|
||||||
|
|
||||||
|
const isAuthorizedUser = !!currentWorkspaceRole && currentWorkspaceRole >= EUserWorkspaceRoles.MEMBER;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full cursor-pointer space-y-1 p-4">
|
<div className="w-full cursor-pointer space-y-1 p-4">
|
||||||
{workspaceLinks(workspaceSlug as string).map((link, index) => {
|
{workspaceLinks(workspaceSlug as string).map((link, index) => {
|
||||||
const isActive = link.name === "Settings" ? router.asPath.includes(link.href) : router.asPath === link.href;
|
const isActive = link.name === "Settings" ? router.asPath.includes(link.href) : router.asPath === link.href;
|
||||||
|
if (!isAuthorizedUser && link.name === "Analytics") return;
|
||||||
return (
|
return (
|
||||||
<Link key={index} href={link.href}>
|
<Link key={index} href={link.href}>
|
||||||
<span className="block w-full">
|
<span className="block w-full">
|
||||||
|
@ -10,6 +10,8 @@ import { CreateUpdateDraftIssueModal } from "components/issues";
|
|||||||
import { useMobxStore } from "lib/mobx/store-provider";
|
import { useMobxStore } from "lib/mobx/store-provider";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { EProjectStore } from "store/command-palette.store";
|
import { EProjectStore } from "store/command-palette.store";
|
||||||
|
// constants
|
||||||
|
import { EUserWorkspaceRoles } from "constants/workspace";
|
||||||
|
|
||||||
export const WorkspaceSidebarQuickAction = observer(() => {
|
export const WorkspaceSidebarQuickAction = observer(() => {
|
||||||
// states
|
// states
|
||||||
@ -19,12 +21,15 @@ export const WorkspaceSidebarQuickAction = observer(() => {
|
|||||||
theme: themeStore,
|
theme: themeStore,
|
||||||
commandPalette: commandPaletteStore,
|
commandPalette: commandPaletteStore,
|
||||||
trackEvent: { setTrackElement },
|
trackEvent: { setTrackElement },
|
||||||
|
user: { currentWorkspaceRole },
|
||||||
} = useMobxStore();
|
} = useMobxStore();
|
||||||
|
|
||||||
const { storedValue, clearValue } = useLocalStorage<any>("draftedIssue", JSON.stringify({}));
|
const { storedValue, clearValue } = useLocalStorage<any>("draftedIssue", JSON.stringify({}));
|
||||||
|
|
||||||
const isSidebarCollapsed = themeStore.sidebarCollapsed;
|
const isSidebarCollapsed = themeStore.sidebarCollapsed;
|
||||||
|
|
||||||
|
const isAuthorizedUser = !!currentWorkspaceRole && currentWorkspaceRole >= EUserWorkspaceRoles.MEMBER;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<CreateUpdateDraftIssueModal
|
<CreateUpdateDraftIssueModal
|
||||||
@ -42,61 +47,67 @@ export const WorkspaceSidebarQuickAction = observer(() => {
|
|||||||
isSidebarCollapsed ? "flex-col gap-1" : "gap-2"
|
isSidebarCollapsed ? "flex-col gap-1" : "gap-2"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<div
|
{isAuthorizedUser && (
|
||||||
className={`group relative flex w-full cursor-pointer items-center justify-between gap-1 rounded px-2 ${
|
<div
|
||||||
isSidebarCollapsed
|
className={`group relative flex w-full cursor-pointer items-center justify-between gap-1 rounded px-2 ${
|
||||||
? "px-2 hover:bg-custom-sidebar-background-80"
|
isSidebarCollapsed
|
||||||
: "border-[0.5px] border-custom-border-200 px-3 shadow-custom-sidebar-shadow-2xs"
|
? "px-2 hover:bg-custom-sidebar-background-80"
|
||||||
}`}
|
: "border-[0.5px] border-custom-border-200 px-3 shadow-custom-sidebar-shadow-2xs"
|
||||||
>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className={`relative flex flex-shrink-0 flex-grow items-center gap-2 rounded py-1.5 outline-none ${
|
|
||||||
isSidebarCollapsed ? "justify-center" : ""
|
|
||||||
}`}
|
}`}
|
||||||
onClick={() => {
|
|
||||||
setTrackElement("APP_SIDEBAR_QUICK_ACTIONS");
|
|
||||||
commandPaletteStore.toggleCreateIssueModal(true, EProjectStore.PROJECT);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<PenSquare className="h-4 w-4 text-custom-sidebar-text-300" />
|
<button
|
||||||
{!isSidebarCollapsed && <span className="text-sm font-medium">New Issue</span>}
|
type="button"
|
||||||
</button>
|
className={`relative flex flex-shrink-0 flex-grow items-center gap-2 rounded py-1.5 outline-none ${
|
||||||
|
isSidebarCollapsed ? "justify-center" : ""
|
||||||
|
}`}
|
||||||
|
onClick={() => {
|
||||||
|
setTrackElement("APP_SIDEBAR_QUICK_ACTIONS");
|
||||||
|
commandPaletteStore.toggleCreateIssueModal(true, EProjectStore.PROJECT);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<PenSquare className="h-4 w-4 text-custom-sidebar-text-300" />
|
||||||
|
{!isSidebarCollapsed && <span className="text-sm font-medium">New Issue</span>}
|
||||||
|
</button>
|
||||||
|
|
||||||
{storedValue && Object.keys(JSON.parse(storedValue)).length > 0 && (
|
{storedValue && Object.keys(JSON.parse(storedValue)).length > 0 && (
|
||||||
<>
|
<>
|
||||||
<div className={`h-8 w-0.5 bg-custom-sidebar-background-80 ${isSidebarCollapsed ? "hidden" : "block"}`} />
|
<div
|
||||||
|
className={`h-8 w-0.5 bg-custom-sidebar-background-80 ${isSidebarCollapsed ? "hidden" : "block"}`}
|
||||||
|
/>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={`ml-1.5 flex flex-shrink-0 items-center justify-center rounded py-1.5 ${
|
className={`ml-1.5 flex flex-shrink-0 items-center justify-center rounded py-1.5 ${
|
||||||
isSidebarCollapsed ? "hidden" : "block"
|
isSidebarCollapsed ? "hidden" : "block"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<ChevronUp className="h-4 w-4 rotate-180 transform !text-custom-sidebar-text-300 transition-transform duration-300 group-hover:rotate-0" />
|
<ChevronUp className="h-4 w-4 rotate-180 transform !text-custom-sidebar-text-300 transition-transform duration-300 group-hover:rotate-0" />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
className={`pointer-events-none fixed left-4 mt-0 h-10 w-[203px] pt-2 opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 ${
|
className={`pointer-events-none fixed left-4 mt-0 h-10 w-[203px] pt-2 opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 ${
|
||||||
isSidebarCollapsed ? "top-[5.5rem]" : "top-24"
|
isSidebarCollapsed ? "top-[5.5rem]" : "top-24"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<div className="h-full w-full">
|
<div className="h-full w-full">
|
||||||
<button
|
<button
|
||||||
onClick={() => setIsDraftIssueModalOpen(true)}
|
onClick={() => setIsDraftIssueModalOpen(true)}
|
||||||
className="flex w-full flex-shrink-0 items-center rounded border-[0.5px] border-custom-border-300 bg-custom-background-100 px-3 py-[10px] text-sm text-custom-text-300 shadow"
|
className="flex w-full flex-shrink-0 items-center rounded border-[0.5px] border-custom-border-300 bg-custom-background-100 px-3 py-[10px] text-sm text-custom-text-300 shadow"
|
||||||
>
|
>
|
||||||
<PenSquare size={16} className="mr-2 !text-lg !leading-4 text-custom-sidebar-text-300" />
|
<PenSquare size={16} className="mr-2 !text-lg !leading-4 text-custom-sidebar-text-300" />
|
||||||
Last Drafted Issue
|
Last Drafted Issue
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</>
|
||||||
</>
|
)}
|
||||||
)}
|
</div>
|
||||||
</div>
|
)}
|
||||||
|
|
||||||
<button
|
<button
|
||||||
className={`flex flex-shrink-0 items-center justify-center rounded p-2 outline-none ${
|
className={`flex flex-shrink-0 items-center rounded p-2 gap-2 outline-none ${
|
||||||
|
isAuthorizedUser ? "justify-center" : "w-full"
|
||||||
|
} ${
|
||||||
isSidebarCollapsed
|
isSidebarCollapsed
|
||||||
? "hover:bg-custom-sidebar-background-80"
|
? "hover:bg-custom-sidebar-background-80"
|
||||||
: "border-[0.5px] border-custom-border-200 shadow-custom-sidebar-shadow-2xs"
|
: "border-[0.5px] border-custom-border-200 shadow-custom-sidebar-shadow-2xs"
|
||||||
@ -104,6 +115,7 @@ export const WorkspaceSidebarQuickAction = observer(() => {
|
|||||||
onClick={() => commandPaletteStore.toggleCommandPaletteModal(true)}
|
onClick={() => commandPaletteStore.toggleCommandPaletteModal(true)}
|
||||||
>
|
>
|
||||||
<Search className="h-4 w-4 text-custom-sidebar-text-300" />
|
<Search className="h-4 w-4 text-custom-sidebar-text-300" />
|
||||||
|
<span className="text-xs font-medium">Open command menu</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
Loading…
Reference in New Issue
Block a user