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
This commit is contained in:
Aaryan Khandelwal 2023-12-17 00:35:53 +05:30 committed by GitHub
parent 3d83101f69
commit 8a1a6c6f62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 139 additions and 86 deletions

View File

@ -1,14 +1,14 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import useSWR from "swr"; import { observer } from "mobx-react-lite";
// react hook form
import { SubmitHandler, useForm } from "react-hook-form"; import { SubmitHandler, useForm } from "react-hook-form";
// headless ui
import { Combobox, Dialog, Transition } from "@headlessui/react"; 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 // services
import { IssueService } from "services/issue"; import { IssueService } from "services/issue";
// hooks
import useToast from "hooks/use-toast";
// ui // ui
import { Button, LayersIcon } from "@plane/ui"; import { Button, LayersIcon } from "@plane/ui";
// icons // icons
@ -30,17 +30,25 @@ type Props = {
const issueService = new IssueService(); const issueService = new IssueService();
export const BulkDeleteIssuesModal: React.FC<Props> = (props) => { export const BulkDeleteIssuesModal: React.FC<Props> = observer((props) => {
const { isOpen, onClose } = props; const { isOpen, onClose } = props;
// states
const [query, setQuery] = useState("");
// router // router
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId } = router.query; const { workspaceSlug, projectId } = router.query;
// states // store hooks
const [query, setQuery] = useState(""); const {
user: { hasPermissionToCurrentProject },
} = useMobxStore();
// fetching project issues. // fetching project issues.
const { data: issues } = useSWR( const { data: issues } = useSWR(
workspaceSlug && projectId ? PROJECT_ISSUES_LIST(workspaceSlug as string, projectId as string) : null, workspaceSlug && projectId && hasPermissionToCurrentProject
workspaceSlug && projectId ? () => issueService.getIssues(workspaceSlug as string, projectId as string) : null ? PROJECT_ISSUES_LIST(workspaceSlug.toString(), projectId.toString())
: null,
workspaceSlug && projectId && hasPermissionToCurrentProject
? () => issueService.getIssues(workspaceSlug.toString(), projectId.toString())
: null
); );
const { setToastAlert } = useToast(); const { setToastAlert } = useToast();
@ -222,4 +230,4 @@ export const BulkDeleteIssuesModal: React.FC<Props> = (props) => {
</Dialog> </Dialog>
</Transition.Root> </Transition.Root>
); );
}; });

View File

@ -9,7 +9,7 @@ import { ArchivedIssueListLayout, ArchivedIssueAppliedFiltersRoot } from "compon
export const ArchivedIssueLayoutRoot: React.FC = observer(() => { export const ArchivedIssueLayoutRoot: React.FC = observer(() => {
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId } = router.query as { workspaceSlug: string; projectId: string }; const { workspaceSlug, projectId } = router.query;
const { const {
projectArchivedIssues: { getIssues, fetchIssues }, projectArchivedIssues: { getIssues, fetchIssues },
@ -18,8 +18,8 @@ export const ArchivedIssueLayoutRoot: React.FC = observer(() => {
useSWR(workspaceSlug && projectId ? `ARCHIVED_FILTERS_AND_ISSUES_${projectId.toString()}` : null, async () => { useSWR(workspaceSlug && projectId ? `ARCHIVED_FILTERS_AND_ISSUES_${projectId.toString()}` : null, async () => {
if (workspaceSlug && projectId) { if (workspaceSlug && projectId) {
await fetchFilters(workspaceSlug, projectId); await fetchFilters(workspaceSlug.toString(), projectId.toString());
await fetchIssues(workspaceSlug, projectId, getIssues ? "mutation" : "init-loader"); await fetchIssues(workspaceSlug.toString(), projectId.toString(), getIssues ? "mutation" : "init-loader");
} }
}); });

View File

@ -24,11 +24,7 @@ export const CycleLayoutRoot: React.FC = observer(() => {
const [transferIssuesModal, setTransferIssuesModal] = useState(false); const [transferIssuesModal, setTransferIssuesModal] = useState(false);
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId, cycleId } = router.query as { const { workspaceSlug, projectId, cycleId } = router.query;
workspaceSlug: string;
projectId: string;
cycleId: string;
};
const { const {
cycle: cycleStore, cycle: cycleStore,
@ -40,8 +36,13 @@ export const CycleLayoutRoot: React.FC = observer(() => {
workspaceSlug && projectId && cycleId ? `CYCLE_ISSUES_V3_${workspaceSlug}_${projectId}_${cycleId}` : null, workspaceSlug && projectId && cycleId ? `CYCLE_ISSUES_V3_${workspaceSlug}_${projectId}_${cycleId}` : null,
async () => { async () => {
if (workspaceSlug && projectId && cycleId) { if (workspaceSlug && projectId && cycleId) {
await fetchFilters(workspaceSlug, projectId, cycleId); await fetchFilters(workspaceSlug.toString(), projectId.toString(), cycleId.toString());
await fetchIssues(workspaceSlug, projectId, getIssues ? "mutation" : "init-loader", cycleId); 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 ? ( {Object.keys(getIssues ?? {}).length == 0 ? (
<CycleEmptyState workspaceSlug={workspaceSlug} projectId={projectId} cycleId={cycleId} /> <CycleEmptyState
workspaceSlug={workspaceSlug?.toString()}
projectId={projectId?.toString()}
cycleId={cycleId?.toString()}
/>
) : ( ) : (
<div className="h-full w-full overflow-auto"> <div className="h-full w-full overflow-auto">
{activeLayout === "list" ? ( {activeLayout === "list" ? (

View File

@ -11,7 +11,7 @@ import { DraftKanBanLayout } from "../kanban/roots/draft-issue-root";
export const DraftIssueLayoutRoot: React.FC = observer(() => { export const DraftIssueLayoutRoot: React.FC = observer(() => {
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId } = router.query as { workspaceSlug: string; projectId: string }; const { workspaceSlug, projectId } = router.query;
const { const {
projectDraftIssuesFilter: { issueFilters, fetchFilters }, projectDraftIssuesFilter: { issueFilters, fetchFilters },
@ -20,8 +20,8 @@ export const DraftIssueLayoutRoot: React.FC = observer(() => {
useSWR(workspaceSlug && projectId ? `DRAFT_FILTERS_AND_ISSUES_${projectId.toString()}` : null, async () => { useSWR(workspaceSlug && projectId ? `DRAFT_FILTERS_AND_ISSUES_${projectId.toString()}` : null, async () => {
if (workspaceSlug && projectId) { if (workspaceSlug && projectId) {
await fetchFilters(workspaceSlug, projectId); await fetchFilters(workspaceSlug.toString(), projectId.toString());
await fetchIssues(workspaceSlug, projectId, getIssues ? "mutation" : "init-loader"); await fetchIssues(workspaceSlug.toString(), projectId.toString(), getIssues ? "mutation" : "init-loader");
} }
}); });

View File

@ -20,11 +20,7 @@ import { Spinner } from "@plane/ui";
export const ModuleLayoutRoot: React.FC = observer(() => { export const ModuleLayoutRoot: React.FC = observer(() => {
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId, moduleId } = router.query as { const { workspaceSlug, projectId, moduleId } = router.query;
workspaceSlug: string;
projectId: string;
moduleId: string;
};
const { const {
moduleIssues: { loader, getIssues, fetchIssues }, moduleIssues: { loader, getIssues, fetchIssues },
@ -35,8 +31,13 @@ export const ModuleLayoutRoot: React.FC = observer(() => {
workspaceSlug && projectId && moduleId ? `MODULE_ISSUES_V3_${workspaceSlug}_${projectId}_${moduleId}` : null, workspaceSlug && projectId && moduleId ? `MODULE_ISSUES_V3_${workspaceSlug}_${projectId}_${moduleId}` : null,
async () => { async () => {
if (workspaceSlug && projectId && moduleId) { if (workspaceSlug && projectId && moduleId) {
await fetchFilters(workspaceSlug, projectId, moduleId); await fetchFilters(workspaceSlug.toString(), projectId.toString(), moduleId.toString());
await fetchIssues(workspaceSlug, projectId, getIssues ? "mutation" : "init-loader", moduleId); 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 ? ( {Object.keys(getIssues ?? {}).length == 0 ? (
<ModuleEmptyState workspaceSlug={workspaceSlug} projectId={projectId} moduleId={moduleId} /> <ModuleEmptyState
workspaceSlug={workspaceSlug?.toString()}
projectId={projectId?.toString()}
moduleId={moduleId?.toString()}
/>
) : ( ) : (
<div className="h-full w-full overflow-auto"> <div className="h-full w-full overflow-auto">
{activeLayout === "list" ? ( {activeLayout === "list" ? (

View File

@ -19,7 +19,7 @@ import { Spinner } from "@plane/ui";
export const ProjectLayoutRoot: React.FC = observer(() => { export const ProjectLayoutRoot: React.FC = observer(() => {
// router // router
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId } = router.query as { workspaceSlug: string; projectId: string }; const { workspaceSlug, projectId } = router.query;
const { const {
projectIssues: { loader, getIssues, fetchIssues }, projectIssues: { loader, getIssues, fetchIssues },
@ -28,8 +28,8 @@ export const ProjectLayoutRoot: React.FC = observer(() => {
useSWR(workspaceSlug && projectId ? `PROJECT_ISSUES_V3_${workspaceSlug}_${projectId}` : null, async () => { useSWR(workspaceSlug && projectId ? `PROJECT_ISSUES_V3_${workspaceSlug}_${projectId}` : null, async () => {
if (workspaceSlug && projectId) { if (workspaceSlug && projectId) {
await fetchFilters(workspaceSlug, projectId); await fetchFilters(workspaceSlug.toString(), projectId.toString());
await fetchIssues(workspaceSlug, projectId, getIssues ? "mutation" : "init-loader"); await fetchIssues(workspaceSlug.toString(), projectId.toString(), getIssues ? "mutation" : "init-loader");
} }
}); });

View File

@ -18,11 +18,7 @@ import { Spinner } from "@plane/ui";
export const ProjectViewLayoutRoot: React.FC = observer(() => { export const ProjectViewLayoutRoot: React.FC = observer(() => {
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId, viewId } = router.query as { const { workspaceSlug, projectId, viewId } = router.query;
workspaceSlug: string;
projectId: string;
viewId?: string;
};
const { const {
viewIssues: { loader, getIssues, fetchIssues }, 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 () => { useSWR(workspaceSlug && projectId && viewId ? `PROJECT_ISSUES_V3_${workspaceSlug}_${projectId}` : null, async () => {
if (workspaceSlug && projectId && viewId) { if (workspaceSlug && projectId && viewId) {
await fetchFilters(workspaceSlug, projectId, viewId); await fetchFilters(workspaceSlug.toString(), projectId.toString(), viewId.toString());
await fetchIssues(workspaceSlug, projectId, getIssues ? "mutation" : "init-loader"); await fetchIssues(workspaceSlug.toString(), projectId.toString(), getIssues ? "mutation" : "init-loader");
} }
}); });

View File

@ -19,7 +19,7 @@ export const ProjectAuthWrapper: FC<IProjectAuthWrapper> = observer((props) => {
const { children } = props; const { children } = props;
// store // store
const { const {
user: { fetchUserProjectInfo, projectMemberInfo, hasPermissionToProject }, user: { fetchUserProjectInfo, projectMemberInfo, hasPermissionToCurrentProject },
project: { fetchProjectDetails, workspaceProjects }, project: { fetchProjectDetails, workspaceProjects },
projectLabel: { fetchProjectLabels }, projectLabel: { fetchProjectLabels },
projectMember: { fetchProjectMembers }, projectMember: { fetchProjectMembers },
@ -47,44 +47,67 @@ export const ProjectAuthWrapper: FC<IProjectAuthWrapper> = observer((props) => {
); );
// fetching project labels // fetching project labels
useSWR( useSWR(
workspaceSlug && projectId ? `PROJECT_LABELS_${workspaceSlug}_${projectId}` : null, workspaceSlug && projectId && hasPermissionToCurrentProject ? `PROJECT_LABELS_${workspaceSlug}_${projectId}` : null,
workspaceSlug && projectId ? () => fetchProjectLabels(workspaceSlug.toString(), projectId.toString()) : null workspaceSlug && projectId && hasPermissionToCurrentProject
? () => fetchProjectLabels(workspaceSlug.toString(), projectId.toString())
: null
); );
// fetching project members // fetching project members
useSWR( useSWR(
workspaceSlug && projectId ? `PROJECT_MEMBERS_${workspaceSlug}_${projectId}` : null, workspaceSlug && projectId && hasPermissionToCurrentProject
workspaceSlug && projectId ? () => fetchProjectMembers(workspaceSlug.toString(), projectId.toString()) : null ? `PROJECT_MEMBERS_${workspaceSlug}_${projectId}`
: null,
workspaceSlug && projectId && hasPermissionToCurrentProject
? () => fetchProjectMembers(workspaceSlug.toString(), projectId.toString())
: null
); );
// fetching project states // fetching project states
useSWR( useSWR(
workspaceSlug && projectId ? `PROJECT_STATES_${workspaceSlug}_${projectId}` : null, workspaceSlug && projectId && hasPermissionToCurrentProject ? `PROJECT_STATES_${workspaceSlug}_${projectId}` : null,
workspaceSlug && projectId ? () => fetchProjectStates(workspaceSlug.toString(), projectId.toString()) : null workspaceSlug && projectId && hasPermissionToCurrentProject
? () => fetchProjectStates(workspaceSlug.toString(), projectId.toString())
: null
); );
// fetching project estimates // fetching project estimates
useSWR( useSWR(
workspaceSlug && projectId ? `PROJECT_ESTIMATES_${workspaceSlug}_${projectId}` : null, workspaceSlug && projectId && hasPermissionToCurrentProject
workspaceSlug && projectId ? () => fetchProjectEstimates(workspaceSlug.toString(), projectId.toString()) : null ? `PROJECT_ESTIMATES_${workspaceSlug}_${projectId}`
: null,
workspaceSlug && projectId && hasPermissionToCurrentProject
? () => fetchProjectEstimates(workspaceSlug.toString(), projectId.toString())
: null
); );
// fetching project cycles // fetching project cycles
useSWR( useSWR(
workspaceSlug && projectId ? `PROJECT_ALL_CYCLES_${workspaceSlug}_${projectId}` : null, workspaceSlug && projectId && hasPermissionToCurrentProject
workspaceSlug && projectId ? () => fetchCycles(workspaceSlug.toString(), projectId.toString(), "all") : null ? `PROJECT_ALL_CYCLES_${workspaceSlug}_${projectId}`
: null,
workspaceSlug && projectId && hasPermissionToCurrentProject
? () => fetchCycles(workspaceSlug.toString(), projectId.toString(), "all")
: null
); );
// fetching project modules // fetching project modules
useSWR( useSWR(
workspaceSlug && projectId ? `PROJECT_MODULES_${workspaceSlug}_${projectId}` : null, workspaceSlug && projectId && hasPermissionToCurrentProject
workspaceSlug && projectId ? () => fetchModules(workspaceSlug.toString(), projectId.toString()) : null ? `PROJECT_MODULES_${workspaceSlug}_${projectId}`
: null,
workspaceSlug && projectId && hasPermissionToCurrentProject
? () => fetchModules(workspaceSlug.toString(), projectId.toString())
: null
); );
// fetching project views // fetching project views
useSWR( useSWR(
workspaceSlug && projectId ? `PROJECT_VIEWS_${workspaceSlug}_${projectId}` : null, workspaceSlug && projectId && hasPermissionToCurrentProject ? `PROJECT_VIEWS_${workspaceSlug}_${projectId}` : null,
workspaceSlug && projectId ? () => fetchAllViews(workspaceSlug.toString(), projectId.toString()) : null workspaceSlug && projectId && hasPermissionToCurrentProject
? () => fetchAllViews(workspaceSlug.toString(), projectId.toString())
: null
); );
// TODO: fetching project pages
// fetching project inboxes if inbox is enabled // fetching project inboxes if inbox is enabled
useSWR( useSWR(
workspaceSlug && projectId && isInboxEnabled ? `PROJECT_INBOXES_${workspaceSlug}_${projectId}` : null, workspaceSlug && projectId && hasPermissionToCurrentProject && isInboxEnabled
workspaceSlug && projectId && isInboxEnabled ? `PROJECT_INBOXES_${workspaceSlug}_${projectId}`
: null,
workspaceSlug && projectId && hasPermissionToCurrentProject && isInboxEnabled
? () => fetchInboxesList(workspaceSlug.toString(), projectId.toString()) ? () => fetchInboxesList(workspaceSlug.toString(), projectId.toString())
: null, : null,
{ {
@ -97,7 +120,7 @@ export const ProjectAuthWrapper: FC<IProjectAuthWrapper> = observer((props) => {
const projectExists = projectId ? projectsList?.find((project) => project.id === projectId.toString()) : null; const projectExists = projectId ? projectsList?.find((project) => project.id === projectId.toString()) : null;
// check if the project member apis is loading // check if the project member apis is loading
if (!projectMemberInfo && projectId && hasPermissionToProject[projectId.toString()] === null) if (!projectMemberInfo && projectId && hasPermissionToCurrentProject === null)
return ( return (
<div className="grid h-screen place-items-center bg-custom-background-100 p-4"> <div className="grid h-screen place-items-center bg-custom-background-100 p-4">
<div className="flex flex-col items-center gap-3 text-center"> <div className="flex flex-col items-center gap-3 text-center">
@ -107,10 +130,10 @@ export const ProjectAuthWrapper: FC<IProjectAuthWrapper> = observer((props) => {
); );
// check if the user don't have permission to access the project // check if the user don't have permission to access the project
if (projectExists && projectId && hasPermissionToProject[projectId.toString()] === false) return <JoinProject />; if (projectExists && projectId && hasPermissionToCurrentProject === false) return <JoinProject />;
// check if the project info is not found. // check if the project info is not found.
if (!projectExists && projectId && hasPermissionToProject[projectId.toString()] === false) if (!projectExists && projectId && hasPermissionToCurrentProject === false)
return ( return (
<div className="container grid h-screen place-items-center bg-custom-background-100"> <div className="container grid h-screen place-items-center bg-custom-background-100">
<EmptyState <EmptyState

View File

@ -1,6 +1,7 @@
import { FC, ReactNode } from "react"; import { FC, ReactNode } from "react";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import useSWR from "swr"; import useSWR from "swr";
import useSWRImmutable from "swr/immutable";
// ui // ui
import { Spinner } from "@plane/ui"; import { Spinner } from "@plane/ui";
// store // store
@ -31,7 +32,7 @@ export const UserAuthWrapper: FC<IUserAuthWrapper> = observer((props) => {
shouldRetryOnError: false, shouldRetryOnError: false,
}); });
// fetching current user instance admin status // fetching current user instance admin status
useSWR("CURRENT_USER_INSTANCE_ADMIN_STATUS", () => fetchCurrentUserInstanceAdminStatus(), { useSWRImmutable("CURRENT_USER_INSTANCE_ADMIN_STATUS", () => fetchCurrentUserInstanceAdminStatus(), {
shouldRetryOnError: false, shouldRetryOnError: false,
}); });
// fetching user settings // fetching user settings

View File

@ -32,23 +32,25 @@ export const WorkspaceAuthWrapper: FC<IWorkspaceAuthWrapper> = observer((props)
); );
// fetching workspace projects // fetching workspace projects
useSWR( useSWR(
workspaceSlug ? `WORKSPACE_PROJECTS_${workspaceSlug}` : null, workspaceSlug && hasPermissionToCurrentWorkspace ? `WORKSPACE_PROJECTS_${workspaceSlug}` : null,
workspaceSlug ? () => fetchProjects(workspaceSlug.toString()) : null workspaceSlug && hasPermissionToCurrentWorkspace ? () => fetchProjects(workspaceSlug.toString()) : null
); );
// fetch workspace members // fetch workspace members
useSWR( useSWR(
workspaceSlug ? `WORKSPACE_MEMBERS_${workspaceSlug}` : null, workspaceSlug && hasPermissionToCurrentWorkspace ? `WORKSPACE_MEMBERS_${workspaceSlug}` : null,
workspaceSlug ? () => fetchWorkspaceMembers(workspaceSlug.toString()) : null workspaceSlug && hasPermissionToCurrentWorkspace ? () => fetchWorkspaceMembers(workspaceSlug.toString()) : null
); );
// fetch workspace labels // fetch workspace labels
useSWR( useSWR(
workspaceSlug ? `WORKSPACE_LABELS_${workspaceSlug}` : null, workspaceSlug && hasPermissionToCurrentWorkspace ? `WORKSPACE_LABELS_${workspaceSlug}` : null,
workspaceSlug ? () => fetchWorkspaceLabels(workspaceSlug.toString()) : null workspaceSlug && hasPermissionToCurrentWorkspace ? () => fetchWorkspaceLabels(workspaceSlug.toString()) : null
); );
// fetch workspace user projects role // fetch workspace user projects role
useSWR( useSWR(
workspaceSlug ? `WORKSPACE_PROJECTS_ROLE_${workspaceSlug}` : null, workspaceSlug && hasPermissionToCurrentWorkspace ? `WORKSPACE_PROJECTS_ROLE_${workspaceSlug}` : null,
workspaceSlug ? () => fetchWorkspaceUserProjectsRole(workspaceSlug.toString()) : null workspaceSlug && hasPermissionToCurrentWorkspace
? () => fetchWorkspaceUserProjectsRole(workspaceSlug.toString())
: null
); );
// while data is being loaded // while data is being loaded

View File

@ -87,10 +87,12 @@ export class ArchivedIssueStore implements IArchivedIssueStore {
autorun(() => { autorun(() => {
const workspaceSlug = this.rootStore.workspace.workspaceSlug; const workspaceSlug = this.rootStore.workspace.workspaceSlug;
const projectId = this.rootStore.project.projectId; const projectId = this.rootStore.project.projectId;
const hasPermissionToCurrentProject = this.rootStore.user.hasPermissionToCurrentProject;
if ( if (
workspaceSlug && workspaceSlug &&
projectId && projectId &&
hasPermissionToCurrentProject &&
this.rootStore.archivedIssueFilters.userDisplayFilters && this.rootStore.archivedIssueFilters.userDisplayFilters &&
this.rootStore.archivedIssueFilters.userFilters this.rootStore.archivedIssueFilters.userFilters
) )

View File

@ -89,10 +89,12 @@ export class CycleIssueStore implements ICycleIssueStore {
const workspaceSlug = this.rootStore.workspace.workspaceSlug; const workspaceSlug = this.rootStore.workspace.workspaceSlug;
const projectId = this.rootStore.project.projectId; const projectId = this.rootStore.project.projectId;
const cycleId = this.rootStore.cycle.cycleId; const cycleId = this.rootStore.cycle.cycleId;
const hasPermissionToCurrentProject = this.rootStore.user.hasPermissionToCurrentProject;
if ( if (
workspaceSlug && workspaceSlug &&
projectId && projectId &&
hasPermissionToCurrentProject &&
cycleId && cycleId &&
this.rootStore.cycleIssueFilter.cycleFilters && this.rootStore.cycleIssueFilter.cycleFilters &&
this.rootStore.issueFilter.userDisplayFilters this.rootStore.issueFilter.userDisplayFilters
@ -115,8 +117,8 @@ export class CycleIssueStore implements ICycleIssueStore {
? "groupWithSubGroups" ? "groupWithSubGroups"
: "grouped" : "grouped"
: ungroupedLayouts.includes(issueLayout) : ungroupedLayouts.includes(issueLayout)
? "ungrouped" ? "ungrouped"
: null; : null;
return _issueState || null; return _issueState || null;
} }

View File

@ -82,9 +82,11 @@ export class IssueStore implements IIssueStore {
autorun(() => { autorun(() => {
const workspaceSlug = this.rootStore.workspace.workspaceSlug; const workspaceSlug = this.rootStore.workspace.workspaceSlug;
const projectId = this.rootStore.project.projectId; const projectId = this.rootStore.project.projectId;
const hasPermissionToCurrentProject = this.rootStore.user.hasPermissionToCurrentProject;
if ( if (
workspaceSlug && workspaceSlug &&
projectId && projectId &&
hasPermissionToCurrentProject &&
this.rootStore.issueFilter.userFilters && this.rootStore.issueFilter.userFilters &&
this.rootStore.issueFilter.userDisplayFilters this.rootStore.issueFilter.userDisplayFilters
) )
@ -108,8 +110,8 @@ export class IssueStore implements IIssueStore {
: "grouped" : "grouped"
: "ungrouped" : "ungrouped"
: ungroupedLayouts.includes(issueLayout) : ungroupedLayouts.includes(issueLayout)
? "ungrouped" ? "ungrouped"
: null; : null;
return _issueState || null; return _issueState || null;
} }

View File

@ -60,7 +60,8 @@ export class ProjectArchivedIssuesStore extends IssueBaseStore implements IProje
autorun(() => { autorun(() => {
const workspaceSlug = this.rootStore.workspace.workspaceSlug; const workspaceSlug = this.rootStore.workspace.workspaceSlug;
const projectId = this.rootStore.project.projectId; 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; const userFilters = this.rootStore?.projectArchivedIssuesFilter?.issueFilters?.filters;
if (userFilters) this.fetchIssues(workspaceSlug, projectId, "mutation"); if (userFilters) this.fetchIssues(workspaceSlug, projectId, "mutation");

View File

@ -119,7 +119,8 @@ export class CycleIssuesStore extends IssueBaseStore implements ICycleIssuesStor
const workspaceSlug = this.rootStore.workspace.workspaceSlug; const workspaceSlug = this.rootStore.workspace.workspaceSlug;
const projectId = this.rootStore.project.projectId; const projectId = this.rootStore.project.projectId;
const cycleId = this.rootStore.cycle.cycleId; 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; const userFilters = this.rootStore?.cycleIssuesFilter?.issueFilters?.filters;
if (userFilters) this.fetchIssues(workspaceSlug, projectId, "mutation", cycleId); if (userFilters) this.fetchIssues(workspaceSlug, projectId, "mutation", cycleId);

View File

@ -63,7 +63,8 @@ export class ProjectDraftIssuesStore extends IssueBaseStore implements IProjectD
autorun(() => { autorun(() => {
const workspaceSlug = this.rootStore.workspace.workspaceSlug; const workspaceSlug = this.rootStore.workspace.workspaceSlug;
const projectId = this.rootStore.project.projectId; 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; const userFilters = this.rootStore?.projectDraftIssuesFilter?.issueFilters?.filters;
if (userFilters) this.fetchIssues(workspaceSlug, projectId, "mutation"); if (userFilters) this.fetchIssues(workspaceSlug, projectId, "mutation");

View File

@ -111,7 +111,8 @@ export class ModuleIssuesStore extends IssueBaseStore implements IModuleIssuesSt
const workspaceSlug = this.rootStore.workspace.workspaceSlug; const workspaceSlug = this.rootStore.workspace.workspaceSlug;
const projectId = this.rootStore.project.projectId; const projectId = this.rootStore.project.projectId;
const moduleId = this.rootStore.module.moduleId; 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; const userFilters = this.rootStore?.moduleIssuesFilter?.issueFilters?.filters;
if (userFilters) this.fetchIssues(workspaceSlug, projectId, "mutation", moduleId); if (userFilters) this.fetchIssues(workspaceSlug, projectId, "mutation", moduleId);

View File

@ -65,7 +65,8 @@ export class ViewIssuesStore extends IssueBaseStore implements IViewIssuesStore
autorun(() => { autorun(() => {
const workspaceSlug = this.rootStore.workspace.workspaceSlug; const workspaceSlug = this.rootStore.workspace.workspaceSlug;
const projectId = this.rootStore.project.projectId; 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; const userFilters = this.rootStore?.viewIssuesFilter?.issueFilters?.filters;
if (userFilters) this.fetchIssues(workspaceSlug, projectId, "mutation"); if (userFilters) this.fetchIssues(workspaceSlug, projectId, "mutation");

View File

@ -65,7 +65,8 @@ export class ProjectIssuesStore extends IssueBaseStore implements IProjectIssues
autorun(() => { autorun(() => {
const workspaceSlug = this.rootStore.workspace.workspaceSlug; const workspaceSlug = this.rootStore.workspace.workspaceSlug;
const projectId = this.rootStore.project.projectId; 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; const userFilters = this.rootStore?.projectIssuesFilter?.issueFilters?.filters;
if (userFilters) this.fetchIssues(workspaceSlug, projectId, "mutation"); if (userFilters) this.fetchIssues(workspaceSlug, projectId, "mutation");

View File

@ -91,10 +91,12 @@ export class ModuleIssueStore implements IModuleIssueStore {
const workspaceSlug = this.rootStore.workspace.workspaceSlug; const workspaceSlug = this.rootStore.workspace.workspaceSlug;
const projectId = this.rootStore.project.projectId; const projectId = this.rootStore.project.projectId;
const moduleId = this.rootStore.module.moduleId; const moduleId = this.rootStore.module.moduleId;
const hasPermissionToCurrentProject = this.rootStore.user.hasPermissionToCurrentProject;
if ( if (
workspaceSlug && workspaceSlug &&
projectId && projectId &&
hasPermissionToCurrentProject &&
moduleId && moduleId &&
this.rootStore.moduleFilter.moduleFilters && this.rootStore.moduleFilter.moduleFilters &&
this.rootStore.issueFilter.userDisplayFilters this.rootStore.issueFilter.userDisplayFilters
@ -117,8 +119,8 @@ export class ModuleIssueStore implements IModuleIssueStore {
? "groupWithSubGroups" ? "groupWithSubGroups"
: "grouped" : "grouped"
: ungroupedLayouts.includes(issueLayout) : ungroupedLayouts.includes(issueLayout)
? "ungrouped" ? "ungrouped"
: null; : null;
return _issueState || null; return _issueState || null;
} }

View File

@ -68,7 +68,6 @@ export class ProfileIssueFilterStore implements IProfileIssueFilterStore {
const workspaceSlug = this.rootStore.workspace.workspaceSlug; const workspaceSlug = this.rootStore.workspace.workspaceSlug;
const userId = this.rootStore.profileIssues?.userId; const userId = this.rootStore.profileIssues?.userId;
if (workspaceSlug && userId && this.rootStore.profileIssues.currentProfileTab && this.appliedFilters) { if (workspaceSlug && userId && this.rootStore.profileIssues.currentProfileTab && this.appliedFilters) {
console.log("autorun triggered");
this.rootStore.profileIssues.fetchIssues( this.rootStore.profileIssues.fetchIssues(
workspaceSlug, workspaceSlug,
userId, userId,