[WEB-2460] fix: role permission validation (#5615)
* fix: workspace menu quick action * fix: guest role upgrade flow validation * fix: create issue validation * fix: create issue validation * fix: cmd k permission validation * fix: subscription validation * fix: create label permission validation * fix: build error * chore: guest can comment in their created issues * chore: changed the queryset * chore: code refactor * chore: code refactor --------- Co-authored-by: NarayanBavisetti <narayan3119@gmail.com>
This commit is contained in:
parent
2e816656e5
commit
45da70cf6a
9 changed files with 132 additions and 76 deletions
|
|
@ -6,10 +6,11 @@ import { IIssueLabel, TIssue } from "@plane/types";
|
|||
// components
|
||||
import { TOAST_TYPE, setToast } from "@plane/ui";
|
||||
// hooks
|
||||
import { useIssueDetail, useLabel, useProjectInbox } from "@/hooks/store";
|
||||
import { useIssueDetail, useLabel, useProjectInbox, useUserPermissions } from "@/hooks/store";
|
||||
// ui
|
||||
// types
|
||||
import { LabelList, LabelCreate, IssueLabelSelectRoot } from "./";
|
||||
import { EUserPermissions, EUserPermissionsLevel } from "ee/constants/user-permissions";
|
||||
|
||||
export type TIssueLabel = {
|
||||
workspaceSlug: string;
|
||||
|
|
@ -34,7 +35,9 @@ export const IssueLabel: FC<TIssueLabel> = observer((props) => {
|
|||
issue: { getIssueById },
|
||||
} = useIssueDetail();
|
||||
const { getIssueInboxByIssueId } = useProjectInbox();
|
||||
const { allowPermissions } = useUserPermissions();
|
||||
|
||||
const canCreateLabel = allowPermissions([EUserPermissions.ADMIN], EUserPermissionsLevel.PROJECT);
|
||||
const issue = isInboxIssue ? getIssueInboxByIssueId(issueId)?.issue : getIssueById(issueId);
|
||||
|
||||
const labelOperations: TLabelOperations = useMemo(
|
||||
|
|
@ -99,7 +102,7 @@ export const IssueLabel: FC<TIssueLabel> = observer((props) => {
|
|||
/>
|
||||
)}
|
||||
|
||||
{!disabled && (
|
||||
{!disabled && canCreateLabel && (
|
||||
<LabelCreate
|
||||
workspaceSlug={workspaceSlug}
|
||||
projectId={projectId}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ import { Bell, BellOff } from "lucide-react";
|
|||
// UI
|
||||
import { Button, Loader, TOAST_TYPE, setToast } from "@plane/ui";
|
||||
// hooks
|
||||
import { useIssueDetail } from "@/hooks/store";
|
||||
import { useIssueDetail, useUserPermissions } from "@/hooks/store";
|
||||
import { EUserPermissions, EUserPermissionsLevel } from "@/plane-web/constants/user-permissions";
|
||||
|
||||
export type TIssueSubscription = {
|
||||
workspaceSlug: string;
|
||||
|
|
@ -25,8 +26,16 @@ export const IssueSubscription: FC<TIssueSubscription> = observer((props) => {
|
|||
} = useIssueDetail();
|
||||
// state
|
||||
const [loading, setLoading] = useState(false);
|
||||
// hooks
|
||||
const { allowPermissions } = useUserPermissions();
|
||||
|
||||
const isSubscribed = getSubscriptionByIssueId(issueId);
|
||||
const isEditable = allowPermissions(
|
||||
[EUserPermissions.ADMIN, EUserPermissions.MEMBER],
|
||||
EUserPermissionsLevel.PROJECT,
|
||||
workspaceSlug,
|
||||
projectId
|
||||
);
|
||||
|
||||
const handleSubscription = async () => {
|
||||
setLoading(true);
|
||||
|
|
@ -64,6 +73,7 @@ export const IssueSubscription: FC<TIssueSubscription> = observer((props) => {
|
|||
variant="outline-primary"
|
||||
className="hover:!bg-custom-primary-100/20"
|
||||
onClick={handleSubscription}
|
||||
disabled={!isEditable}
|
||||
>
|
||||
{loading ? (
|
||||
<span>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue