From 3dae871d23424d55abac95e16522696ad3c2a5c4 Mon Sep 17 00:00:00 2001 From: Prateek Shourya Date: Wed, 27 Dec 2023 13:31:33 +0530 Subject: [PATCH] chore: allow guest/ viewer to clear applied filters in project issues. --- .../filters/applied-filters/filters-list.tsx | 50 ++++++------------- .../filters/applied-filters/label.tsx | 19 +++---- .../filters/applied-filters/members.tsx | 19 +++---- .../filters/applied-filters/priority.tsx | 19 +++---- .../filters/applied-filters/project.tsx | 19 +++---- .../filters/applied-filters/state.tsx | 19 +++---- 6 files changed, 56 insertions(+), 89 deletions(-) diff --git a/web/components/issues/issue-layouts/filters/applied-filters/filters-list.tsx b/web/components/issues/issue-layouts/filters/applied-filters/filters-list.tsx index 7ff8056b9..5d1868a8a 100644 --- a/web/components/issues/issue-layouts/filters/applied-filters/filters-list.tsx +++ b/web/components/issues/issue-layouts/filters/applied-filters/filters-list.tsx @@ -1,5 +1,4 @@ import { observer } from "mobx-react-lite"; -import { useMobxStore } from "lib/mobx/store-provider"; // components import { AppliedDateFilters, @@ -16,8 +15,6 @@ import { X } from "lucide-react"; import { replaceUnderscoreIfSnakeCase } from "helpers/string.helper"; // types import { IIssueFilterOptions, IIssueLabel, IProject, IState, IUserLite } from "types"; -// constants -import { EUserWorkspaceRoles } from "constants/workspace"; type Props = { appliedFilters: IIssueFilterOptions; @@ -35,16 +32,10 @@ const dateFilters = ["start_date", "target_date"]; export const AppliedFiltersList: React.FC = observer((props) => { const { appliedFilters, handleClearAllFilters, handleRemoveFilter, labels, members, projects, states } = props; - const { - user: { currentProjectRole }, - } = useMobxStore(); - if (!appliedFilters) return null; if (Object.keys(appliedFilters).length === 0) return null; - const isEditingAllowed = currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER; - return (
{Object.entries(appliedFilters).map(([key, value]) => { @@ -61,7 +52,6 @@ export const AppliedFiltersList: React.FC = observer((props) => {
{membersFilters.includes(filterKey) && ( handleRemoveFilter(filterKey, val)} members={members} values={value} @@ -72,7 +62,6 @@ export const AppliedFiltersList: React.FC = observer((props) => { )} {filterKey === "labels" && ( handleRemoveFilter("labels", val)} labels={labels} values={value} @@ -80,14 +69,12 @@ export const AppliedFiltersList: React.FC = observer((props) => { )} {filterKey === "priority" && ( handleRemoveFilter("priority", val)} values={value} /> )} {filterKey === "state" && states && ( handleRemoveFilter("state", val)} states={states} values={value} @@ -101,35 +88,30 @@ export const AppliedFiltersList: React.FC = observer((props) => { )} {filterKey === "project" && ( handleRemoveFilter("project", val)} projects={projects} values={value} /> )} - {isEditingAllowed && ( - - )} +
); })} - {isEditingAllowed && ( - - )} - + + ); }); diff --git a/web/components/issues/issue-layouts/filters/applied-filters/label.tsx b/web/components/issues/issue-layouts/filters/applied-filters/label.tsx index 08e7aee44..9cec9b2f7 100644 --- a/web/components/issues/issue-layouts/filters/applied-filters/label.tsx +++ b/web/components/issues/issue-layouts/filters/applied-filters/label.tsx @@ -9,11 +9,10 @@ type Props = { handleRemove: (val: string) => void; labels: IIssueLabel[] | undefined; values: string[]; - editable: boolean | undefined; }; export const AppliedLabelsFilters: React.FC = observer((props) => { - const { handleRemove, labels, values, editable } = props; + const { handleRemove, labels, values } = props; return ( <> @@ -31,15 +30,13 @@ export const AppliedLabelsFilters: React.FC = observer((props) => { }} /> {labelDetails.name} - {editable && ( - - )} + ); })} diff --git a/web/components/issues/issue-layouts/filters/applied-filters/members.tsx b/web/components/issues/issue-layouts/filters/applied-filters/members.tsx index 1dd61d339..bfa7e9a29 100644 --- a/web/components/issues/issue-layouts/filters/applied-filters/members.tsx +++ b/web/components/issues/issue-layouts/filters/applied-filters/members.tsx @@ -9,11 +9,10 @@ type Props = { handleRemove: (val: string) => void; members: IUserLite[] | undefined; values: string[]; - editable: boolean | undefined; }; export const AppliedMembersFilters: React.FC = observer((props) => { - const { handleRemove, members, values, editable } = props; + const { handleRemove, members, values } = props; return ( <> @@ -26,15 +25,13 @@ export const AppliedMembersFilters: React.FC = observer((props) => {
{memberDetails.display_name} - {editable && ( - - )} +
); })} diff --git a/web/components/issues/issue-layouts/filters/applied-filters/priority.tsx b/web/components/issues/issue-layouts/filters/applied-filters/priority.tsx index 88b39dc00..e00d0d829 100644 --- a/web/components/issues/issue-layouts/filters/applied-filters/priority.tsx +++ b/web/components/issues/issue-layouts/filters/applied-filters/priority.tsx @@ -9,11 +9,10 @@ import { TIssuePriorities } from "types"; type Props = { handleRemove: (val: string) => void; values: string[]; - editable: boolean | undefined; }; export const AppliedPriorityFilters: React.FC = observer((props) => { - const { handleRemove, values, editable } = props; + const { handleRemove, values } = props; return ( <> @@ -21,15 +20,13 @@ export const AppliedPriorityFilters: React.FC = observer((props) => {
{priority} - {editable && ( - - )} +
))} diff --git a/web/components/issues/issue-layouts/filters/applied-filters/project.tsx b/web/components/issues/issue-layouts/filters/applied-filters/project.tsx index b1e17cfe3..018309861 100644 --- a/web/components/issues/issue-layouts/filters/applied-filters/project.tsx +++ b/web/components/issues/issue-layouts/filters/applied-filters/project.tsx @@ -10,11 +10,10 @@ type Props = { handleRemove: (val: string) => void; projects: IProject[] | undefined; values: string[]; - editable: boolean | undefined; }; export const AppliedProjectFilters: React.FC = observer((props) => { - const { handleRemove, projects, values, editable } = props; + const { handleRemove, projects, values } = props; return ( <> @@ -35,15 +34,13 @@ export const AppliedProjectFilters: React.FC = observer((props) => { )} {projectDetails.name} - {editable && ( - - )} + ); })} diff --git a/web/components/issues/issue-layouts/filters/applied-filters/state.tsx b/web/components/issues/issue-layouts/filters/applied-filters/state.tsx index 9cff84d9b..8e7592505 100644 --- a/web/components/issues/issue-layouts/filters/applied-filters/state.tsx +++ b/web/components/issues/issue-layouts/filters/applied-filters/state.tsx @@ -10,11 +10,10 @@ type Props = { handleRemove: (val: string) => void; states: IState[]; values: string[]; - editable: boolean | undefined; }; export const AppliedStateFilters: React.FC = observer((props) => { - const { handleRemove, states, values, editable } = props; + const { handleRemove, states, values } = props; return ( <> @@ -27,15 +26,13 @@ export const AppliedStateFilters: React.FC = observer((props) => {
{stateDetails.name} - {editable && ( - - )} +
); })}