mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
ddb07dbe5f
* chore: removed inbox id * fix: inbox changes * chore: resolved merge conflicts * chore: inbox issue response changes * chore: inbox issue filters * fix: inbox implementation revamp * fix: type fixes * fix: pagination implementation * fix: inbox fixes * fix: pagination fixes * fix: inbox Issues pagination fixes * chore: triage state change * fix: inbox fixes * chore: filtering using boolean * chore: total results in the pagination * fix: inbox main content changes * fix: develop pull fixes * chore: resolved build erros in inbox issues * dev: fix migrations * chore: module, labels and assignee in inbox * chore: inbox issue order by * chore: inbox filters * chore: inbox ui revamp * chore: inbox type updated * chore: updated filters * chore: updated filter menmbers and date types in inbox issue filter * chore: inbox issue filter updated * chore: updated date filter in the inbox issue filter * chore: moved the current tab state from local state to store * chore: updated the filter and fetch request in the inbox issues * chore: updated tab change handler * chore: handled isEmpty in the issue filters query params * chore: inbox sidebar updated * chore: enabled create inbox issue in mobx * chore: replaced the key inbox_status to status * chore: inbox sidebar pagination * chore: updated inbox issue services * chore: inbox sidebar total count indicator * chore: create inbox issue updated * chore: updated inbox issue sidebar layout * chore: rendering issue detail in inbox issue * chore: inbox issue content updated * chore: create inbox issue modal description improvement * fix: updated delete functionality in inbox store * chore: updated multiple inbox issue creation * chore: handled loading, empty states and inbox user access permissions * chore: updated rendering issues in the sidebar * chore: inbox sidebar label improvement * chore: handled empty states * chore: disabled inbox empty state added * chore: module, labels and assignee in list endpoint * chore: labels in list endpoint * chore: inboc issue serializer * chore: representation in serializer * chore: super function * chore: inbox empty state updated * chore: implemented applied filters * chore: inbox empty state updated * chore: update date formats in applied filters * chore: inbox skeleton updated * chore: ui changes in the siebar list item * chore: removed the module and cycle ids * chore: inbox sidebar tab * chore: inbox actions * chore: updated inbox issue header actions * chore: updated inbox issue code cleanup * chore: loader improvement * chore: inbox sidebar improvement * chore: inbox sidebar empty state flicker * fix: inbox issue delete operation * chore: inbox issue title and description update indicator added * fix: resolved issue property rendering in initial load * chore: inbox sidebar and detail header improvement * fix: handling selected filter in the issue filters and applied filters * chore: inbox issue detail improvement * chore: inbox issue label updated * chore: inbox issue sidebar improvement * fix: handling issue description update when we move between the issues in inbox * chore: removed inbox issue helpers file * chore: boolean checked * chore: resolved file change requests --------- Co-authored-by: NarayanBavisetti <narayan3119@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com> Co-authored-by: pablohashescobar <nikhilschacko@gmail.com> Co-authored-by: Anmol Singh Bhatia <anmolsinghbhatia@plane.so>
144 lines
5.4 KiB
TypeScript
144 lines
5.4 KiB
TypeScript
import { FC, ReactNode } from "react";
|
|
import { observer } from "mobx-react-lite";
|
|
import { useRouter } from "next/router";
|
|
import useSWR from "swr";
|
|
// hooks
|
|
// components
|
|
import { Spinner } from "@plane/ui";
|
|
import { JoinProject } from "@/components/auth-screens";
|
|
import { EmptyState } from "@/components/common";
|
|
import {
|
|
useApplication,
|
|
useEventTracker,
|
|
useCycle,
|
|
useEstimate,
|
|
useLabel,
|
|
useMember,
|
|
useModule,
|
|
useProject,
|
|
useProjectState,
|
|
useProjectView,
|
|
useUser,
|
|
// useInbox,
|
|
} from "@/hooks/store";
|
|
// images
|
|
import emptyProject from "public/empty-state/project.svg";
|
|
|
|
interface IProjectAuthWrapper {
|
|
children: ReactNode;
|
|
}
|
|
|
|
export const ProjectAuthWrapper: FC<IProjectAuthWrapper> = observer((props) => {
|
|
const { children } = props;
|
|
// store
|
|
// const { fetchInboxes } = useInbox();
|
|
const {
|
|
commandPalette: { toggleCreateProjectModal },
|
|
} = useApplication();
|
|
const { setTrackElement } = useEventTracker();
|
|
const {
|
|
membership: { fetchUserProjectInfo, projectMemberInfo, hasPermissionToProject },
|
|
} = useUser();
|
|
const { getProjectById, fetchProjectDetails } = useProject();
|
|
const { fetchAllCycles } = useCycle();
|
|
const { fetchModules } = useModule();
|
|
const { fetchViews } = useProjectView();
|
|
const {
|
|
project: { fetchProjectMembers },
|
|
} = useMember();
|
|
const { fetchProjectStates } = useProjectState();
|
|
const { fetchProjectLabels } = useLabel();
|
|
const { fetchProjectEstimates } = useEstimate();
|
|
// router
|
|
const router = useRouter();
|
|
const { workspaceSlug, projectId } = router.query;
|
|
|
|
// fetching project details
|
|
useSWR(
|
|
workspaceSlug && projectId ? `PROJECT_DETAILS_${workspaceSlug.toString()}_${projectId.toString()}` : null,
|
|
workspaceSlug && projectId ? () => fetchProjectDetails(workspaceSlug.toString(), projectId.toString()) : null
|
|
);
|
|
// fetching user project member information
|
|
useSWR(
|
|
workspaceSlug && projectId ? `PROJECT_MEMBERS_ME_${workspaceSlug}_${projectId}` : null,
|
|
workspaceSlug && projectId ? () => fetchUserProjectInfo(workspaceSlug.toString(), projectId.toString()) : null
|
|
);
|
|
// fetching project labels
|
|
useSWR(
|
|
workspaceSlug && projectId ? `PROJECT_LABELS_${workspaceSlug}_${projectId}` : null,
|
|
workspaceSlug && projectId ? () => fetchProjectLabels(workspaceSlug.toString(), projectId.toString()) : null,
|
|
{ revalidateIfStale: false, revalidateOnFocus: false }
|
|
);
|
|
// fetching project members
|
|
useSWR(
|
|
workspaceSlug && projectId ? `PROJECT_MEMBERS_${workspaceSlug}_${projectId}` : null,
|
|
workspaceSlug && projectId ? () => fetchProjectMembers(workspaceSlug.toString(), projectId.toString()) : null,
|
|
{ revalidateIfStale: false, revalidateOnFocus: false }
|
|
);
|
|
// fetching project states
|
|
useSWR(
|
|
workspaceSlug && projectId ? `PROJECT_STATES_${workspaceSlug}_${projectId}` : null,
|
|
workspaceSlug && projectId ? () => fetchProjectStates(workspaceSlug.toString(), projectId.toString()) : null,
|
|
{ revalidateIfStale: false, revalidateOnFocus: false }
|
|
);
|
|
// fetching project estimates
|
|
useSWR(
|
|
workspaceSlug && projectId ? `PROJECT_ESTIMATES_${workspaceSlug}_${projectId}` : null,
|
|
workspaceSlug && projectId ? () => fetchProjectEstimates(workspaceSlug.toString(), projectId.toString()) : null,
|
|
{ revalidateIfStale: false, revalidateOnFocus: false }
|
|
);
|
|
// fetching project cycles
|
|
useSWR(
|
|
workspaceSlug && projectId ? `PROJECT_ALL_CYCLES_${workspaceSlug}_${projectId}` : null,
|
|
workspaceSlug && projectId ? () => fetchAllCycles(workspaceSlug.toString(), projectId.toString()) : null,
|
|
{ revalidateIfStale: false, revalidateOnFocus: false }
|
|
);
|
|
// fetching project modules
|
|
useSWR(
|
|
workspaceSlug && projectId ? `PROJECT_MODULES_${workspaceSlug}_${projectId}` : null,
|
|
workspaceSlug && projectId ? () => fetchModules(workspaceSlug.toString(), projectId.toString()) : null,
|
|
{ revalidateIfStale: false, revalidateOnFocus: false }
|
|
);
|
|
// fetching project views
|
|
useSWR(
|
|
workspaceSlug && projectId ? `PROJECT_VIEWS_${workspaceSlug}_${projectId}` : null,
|
|
workspaceSlug && projectId ? () => fetchViews(workspaceSlug.toString(), projectId.toString()) : null,
|
|
{ revalidateIfStale: false, revalidateOnFocus: false }
|
|
);
|
|
const projectExists = projectId ? getProjectById(projectId.toString()) : null;
|
|
|
|
// check if the project member apis is loading
|
|
if (!projectMemberInfo && projectId && hasPermissionToProject[projectId.toString()] === null)
|
|
return (
|
|
<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">
|
|
<Spinner />
|
|
</div>
|
|
</div>
|
|
);
|
|
|
|
// check if the user don't have permission to access the project
|
|
if (projectExists && projectId && hasPermissionToProject[projectId.toString()] === false) return <JoinProject />;
|
|
|
|
// check if the project info is not found.
|
|
if (!projectExists && projectId && hasPermissionToProject[projectId.toString()] === false)
|
|
return (
|
|
<div className="container grid h-screen place-items-center bg-custom-background-100">
|
|
<EmptyState
|
|
title="No such project exists"
|
|
description="Try creating a new project"
|
|
image={emptyProject}
|
|
primaryButton={{
|
|
text: "Create Project",
|
|
onClick: () => {
|
|
setTrackElement("Projects page empty state");
|
|
toggleCreateProjectModal(true);
|
|
},
|
|
}}
|
|
/>
|
|
</div>
|
|
);
|
|
|
|
return <>{children}</>;
|
|
});
|