From 8a1a6c6f62f30607046c85e5bace9e889cd4b55a Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Sun, 17 Dec 2023 00:35:53 +0530 Subject: [PATCH] chore: disable API calls for un-authorized users (#3144) * fix: disable api calls if user doesn't have access * chore: remove permissions from component level * chore: rmeove console log and organize import statements --- .../core/modals/bulk-delete-issues-modal.tsx | 30 +++++---- .../roots/archived-issue-layout-root.tsx | 6 +- .../issue-layouts/roots/cycle-layout-root.tsx | 21 +++--- .../roots/draft-issue-layout-root.tsx | 6 +- .../roots/module-layout-root.tsx | 21 +++--- .../roots/project-layout-root.tsx | 6 +- .../roots/project-view-layout-root.tsx | 10 +-- web/layouts/auth-layout/project-wrapper.tsx | 65 +++++++++++++------ web/layouts/auth-layout/user-wrapper.tsx | 3 +- web/layouts/auth-layout/workspace-wrapper.tsx | 18 ++--- web/store/archived-issues/issue.store.ts | 2 + web/store/cycle/cycle_issue.store.ts | 6 +- web/store/issue/issue.store.ts | 6 +- .../project-issues/archived/issue.store.ts | 3 +- .../project-issues/cycle/issue.store.ts | 3 +- .../project-issues/draft/issue.store.ts | 3 +- .../project-issues/module/issue.store.ts | 3 +- .../project-view/issue.store.ts | 3 +- .../project-issues/project/issue.store.ts | 3 +- web/store/module/module_issue.store.ts | 6 +- .../profile-issues/issue_filters.store.ts | 1 - 21 files changed, 139 insertions(+), 86 deletions(-) diff --git a/web/components/core/modals/bulk-delete-issues-modal.tsx b/web/components/core/modals/bulk-delete-issues-modal.tsx index 42ff147fa..d745e1111 100644 --- a/web/components/core/modals/bulk-delete-issues-modal.tsx +++ b/web/components/core/modals/bulk-delete-issues-modal.tsx @@ -1,14 +1,14 @@ import React, { useState } from "react"; import { useRouter } from "next/router"; -import useSWR from "swr"; -// react hook form +import { observer } from "mobx-react-lite"; import { SubmitHandler, useForm } from "react-hook-form"; -// headless ui import { Combobox, Dialog, Transition } from "@headlessui/react"; +import useSWR from "swr"; +// hooks +import { useMobxStore } from "lib/mobx/store-provider"; +import useToast from "hooks/use-toast"; // services import { IssueService } from "services/issue"; -// hooks -import useToast from "hooks/use-toast"; // ui import { Button, LayersIcon } from "@plane/ui"; // icons @@ -30,17 +30,25 @@ type Props = { const issueService = new IssueService(); -export const BulkDeleteIssuesModal: React.FC = (props) => { +export const BulkDeleteIssuesModal: React.FC = observer((props) => { const { isOpen, onClose } = props; + // states + const [query, setQuery] = useState(""); // router const router = useRouter(); const { workspaceSlug, projectId } = router.query; - // states - const [query, setQuery] = useState(""); + // store hooks + const { + user: { hasPermissionToCurrentProject }, + } = useMobxStore(); // fetching project issues. const { data: issues } = useSWR( - workspaceSlug && projectId ? PROJECT_ISSUES_LIST(workspaceSlug as string, projectId as string) : null, - workspaceSlug && projectId ? () => issueService.getIssues(workspaceSlug as string, projectId as string) : null + workspaceSlug && projectId && hasPermissionToCurrentProject + ? PROJECT_ISSUES_LIST(workspaceSlug.toString(), projectId.toString()) + : null, + workspaceSlug && projectId && hasPermissionToCurrentProject + ? () => issueService.getIssues(workspaceSlug.toString(), projectId.toString()) + : null ); const { setToastAlert } = useToast(); @@ -222,4 +230,4 @@ export const BulkDeleteIssuesModal: React.FC = (props) => { ); -}; +}); diff --git a/web/components/issues/issue-layouts/roots/archived-issue-layout-root.tsx b/web/components/issues/issue-layouts/roots/archived-issue-layout-root.tsx index fd5002b17..53171f4e5 100644 --- a/web/components/issues/issue-layouts/roots/archived-issue-layout-root.tsx +++ b/web/components/issues/issue-layouts/roots/archived-issue-layout-root.tsx @@ -9,7 +9,7 @@ import { ArchivedIssueListLayout, ArchivedIssueAppliedFiltersRoot } from "compon export const ArchivedIssueLayoutRoot: React.FC = observer(() => { const router = useRouter(); - const { workspaceSlug, projectId } = router.query as { workspaceSlug: string; projectId: string }; + const { workspaceSlug, projectId } = router.query; const { projectArchivedIssues: { getIssues, fetchIssues }, @@ -18,8 +18,8 @@ export const ArchivedIssueLayoutRoot: React.FC = observer(() => { useSWR(workspaceSlug && projectId ? `ARCHIVED_FILTERS_AND_ISSUES_${projectId.toString()}` : null, async () => { if (workspaceSlug && projectId) { - await fetchFilters(workspaceSlug, projectId); - await fetchIssues(workspaceSlug, projectId, getIssues ? "mutation" : "init-loader"); + await fetchFilters(workspaceSlug.toString(), projectId.toString()); + await fetchIssues(workspaceSlug.toString(), projectId.toString(), getIssues ? "mutation" : "init-loader"); } }); diff --git a/web/components/issues/issue-layouts/roots/cycle-layout-root.tsx b/web/components/issues/issue-layouts/roots/cycle-layout-root.tsx index 0d40a7f06..f967956f0 100644 --- a/web/components/issues/issue-layouts/roots/cycle-layout-root.tsx +++ b/web/components/issues/issue-layouts/roots/cycle-layout-root.tsx @@ -24,11 +24,7 @@ export const CycleLayoutRoot: React.FC = observer(() => { const [transferIssuesModal, setTransferIssuesModal] = useState(false); const router = useRouter(); - const { workspaceSlug, projectId, cycleId } = router.query as { - workspaceSlug: string; - projectId: string; - cycleId: string; - }; + const { workspaceSlug, projectId, cycleId } = router.query; const { cycle: cycleStore, @@ -40,8 +36,13 @@ export const CycleLayoutRoot: React.FC = observer(() => { workspaceSlug && projectId && cycleId ? `CYCLE_ISSUES_V3_${workspaceSlug}_${projectId}_${cycleId}` : null, async () => { if (workspaceSlug && projectId && cycleId) { - await fetchFilters(workspaceSlug, projectId, cycleId); - await fetchIssues(workspaceSlug, projectId, getIssues ? "mutation" : "init-loader", cycleId); + await fetchFilters(workspaceSlug.toString(), projectId.toString(), cycleId.toString()); + await fetchIssues( + workspaceSlug.toString(), + projectId.toString(), + getIssues ? "mutation" : "init-loader", + cycleId.toString() + ); } } ); @@ -69,7 +70,11 @@ export const CycleLayoutRoot: React.FC = observer(() => { ) : ( <> {Object.keys(getIssues ?? {}).length == 0 ? ( - + ) : (
{activeLayout === "list" ? ( diff --git a/web/components/issues/issue-layouts/roots/draft-issue-layout-root.tsx b/web/components/issues/issue-layouts/roots/draft-issue-layout-root.tsx index cf7939015..d09d47714 100644 --- a/web/components/issues/issue-layouts/roots/draft-issue-layout-root.tsx +++ b/web/components/issues/issue-layouts/roots/draft-issue-layout-root.tsx @@ -11,7 +11,7 @@ import { DraftKanBanLayout } from "../kanban/roots/draft-issue-root"; export const DraftIssueLayoutRoot: React.FC = observer(() => { const router = useRouter(); - const { workspaceSlug, projectId } = router.query as { workspaceSlug: string; projectId: string }; + const { workspaceSlug, projectId } = router.query; const { projectDraftIssuesFilter: { issueFilters, fetchFilters }, @@ -20,8 +20,8 @@ export const DraftIssueLayoutRoot: React.FC = observer(() => { useSWR(workspaceSlug && projectId ? `DRAFT_FILTERS_AND_ISSUES_${projectId.toString()}` : null, async () => { if (workspaceSlug && projectId) { - await fetchFilters(workspaceSlug, projectId); - await fetchIssues(workspaceSlug, projectId, getIssues ? "mutation" : "init-loader"); + await fetchFilters(workspaceSlug.toString(), projectId.toString()); + await fetchIssues(workspaceSlug.toString(), projectId.toString(), getIssues ? "mutation" : "init-loader"); } }); diff --git a/web/components/issues/issue-layouts/roots/module-layout-root.tsx b/web/components/issues/issue-layouts/roots/module-layout-root.tsx index bbf1ec2da..21f52564e 100644 --- a/web/components/issues/issue-layouts/roots/module-layout-root.tsx +++ b/web/components/issues/issue-layouts/roots/module-layout-root.tsx @@ -20,11 +20,7 @@ import { Spinner } from "@plane/ui"; export const ModuleLayoutRoot: React.FC = observer(() => { const router = useRouter(); - const { workspaceSlug, projectId, moduleId } = router.query as { - workspaceSlug: string; - projectId: string; - moduleId: string; - }; + const { workspaceSlug, projectId, moduleId } = router.query; const { moduleIssues: { loader, getIssues, fetchIssues }, @@ -35,8 +31,13 @@ export const ModuleLayoutRoot: React.FC = observer(() => { workspaceSlug && projectId && moduleId ? `MODULE_ISSUES_V3_${workspaceSlug}_${projectId}_${moduleId}` : null, async () => { if (workspaceSlug && projectId && moduleId) { - await fetchFilters(workspaceSlug, projectId, moduleId); - await fetchIssues(workspaceSlug, projectId, getIssues ? "mutation" : "init-loader", moduleId); + await fetchFilters(workspaceSlug.toString(), projectId.toString(), moduleId.toString()); + await fetchIssues( + workspaceSlug.toString(), + projectId.toString(), + getIssues ? "mutation" : "init-loader", + moduleId.toString() + ); } } ); @@ -54,7 +55,11 @@ export const ModuleLayoutRoot: React.FC = observer(() => { ) : ( <> {Object.keys(getIssues ?? {}).length == 0 ? ( - + ) : (
{activeLayout === "list" ? ( diff --git a/web/components/issues/issue-layouts/roots/project-layout-root.tsx b/web/components/issues/issue-layouts/roots/project-layout-root.tsx index 9722c4760..db30e4b7c 100644 --- a/web/components/issues/issue-layouts/roots/project-layout-root.tsx +++ b/web/components/issues/issue-layouts/roots/project-layout-root.tsx @@ -19,7 +19,7 @@ import { Spinner } from "@plane/ui"; export const ProjectLayoutRoot: React.FC = observer(() => { // router const router = useRouter(); - const { workspaceSlug, projectId } = router.query as { workspaceSlug: string; projectId: string }; + const { workspaceSlug, projectId } = router.query; const { projectIssues: { loader, getIssues, fetchIssues }, @@ -28,8 +28,8 @@ export const ProjectLayoutRoot: React.FC = observer(() => { useSWR(workspaceSlug && projectId ? `PROJECT_ISSUES_V3_${workspaceSlug}_${projectId}` : null, async () => { if (workspaceSlug && projectId) { - await fetchFilters(workspaceSlug, projectId); - await fetchIssues(workspaceSlug, projectId, getIssues ? "mutation" : "init-loader"); + await fetchFilters(workspaceSlug.toString(), projectId.toString()); + await fetchIssues(workspaceSlug.toString(), projectId.toString(), getIssues ? "mutation" : "init-loader"); } }); diff --git a/web/components/issues/issue-layouts/roots/project-view-layout-root.tsx b/web/components/issues/issue-layouts/roots/project-view-layout-root.tsx index da66a493f..b6623f72c 100644 --- a/web/components/issues/issue-layouts/roots/project-view-layout-root.tsx +++ b/web/components/issues/issue-layouts/roots/project-view-layout-root.tsx @@ -18,11 +18,7 @@ import { Spinner } from "@plane/ui"; export const ProjectViewLayoutRoot: React.FC = observer(() => { const router = useRouter(); - const { workspaceSlug, projectId, viewId } = router.query as { - workspaceSlug: string; - projectId: string; - viewId?: string; - }; + const { workspaceSlug, projectId, viewId } = router.query; const { viewIssues: { loader, getIssues, fetchIssues }, @@ -31,8 +27,8 @@ export const ProjectViewLayoutRoot: React.FC = observer(() => { useSWR(workspaceSlug && projectId && viewId ? `PROJECT_ISSUES_V3_${workspaceSlug}_${projectId}` : null, async () => { if (workspaceSlug && projectId && viewId) { - await fetchFilters(workspaceSlug, projectId, viewId); - await fetchIssues(workspaceSlug, projectId, getIssues ? "mutation" : "init-loader"); + await fetchFilters(workspaceSlug.toString(), projectId.toString(), viewId.toString()); + await fetchIssues(workspaceSlug.toString(), projectId.toString(), getIssues ? "mutation" : "init-loader"); } }); diff --git a/web/layouts/auth-layout/project-wrapper.tsx b/web/layouts/auth-layout/project-wrapper.tsx index 5f162b302..c3352e06d 100644 --- a/web/layouts/auth-layout/project-wrapper.tsx +++ b/web/layouts/auth-layout/project-wrapper.tsx @@ -19,7 +19,7 @@ export const ProjectAuthWrapper: FC = observer((props) => { const { children } = props; // store const { - user: { fetchUserProjectInfo, projectMemberInfo, hasPermissionToProject }, + user: { fetchUserProjectInfo, projectMemberInfo, hasPermissionToCurrentProject }, project: { fetchProjectDetails, workspaceProjects }, projectLabel: { fetchProjectLabels }, projectMember: { fetchProjectMembers }, @@ -47,44 +47,67 @@ export const ProjectAuthWrapper: FC = observer((props) => { ); // fetching project labels useSWR( - workspaceSlug && projectId ? `PROJECT_LABELS_${workspaceSlug}_${projectId}` : null, - workspaceSlug && projectId ? () => fetchProjectLabels(workspaceSlug.toString(), projectId.toString()) : null + workspaceSlug && projectId && hasPermissionToCurrentProject ? `PROJECT_LABELS_${workspaceSlug}_${projectId}` : null, + workspaceSlug && projectId && hasPermissionToCurrentProject + ? () => fetchProjectLabels(workspaceSlug.toString(), projectId.toString()) + : null ); // fetching project members useSWR( - workspaceSlug && projectId ? `PROJECT_MEMBERS_${workspaceSlug}_${projectId}` : null, - workspaceSlug && projectId ? () => fetchProjectMembers(workspaceSlug.toString(), projectId.toString()) : null + workspaceSlug && projectId && hasPermissionToCurrentProject + ? `PROJECT_MEMBERS_${workspaceSlug}_${projectId}` + : null, + workspaceSlug && projectId && hasPermissionToCurrentProject + ? () => fetchProjectMembers(workspaceSlug.toString(), projectId.toString()) + : null ); // fetching project states useSWR( - workspaceSlug && projectId ? `PROJECT_STATES_${workspaceSlug}_${projectId}` : null, - workspaceSlug && projectId ? () => fetchProjectStates(workspaceSlug.toString(), projectId.toString()) : null + workspaceSlug && projectId && hasPermissionToCurrentProject ? `PROJECT_STATES_${workspaceSlug}_${projectId}` : null, + workspaceSlug && projectId && hasPermissionToCurrentProject + ? () => fetchProjectStates(workspaceSlug.toString(), projectId.toString()) + : null ); // fetching project estimates useSWR( - workspaceSlug && projectId ? `PROJECT_ESTIMATES_${workspaceSlug}_${projectId}` : null, - workspaceSlug && projectId ? () => fetchProjectEstimates(workspaceSlug.toString(), projectId.toString()) : null + workspaceSlug && projectId && hasPermissionToCurrentProject + ? `PROJECT_ESTIMATES_${workspaceSlug}_${projectId}` + : null, + workspaceSlug && projectId && hasPermissionToCurrentProject + ? () => fetchProjectEstimates(workspaceSlug.toString(), projectId.toString()) + : null ); // fetching project cycles useSWR( - workspaceSlug && projectId ? `PROJECT_ALL_CYCLES_${workspaceSlug}_${projectId}` : null, - workspaceSlug && projectId ? () => fetchCycles(workspaceSlug.toString(), projectId.toString(), "all") : null + workspaceSlug && projectId && hasPermissionToCurrentProject + ? `PROJECT_ALL_CYCLES_${workspaceSlug}_${projectId}` + : null, + workspaceSlug && projectId && hasPermissionToCurrentProject + ? () => fetchCycles(workspaceSlug.toString(), projectId.toString(), "all") + : null ); // fetching project modules useSWR( - workspaceSlug && projectId ? `PROJECT_MODULES_${workspaceSlug}_${projectId}` : null, - workspaceSlug && projectId ? () => fetchModules(workspaceSlug.toString(), projectId.toString()) : null + workspaceSlug && projectId && hasPermissionToCurrentProject + ? `PROJECT_MODULES_${workspaceSlug}_${projectId}` + : null, + workspaceSlug && projectId && hasPermissionToCurrentProject + ? () => fetchModules(workspaceSlug.toString(), projectId.toString()) + : null ); // fetching project views useSWR( - workspaceSlug && projectId ? `PROJECT_VIEWS_${workspaceSlug}_${projectId}` : null, - workspaceSlug && projectId ? () => fetchAllViews(workspaceSlug.toString(), projectId.toString()) : null + workspaceSlug && projectId && hasPermissionToCurrentProject ? `PROJECT_VIEWS_${workspaceSlug}_${projectId}` : null, + workspaceSlug && projectId && hasPermissionToCurrentProject + ? () => fetchAllViews(workspaceSlug.toString(), projectId.toString()) + : null ); - // TODO: fetching project pages // fetching project inboxes if inbox is enabled useSWR( - workspaceSlug && projectId && isInboxEnabled ? `PROJECT_INBOXES_${workspaceSlug}_${projectId}` : null, - workspaceSlug && projectId && isInboxEnabled + workspaceSlug && projectId && hasPermissionToCurrentProject && isInboxEnabled + ? `PROJECT_INBOXES_${workspaceSlug}_${projectId}` + : null, + workspaceSlug && projectId && hasPermissionToCurrentProject && isInboxEnabled ? () => fetchInboxesList(workspaceSlug.toString(), projectId.toString()) : null, { @@ -97,7 +120,7 @@ export const ProjectAuthWrapper: FC = observer((props) => { const projectExists = projectId ? projectsList?.find((project) => project.id === projectId.toString()) : null; // check if the project member apis is loading - if (!projectMemberInfo && projectId && hasPermissionToProject[projectId.toString()] === null) + if (!projectMemberInfo && projectId && hasPermissionToCurrentProject === null) return (
@@ -107,10 +130,10 @@ export const ProjectAuthWrapper: FC = observer((props) => { ); // check if the user don't have permission to access the project - if (projectExists && projectId && hasPermissionToProject[projectId.toString()] === false) return ; + if (projectExists && projectId && hasPermissionToCurrentProject === false) return ; // check if the project info is not found. - if (!projectExists && projectId && hasPermissionToProject[projectId.toString()] === false) + if (!projectExists && projectId && hasPermissionToCurrentProject === false) return (
= observer((props) => { shouldRetryOnError: false, }); // fetching current user instance admin status - useSWR("CURRENT_USER_INSTANCE_ADMIN_STATUS", () => fetchCurrentUserInstanceAdminStatus(), { + useSWRImmutable("CURRENT_USER_INSTANCE_ADMIN_STATUS", () => fetchCurrentUserInstanceAdminStatus(), { shouldRetryOnError: false, }); // fetching user settings diff --git a/web/layouts/auth-layout/workspace-wrapper.tsx b/web/layouts/auth-layout/workspace-wrapper.tsx index e61dd48f8..c9db36140 100644 --- a/web/layouts/auth-layout/workspace-wrapper.tsx +++ b/web/layouts/auth-layout/workspace-wrapper.tsx @@ -32,23 +32,25 @@ export const WorkspaceAuthWrapper: FC = observer((props) ); // fetching workspace projects useSWR( - workspaceSlug ? `WORKSPACE_PROJECTS_${workspaceSlug}` : null, - workspaceSlug ? () => fetchProjects(workspaceSlug.toString()) : null + workspaceSlug && hasPermissionToCurrentWorkspace ? `WORKSPACE_PROJECTS_${workspaceSlug}` : null, + workspaceSlug && hasPermissionToCurrentWorkspace ? () => fetchProjects(workspaceSlug.toString()) : null ); // fetch workspace members useSWR( - workspaceSlug ? `WORKSPACE_MEMBERS_${workspaceSlug}` : null, - workspaceSlug ? () => fetchWorkspaceMembers(workspaceSlug.toString()) : null + workspaceSlug && hasPermissionToCurrentWorkspace ? `WORKSPACE_MEMBERS_${workspaceSlug}` : null, + workspaceSlug && hasPermissionToCurrentWorkspace ? () => fetchWorkspaceMembers(workspaceSlug.toString()) : null ); // fetch workspace labels useSWR( - workspaceSlug ? `WORKSPACE_LABELS_${workspaceSlug}` : null, - workspaceSlug ? () => fetchWorkspaceLabels(workspaceSlug.toString()) : null + workspaceSlug && hasPermissionToCurrentWorkspace ? `WORKSPACE_LABELS_${workspaceSlug}` : null, + workspaceSlug && hasPermissionToCurrentWorkspace ? () => fetchWorkspaceLabels(workspaceSlug.toString()) : null ); // fetch workspace user projects role useSWR( - workspaceSlug ? `WORKSPACE_PROJECTS_ROLE_${workspaceSlug}` : null, - workspaceSlug ? () => fetchWorkspaceUserProjectsRole(workspaceSlug.toString()) : null + workspaceSlug && hasPermissionToCurrentWorkspace ? `WORKSPACE_PROJECTS_ROLE_${workspaceSlug}` : null, + workspaceSlug && hasPermissionToCurrentWorkspace + ? () => fetchWorkspaceUserProjectsRole(workspaceSlug.toString()) + : null ); // while data is being loaded diff --git a/web/store/archived-issues/issue.store.ts b/web/store/archived-issues/issue.store.ts index 53914cdee..94e7df7af 100644 --- a/web/store/archived-issues/issue.store.ts +++ b/web/store/archived-issues/issue.store.ts @@ -87,10 +87,12 @@ export class ArchivedIssueStore implements IArchivedIssueStore { autorun(() => { const workspaceSlug = this.rootStore.workspace.workspaceSlug; const projectId = this.rootStore.project.projectId; + const hasPermissionToCurrentProject = this.rootStore.user.hasPermissionToCurrentProject; if ( workspaceSlug && projectId && + hasPermissionToCurrentProject && this.rootStore.archivedIssueFilters.userDisplayFilters && this.rootStore.archivedIssueFilters.userFilters ) diff --git a/web/store/cycle/cycle_issue.store.ts b/web/store/cycle/cycle_issue.store.ts index 4afa35451..860ff02e2 100644 --- a/web/store/cycle/cycle_issue.store.ts +++ b/web/store/cycle/cycle_issue.store.ts @@ -89,10 +89,12 @@ export class CycleIssueStore implements ICycleIssueStore { const workspaceSlug = this.rootStore.workspace.workspaceSlug; const projectId = this.rootStore.project.projectId; const cycleId = this.rootStore.cycle.cycleId; + const hasPermissionToCurrentProject = this.rootStore.user.hasPermissionToCurrentProject; if ( workspaceSlug && projectId && + hasPermissionToCurrentProject && cycleId && this.rootStore.cycleIssueFilter.cycleFilters && this.rootStore.issueFilter.userDisplayFilters @@ -115,8 +117,8 @@ export class CycleIssueStore implements ICycleIssueStore { ? "groupWithSubGroups" : "grouped" : ungroupedLayouts.includes(issueLayout) - ? "ungrouped" - : null; + ? "ungrouped" + : null; return _issueState || null; } diff --git a/web/store/issue/issue.store.ts b/web/store/issue/issue.store.ts index 9b56e0c23..4667b3a65 100644 --- a/web/store/issue/issue.store.ts +++ b/web/store/issue/issue.store.ts @@ -82,9 +82,11 @@ export class IssueStore implements IIssueStore { autorun(() => { const workspaceSlug = this.rootStore.workspace.workspaceSlug; const projectId = this.rootStore.project.projectId; + const hasPermissionToCurrentProject = this.rootStore.user.hasPermissionToCurrentProject; if ( workspaceSlug && projectId && + hasPermissionToCurrentProject && this.rootStore.issueFilter.userFilters && this.rootStore.issueFilter.userDisplayFilters ) @@ -108,8 +110,8 @@ export class IssueStore implements IIssueStore { : "grouped" : "ungrouped" : ungroupedLayouts.includes(issueLayout) - ? "ungrouped" - : null; + ? "ungrouped" + : null; return _issueState || null; } diff --git a/web/store/issues/project-issues/archived/issue.store.ts b/web/store/issues/project-issues/archived/issue.store.ts index 69a397edd..8449d43b5 100644 --- a/web/store/issues/project-issues/archived/issue.store.ts +++ b/web/store/issues/project-issues/archived/issue.store.ts @@ -60,7 +60,8 @@ export class ProjectArchivedIssuesStore extends IssueBaseStore implements IProje autorun(() => { const workspaceSlug = this.rootStore.workspace.workspaceSlug; const projectId = this.rootStore.project.projectId; - if (!workspaceSlug || !projectId) return; + const hasPermissionToCurrentProject = this.rootStore.user.hasPermissionToCurrentProject; + if (!workspaceSlug || !projectId || !hasPermissionToCurrentProject) return; const userFilters = this.rootStore?.projectArchivedIssuesFilter?.issueFilters?.filters; if (userFilters) this.fetchIssues(workspaceSlug, projectId, "mutation"); diff --git a/web/store/issues/project-issues/cycle/issue.store.ts b/web/store/issues/project-issues/cycle/issue.store.ts index 7d5355010..767000902 100644 --- a/web/store/issues/project-issues/cycle/issue.store.ts +++ b/web/store/issues/project-issues/cycle/issue.store.ts @@ -119,7 +119,8 @@ export class CycleIssuesStore extends IssueBaseStore implements ICycleIssuesStor const workspaceSlug = this.rootStore.workspace.workspaceSlug; const projectId = this.rootStore.project.projectId; const cycleId = this.rootStore.cycle.cycleId; - if (!workspaceSlug || !projectId || !cycleId) return; + const hasPermissionToCurrentProject = this.rootStore.user.hasPermissionToCurrentProject; + if (!workspaceSlug || !projectId || !hasPermissionToCurrentProject || !cycleId) return; const userFilters = this.rootStore?.cycleIssuesFilter?.issueFilters?.filters; if (userFilters) this.fetchIssues(workspaceSlug, projectId, "mutation", cycleId); diff --git a/web/store/issues/project-issues/draft/issue.store.ts b/web/store/issues/project-issues/draft/issue.store.ts index ddcebc3f0..31610dad2 100644 --- a/web/store/issues/project-issues/draft/issue.store.ts +++ b/web/store/issues/project-issues/draft/issue.store.ts @@ -63,7 +63,8 @@ export class ProjectDraftIssuesStore extends IssueBaseStore implements IProjectD autorun(() => { const workspaceSlug = this.rootStore.workspace.workspaceSlug; const projectId = this.rootStore.project.projectId; - if (!workspaceSlug || !projectId) return; + const hasPermissionToCurrentProject = this.rootStore.user.hasPermissionToCurrentProject; + if (!workspaceSlug || !projectId || !hasPermissionToCurrentProject) return; const userFilters = this.rootStore?.projectDraftIssuesFilter?.issueFilters?.filters; if (userFilters) this.fetchIssues(workspaceSlug, projectId, "mutation"); diff --git a/web/store/issues/project-issues/module/issue.store.ts b/web/store/issues/project-issues/module/issue.store.ts index 8135eacaa..0f7fcae5b 100644 --- a/web/store/issues/project-issues/module/issue.store.ts +++ b/web/store/issues/project-issues/module/issue.store.ts @@ -111,7 +111,8 @@ export class ModuleIssuesStore extends IssueBaseStore implements IModuleIssuesSt const workspaceSlug = this.rootStore.workspace.workspaceSlug; const projectId = this.rootStore.project.projectId; const moduleId = this.rootStore.module.moduleId; - if (!workspaceSlug || !projectId || !moduleId) return; + const hasPermissionToCurrentProject = this.rootStore.user.hasPermissionToCurrentProject; + if (!workspaceSlug || !projectId || !hasPermissionToCurrentProject || !moduleId) return; const userFilters = this.rootStore?.moduleIssuesFilter?.issueFilters?.filters; if (userFilters) this.fetchIssues(workspaceSlug, projectId, "mutation", moduleId); diff --git a/web/store/issues/project-issues/project-view/issue.store.ts b/web/store/issues/project-issues/project-view/issue.store.ts index c1f201be8..c3562078a 100644 --- a/web/store/issues/project-issues/project-view/issue.store.ts +++ b/web/store/issues/project-issues/project-view/issue.store.ts @@ -65,7 +65,8 @@ export class ViewIssuesStore extends IssueBaseStore implements IViewIssuesStore autorun(() => { const workspaceSlug = this.rootStore.workspace.workspaceSlug; const projectId = this.rootStore.project.projectId; - if (!workspaceSlug || !projectId) return; + const hasPermissionToCurrentProject = this.rootStore.user.hasPermissionToCurrentProject; + if (!workspaceSlug || !projectId || !hasPermissionToCurrentProject) return; const userFilters = this.rootStore?.viewIssuesFilter?.issueFilters?.filters; if (userFilters) this.fetchIssues(workspaceSlug, projectId, "mutation"); diff --git a/web/store/issues/project-issues/project/issue.store.ts b/web/store/issues/project-issues/project/issue.store.ts index 9b1b83801..8b8075179 100644 --- a/web/store/issues/project-issues/project/issue.store.ts +++ b/web/store/issues/project-issues/project/issue.store.ts @@ -65,7 +65,8 @@ export class ProjectIssuesStore extends IssueBaseStore implements IProjectIssues autorun(() => { const workspaceSlug = this.rootStore.workspace.workspaceSlug; const projectId = this.rootStore.project.projectId; - if (!workspaceSlug || !projectId) return; + const hasPermissionToCurrentProject = this.rootStore.user.hasPermissionToCurrentProject; + if (!workspaceSlug || !projectId || !hasPermissionToCurrentProject) return; const userFilters = this.rootStore?.projectIssuesFilter?.issueFilters?.filters; if (userFilters) this.fetchIssues(workspaceSlug, projectId, "mutation"); diff --git a/web/store/module/module_issue.store.ts b/web/store/module/module_issue.store.ts index dde4670ad..43f2e2d6d 100644 --- a/web/store/module/module_issue.store.ts +++ b/web/store/module/module_issue.store.ts @@ -91,10 +91,12 @@ export class ModuleIssueStore implements IModuleIssueStore { const workspaceSlug = this.rootStore.workspace.workspaceSlug; const projectId = this.rootStore.project.projectId; const moduleId = this.rootStore.module.moduleId; + const hasPermissionToCurrentProject = this.rootStore.user.hasPermissionToCurrentProject; if ( workspaceSlug && projectId && + hasPermissionToCurrentProject && moduleId && this.rootStore.moduleFilter.moduleFilters && this.rootStore.issueFilter.userDisplayFilters @@ -117,8 +119,8 @@ export class ModuleIssueStore implements IModuleIssueStore { ? "groupWithSubGroups" : "grouped" : ungroupedLayouts.includes(issueLayout) - ? "ungrouped" - : null; + ? "ungrouped" + : null; return _issueState || null; } diff --git a/web/store/profile-issues/issue_filters.store.ts b/web/store/profile-issues/issue_filters.store.ts index 6573ec447..9f611b39f 100644 --- a/web/store/profile-issues/issue_filters.store.ts +++ b/web/store/profile-issues/issue_filters.store.ts @@ -68,7 +68,6 @@ export class ProfileIssueFilterStore implements IProfileIssueFilterStore { const workspaceSlug = this.rootStore.workspace.workspaceSlug; const userId = this.rootStore.profileIssues?.userId; if (workspaceSlug && userId && this.rootStore.profileIssues.currentProfileTab && this.appliedFilters) { - console.log("autorun triggered"); this.rootStore.profileIssues.fetchIssues( workspaceSlug, userId,