chore: add new or existing issues validation for guest & viewers in cycles and modules empty state. (#3126)

This commit is contained in:
Prateek Shourya 2023-12-14 16:31:57 +05:30 committed by GitHub
parent 1c546e3cc5
commit 3adf48e429
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -15,6 +15,8 @@ import emptyIssue from "public/empty-state/issue.svg";
// types // types
import { ISearchIssueResponse } from "types"; import { ISearchIssueResponse } from "types";
import { EProjectStore } from "store/command-palette.store"; import { EProjectStore } from "store/command-palette.store";
// constants
import { EUserWorkspaceRoles } from "constants/workspace";
type Props = { type Props = {
workspaceSlug: string | undefined; workspaceSlug: string | undefined;
@ -31,6 +33,7 @@ export const CycleEmptyState: React.FC<Props> = observer((props) => {
cycleIssues: cycleIssueStore, cycleIssues: cycleIssueStore,
commandPalette: commandPaletteStore, commandPalette: commandPaletteStore,
trackEvent: { setTrackElement }, trackEvent: { setTrackElement },
user: { currentProjectRole: userRole },
} = useMobxStore(); } = useMobxStore();
const { setToastAlert } = useToast(); const { setToastAlert } = useToast();
@ -49,6 +52,8 @@ export const CycleEmptyState: React.FC<Props> = observer((props) => {
}); });
}; };
const isEditingAllowed = !!userRole && userRole >= EUserWorkspaceRoles.MEMBER;
return ( return (
<> <>
<ExistingIssuesListModal <ExistingIssuesListModal
@ -75,10 +80,12 @@ export const CycleEmptyState: React.FC<Props> = observer((props) => {
variant="neutral-primary" variant="neutral-primary"
prependIcon={<PlusIcon className="h-3 w-3" strokeWidth={2} />} prependIcon={<PlusIcon className="h-3 w-3" strokeWidth={2} />}
onClick={() => setCycleIssuesListModal(true)} onClick={() => setCycleIssuesListModal(true)}
disabled={!isEditingAllowed}
> >
Add an existing issue Add an existing issue
</Button> </Button>
} }
disabled={!isEditingAllowed}
/> />
</div> </div>
</> </>

View File

@ -10,6 +10,8 @@ import { useMobxStore } from "lib/mobx/store-provider";
import { ISearchIssueResponse } from "types"; import { ISearchIssueResponse } from "types";
import useToast from "hooks/use-toast"; import useToast from "hooks/use-toast";
import { useState } from "react"; import { useState } from "react";
// constants
import { EUserWorkspaceRoles } from "constants/workspace";
type Props = { type Props = {
workspaceSlug: string | undefined; workspaceSlug: string | undefined;
@ -26,6 +28,7 @@ export const ModuleEmptyState: React.FC<Props> = observer((props) => {
moduleIssues: moduleIssueStore, moduleIssues: moduleIssueStore,
commandPalette: commandPaletteStore, commandPalette: commandPaletteStore,
trackEvent: { setTrackElement }, trackEvent: { setTrackElement },
user: { currentProjectRole: userRole },
} = useMobxStore(); } = useMobxStore();
const { setToastAlert } = useToast(); const { setToastAlert } = useToast();
@ -44,6 +47,8 @@ export const ModuleEmptyState: React.FC<Props> = observer((props) => {
); );
}; };
const isEditingAllowed = !!userRole && userRole >= EUserWorkspaceRoles.MEMBER;
return ( return (
<> <>
<ExistingIssuesListModal <ExistingIssuesListModal
@ -70,10 +75,12 @@ export const ModuleEmptyState: React.FC<Props> = observer((props) => {
variant="neutral-primary" variant="neutral-primary"
prependIcon={<PlusIcon className="h-3 w-3" strokeWidth={2} />} prependIcon={<PlusIcon className="h-3 w-3" strokeWidth={2} />}
onClick={() => setModuleIssuesListModal(true)} onClick={() => setModuleIssuesListModal(true)}
disabled={!isEditingAllowed}
> >
Add an existing issue Add an existing issue
</Button> </Button>
} }
disabled={!isEditingAllowed}
/> />
</div> </div>
</> </>