From f132fe59aed3b4ea7ada30a1f6b7e8b9816098e7 Mon Sep 17 00:00:00 2001 From: Prateek Shourya Date: Fri, 29 Dec 2023 16:35:03 +0530 Subject: [PATCH] Chore/user role validation (#3260) * chore: remove `Save View` option for guest/ viewer from project issues header. * chore: allow guest/ viewer to clear applied filters in project issues. * chore: disable `date`, `label` property access for guests/ viewer in all project issue views. * chore: update `Workspace Issues` -> `All Issues` header. * chore: refactor apply/ clear filter implementation in All Issues. * Revert "chore: refactor apply/ clear filter implementation in All Issues." This reverts commit 024822d54f4061eb2686d811a2b87cd0789b6b90. * Revert "chore: allow guest/ viewer to clear applied filters in project issues." This reverts commit 3dae871d23424d55abac95e16522696ad3c2a5c4. * Revert "chore: update `Workspace Issues` -> `All Issues` header." This reverts commit 03f90be188bc6b2f98a780ae22e0a29d9c59268d. * chore: remove `cursor-pointer` style from non actionable issue properties. --- .../applied-filters/roots/project-root.tsx | 16 ++++++++++------ .../issues/issue-layouts/kanban/properties.tsx | 6 +++--- .../issues/issue-layouts/list/properties.tsx | 6 +++--- .../issues/issue-layouts/properties/date.tsx | 3 ++- .../issues/issue-layouts/properties/labels.tsx | 8 ++++++-- web/components/issues/sidebar-select/label.tsx | 4 +++- web/components/issues/view-select/due-date.tsx | 4 ++-- web/components/issues/view-select/start-date.tsx | 4 ++-- 8 files changed, 31 insertions(+), 20 deletions(-) diff --git a/web/components/issues/issue-layouts/filters/applied-filters/roots/project-root.tsx b/web/components/issues/issue-layouts/filters/applied-filters/roots/project-root.tsx index 6d7369bb9..31317366c 100644 --- a/web/components/issues/issue-layouts/filters/applied-filters/roots/project-root.tsx +++ b/web/components/issues/issue-layouts/filters/applied-filters/roots/project-root.tsx @@ -1,29 +1,32 @@ import { useRouter } from "next/router"; import { observer } from "mobx-react-lite"; - // mobx store import { useMobxStore } from "lib/mobx/store-provider"; // components import { AppliedFiltersList, SaveFilterView } from "components/issues"; - // types import { IIssueFilterOptions } from "types"; import { EFilterType } from "store/issues/types"; +// constants +import { EUserWorkspaceRoles } from "constants/workspace"; export const ProjectAppliedFiltersRoot: React.FC = observer(() => { + // router const router = useRouter(); const { workspaceSlug, projectId } = router.query as { workspaceSlug: string; projectId: string; }; - + // mobx stores const { projectLabel: { projectLabels }, projectState: projectStateStore, projectMember: { projectMembers }, projectIssuesFilter: { issueFilters, updateFilters }, + user: { currentProjectRole }, } = useMobxStore(); - + // derived values + const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER; const userFilters = issueFilters?.filters; // filters whose value not null or empty array @@ -73,8 +76,9 @@ export const ProjectAppliedFiltersRoot: React.FC = observer(() => { members={projectMembers?.map((m) => m.member)} states={projectStateStore.states?.[projectId?.toString() ?? ""]} /> - - + {isEditingAllowed && ( + + )} ); }); diff --git a/web/components/issues/issue-layouts/kanban/properties.tsx b/web/components/issues/issue-layouts/kanban/properties.tsx index 9590c9068..5be5a12c5 100644 --- a/web/components/issues/issue-layouts/kanban/properties.tsx +++ b/web/components/issues/issue-layouts/kanban/properties.tsx @@ -166,7 +166,7 @@ export const KanBanProperties: React.FC = observer((props) => {/* sub-issues */} {displayProperties && displayProperties?.sub_issue_count && !!issue?.sub_issues_count && ( -
+
{issue.sub_issues_count}
@@ -176,7 +176,7 @@ export const KanBanProperties: React.FC = observer((props) => {/* attachments */} {displayProperties && displayProperties?.attachment_count && !!issue?.attachment_count && ( -
+
{issue.attachment_count}
@@ -186,7 +186,7 @@ export const KanBanProperties: React.FC = observer((props) => {/* link */} {displayProperties && displayProperties?.link && !!issue?.link_count && ( -
+
{issue.link_count}
diff --git a/web/components/issues/issue-layouts/list/properties.tsx b/web/components/issues/issue-layouts/list/properties.tsx index eeff3b273..07129910f 100644 --- a/web/components/issues/issue-layouts/list/properties.tsx +++ b/web/components/issues/issue-layouts/list/properties.tsx @@ -137,7 +137,7 @@ export const ListProperties: FC = observer((props) => { {/* sub-issues */} {displayProperties && displayProperties?.sub_issue_count && !!issue?.sub_issues_count && ( -
+
{issue.sub_issues_count}
@@ -147,7 +147,7 @@ export const ListProperties: FC = observer((props) => { {/* attachments */} {displayProperties && displayProperties?.attachment_count && !!issue?.attachment_count && ( -
+
{issue.attachment_count}
@@ -157,7 +157,7 @@ export const ListProperties: FC = observer((props) => { {/* link */} {displayProperties && displayProperties?.link && !!issue?.link_count && ( -
+
{issue.link_count}
diff --git a/web/components/issues/issue-layouts/properties/date.tsx b/web/components/issues/issue-layouts/properties/date.tsx index cfe3481e3..d0bb29711 100644 --- a/web/components/issues/issue-layouts/properties/date.tsx +++ b/web/components/issues/issue-layouts/properties/date.tsx @@ -61,6 +61,7 @@ export const IssuePropertyDate: React.FC = observer((props) ref={dropdownBtn} className="border-none outline-none" onClick={(e) => e.stopPropagation()} + disabled={disabled} > = observer((props)
diff --git a/web/components/issues/issue-layouts/properties/labels.tsx b/web/components/issues/issue-layouts/properties/labels.tsx index 282268d7b..d0045c3d4 100644 --- a/web/components/issues/issue-layouts/properties/labels.tsx +++ b/web/components/issues/issue-layouts/properties/labels.tsx @@ -128,7 +128,11 @@ export const IssuePropertyLabels: React.FC = observer((pro ))} ) : ( -
+
= observer((pro ) : (
diff --git a/web/components/issues/sidebar-select/label.tsx b/web/components/issues/sidebar-select/label.tsx index ca7abd8be..6340383e9 100644 --- a/web/components/issues/sidebar-select/label.tsx +++ b/web/components/issues/sidebar-select/label.tsx @@ -92,7 +92,9 @@ export const SidebarLabelSelect: React.FC = observer((props) => { return (