chore: analytics permission validation added

This commit is contained in:
Anmol Singh Bhatia 2023-12-13 20:15:50 +05:30
parent 936452758a
commit 0f892d4670
4 changed files with 57 additions and 41 deletions

View File

@ -192,10 +192,12 @@ export const CycleIssuesHeader: React.FC = observer(() => {
handleDisplayPropertiesUpdate={handleDisplayProperties} handleDisplayPropertiesUpdate={handleDisplayProperties}
/> />
</FiltersDropdown> </FiltersDropdown>
{canUserCreateIssue && (
<>
<Button onClick={() => setAnalyticsModal(true)} variant="neutral-primary" size="sm"> <Button onClick={() => setAnalyticsModal(true)} variant="neutral-primary" size="sm">
Analytics Analytics
</Button> </Button>
{canUserCreateIssue && (
<Button <Button
onClick={() => { onClick={() => {
setTrackElement("CYCLE_PAGE_HEADER"); setTrackElement("CYCLE_PAGE_HEADER");
@ -206,6 +208,7 @@ export const CycleIssuesHeader: React.FC = observer(() => {
> >
Add Issue Add Issue
</Button> </Button>
</>
)} )}
<button <button
type="button" type="button"

View File

@ -193,10 +193,12 @@ export const ModuleIssuesHeader: React.FC = observer(() => {
handleDisplayPropertiesUpdate={handleDisplayProperties} handleDisplayPropertiesUpdate={handleDisplayProperties}
/> />
</FiltersDropdown> </FiltersDropdown>
{canUserCreateIssue && (
<>
<Button onClick={() => setAnalyticsModal(true)} variant="neutral-primary" size="sm"> <Button onClick={() => setAnalyticsModal(true)} variant="neutral-primary" size="sm">
Analytics Analytics
</Button> </Button>
{canUserCreateIssue && (
<Button <Button
onClick={() => { onClick={() => {
setTrackElement("MODULE_PAGE_HEADER"); setTrackElement("MODULE_PAGE_HEADER");
@ -207,6 +209,7 @@ export const ModuleIssuesHeader: React.FC = observer(() => {
> >
Add Issue Add Issue
</Button> </Button>
</>
)} )}
<button <button
type="button" type="button"

View File

@ -202,10 +202,12 @@ export const ProjectIssuesHeader: React.FC = observer(() => {
</span> </span>
</Link> </Link>
)} )}
{canUserCreateIssue && (
<>
<Button onClick={() => setAnalyticsModal(true)} variant="neutral-primary" size="sm"> <Button onClick={() => setAnalyticsModal(true)} variant="neutral-primary" size="sm">
Analytics Analytics
</Button> </Button>
{canUserCreateIssue && (
<Button <Button
onClick={() => { onClick={() => {
setTrackElement("PROJECT_PAGE_HEADER"); setTrackElement("PROJECT_PAGE_HEADER");
@ -216,6 +218,7 @@ export const ProjectIssuesHeader: React.FC = observer(() => {
> >
Add Issue Add Issue
</Button> </Button>
</>
)} )}
</div> </div>
</div> </div>

View File

@ -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">