mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
d3b73dc32f
* feat: manual ordering for issues in kanban * refactor: issues folder structure * refactor: modules and states folder structure * refactor: datepicker code * fix: create issue modal bug * feat: custom progress bar added * refactor: created global component for kanban board * refactor: update cycle and module issue create * refactor: return modules created * refactor: integrated global kanban view everywhere * refactor: integrated global list view everywhere * refactor: removed unnecessary api calls * refactor: update nomenclature for consistency * refactor: global select component for issue view * refactor: track cycles and modules for issue * fix: tracking new cycles and modules in activities * feat: segregate api token workspace * fix: workpsace id during token creation * refactor: update model association to cascade on delete * feat: sentry integrated (#235) * feat: sentry integrated * fix: removed unnecessary env variable * fix: update remirror description to save empty string and empty paragraph (#237) * Update README.md * fix: description and comment_json default value to remove warnings * feat: link option in remirror (#240) * feat: link option in remirror * fix: removed link import from remirror toolbar * feat: module and cycle settings under project * fix: module issue assignment * fix: module issue updation and activity logging * fix: typo while creating module issues * fix: string comparison for update operation * fix: ui fixes (#246) * style: shortcut command label bg color change * sidebar shortcut ui fix --------- Co-authored-by: Anmol Singh Bhatia <anmolsinghbhatia1001@gmail.com> * fix: update empty passwords to hashed string and add hashing for magic sign in * refactor: remove print logs from back migrations * build(deps): bump django in /apiserver/requirements Bumps [django](https://github.com/django/django) from 3.2.16 to 3.2.17. - [Release notes](https://github.com/django/django/releases) - [Commits](https://github.com/django/django/compare/3.2.16...3.2.17) --- updated-dependencies: - dependency-name: django dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * feat: cycles and modules toggle in settings, refactor: folder structure (#247) * feat: link option in remirror * fix: removed link import from remirror toolbar * refactor: constants folder * refactor: layouts folder structure * fix: issue view context * feat: cycles and modules toggle in settings --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: pablohashescobar <nikhilschacko@gmail.com> Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com> Co-authored-by: Anmol Singh Bhatia <anmolsinghbhatia1001@gmail.com> Co-authored-by: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Co-authored-by: pablohashescobar <118773738+pablohashescobar@users.noreply.github.com> Co-authored-by: sphynxux <122926002+sphynxux@users.noreply.github.com> Co-authored-by: Anmol Singh Bhatia <121005188+anmolsinghbhatia@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
223 lines
6.1 KiB
TypeScript
223 lines
6.1 KiB
TypeScript
import React, { FC, useState } from "react";
|
|
|
|
import { useRouter } from "next/router";
|
|
import Link from "next/link";
|
|
|
|
import useSWR from "swr";
|
|
|
|
// services
|
|
import projectService from "services/project.service";
|
|
// hooks
|
|
import useUser from "hooks/use-user";
|
|
// ui
|
|
import { Button, Spinner } from "components/ui";
|
|
// components
|
|
import { NotAuthorizedView } from "components/core";
|
|
import CommandPalette from "components/command-palette";
|
|
import { JoinProject } from "components/project";
|
|
// local components
|
|
import Container from "layouts/container";
|
|
import AppSidebar from "layouts/app-layout/app-sidebar";
|
|
import AppHeader from "layouts/app-layout/app-header";
|
|
import SettingsSidebar from "layouts/settings-layout/settings-sidebar";
|
|
// types
|
|
import { UserAuth } from "types";
|
|
// fetch-keys
|
|
import { PROJECT_MEMBERS } from "constants/fetch-keys";
|
|
|
|
type Meta = {
|
|
title?: string | null;
|
|
description?: string | null;
|
|
image?: string | null;
|
|
url?: string | null;
|
|
};
|
|
|
|
type AppLayoutProps = {
|
|
meta?: Meta;
|
|
children: React.ReactNode;
|
|
noPadding?: boolean;
|
|
bg?: "primary" | "secondary";
|
|
noHeader?: boolean;
|
|
breadcrumbs?: JSX.Element;
|
|
left?: JSX.Element;
|
|
right?: JSX.Element;
|
|
settingsLayout?: "project" | "workspace";
|
|
memberType?: UserAuth;
|
|
};
|
|
|
|
const workspaceLinks: (wSlug: string) => Array<{
|
|
label: string;
|
|
href: string;
|
|
}> = (workspaceSlug) => [
|
|
{
|
|
label: "General",
|
|
href: `/${workspaceSlug}/settings`,
|
|
},
|
|
{
|
|
label: "Members",
|
|
href: `/${workspaceSlug}/settings/members`,
|
|
},
|
|
{
|
|
label: "Billing & Plans",
|
|
href: `/${workspaceSlug}/settings/billing`,
|
|
},
|
|
];
|
|
|
|
const sidebarLinks: (
|
|
wSlug?: string,
|
|
pId?: string
|
|
) => Array<{
|
|
label: string;
|
|
href: string;
|
|
}> = (workspaceSlug, projectId) => [
|
|
{
|
|
label: "General",
|
|
href: `/${workspaceSlug}/projects/${projectId}/settings`,
|
|
},
|
|
{
|
|
label: "Control",
|
|
href: `/${workspaceSlug}/projects/${projectId}/settings/control`,
|
|
},
|
|
{
|
|
label: "Members",
|
|
href: `/${workspaceSlug}/projects/${projectId}/settings/members`,
|
|
},
|
|
{
|
|
label: "Features",
|
|
href: `/${workspaceSlug}/projects/${projectId}/settings/features`,
|
|
},
|
|
{
|
|
label: "States",
|
|
href: `/${workspaceSlug}/projects/${projectId}/settings/states`,
|
|
},
|
|
{
|
|
label: "Labels",
|
|
href: `/${workspaceSlug}/projects/${projectId}/settings/labels`,
|
|
},
|
|
];
|
|
|
|
const AppLayout: FC<AppLayoutProps> = ({
|
|
meta,
|
|
children,
|
|
noPadding = false,
|
|
bg = "primary",
|
|
noHeader = false,
|
|
breadcrumbs,
|
|
left,
|
|
right,
|
|
settingsLayout,
|
|
memberType,
|
|
}) => {
|
|
// states
|
|
const [toggleSidebar, setToggleSidebar] = useState(false);
|
|
const [isJoiningProject, setIsJoiningProject] = useState(false);
|
|
|
|
const router = useRouter();
|
|
const { workspaceSlug, projectId } = router.query;
|
|
|
|
const { user } = useUser();
|
|
|
|
const { data: projectMembers, mutate: projectMembersMutate } = useSWR(
|
|
workspaceSlug && projectId ? PROJECT_MEMBERS(projectId as string) : null,
|
|
workspaceSlug && projectId
|
|
? () => projectService.projectMembers(workspaceSlug as string, projectId as string)
|
|
: null,
|
|
{
|
|
shouldRetryOnError: false,
|
|
}
|
|
);
|
|
// flags
|
|
const isMember = projectMembers?.find((member) => member.member.id === user?.id) || !projectId;
|
|
|
|
const handleJoin = () => {
|
|
setIsJoiningProject(true);
|
|
projectService
|
|
.joinProject(workspaceSlug as string, {
|
|
project_ids: [projectId as string],
|
|
})
|
|
.then(() => {
|
|
setIsJoiningProject(false);
|
|
projectMembersMutate();
|
|
})
|
|
.catch((err) => {
|
|
console.error(err);
|
|
});
|
|
};
|
|
|
|
return (
|
|
<Container meta={meta}>
|
|
<CommandPalette />
|
|
<div className="flex h-screen w-full overflow-x-hidden">
|
|
<AppSidebar toggleSidebar={toggleSidebar} setToggleSidebar={setToggleSidebar} />
|
|
{settingsLayout && (memberType?.isGuest || memberType?.isViewer) ? (
|
|
<NotAuthorizedView
|
|
actionButton={
|
|
(memberType?.isViewer || memberType?.isGuest) && projectId ? (
|
|
<Link href={`/${workspaceSlug}/projects/${projectId}/issues`}>
|
|
<Button size="sm" theme="secondary">
|
|
Go to Issues
|
|
</Button>
|
|
</Link>
|
|
) : (
|
|
(memberType?.isViewer || memberType?.isGuest) &&
|
|
workspaceSlug && (
|
|
<Link href={`/${workspaceSlug}`}>
|
|
<Button size="sm" theme="secondary">
|
|
Go to workspace
|
|
</Button>
|
|
</Link>
|
|
)
|
|
)
|
|
}
|
|
/>
|
|
) : (
|
|
<>
|
|
{settingsLayout && (
|
|
<SettingsSidebar
|
|
links={
|
|
settingsLayout === "workspace"
|
|
? workspaceLinks(workspaceSlug as string)
|
|
: sidebarLinks(workspaceSlug as string, projectId as string)
|
|
}
|
|
/>
|
|
)}
|
|
<main className="flex h-screen w-full min-w-0 flex-col overflow-y-auto">
|
|
{!noHeader && (
|
|
<AppHeader
|
|
breadcrumbs={breadcrumbs}
|
|
left={left}
|
|
right={right}
|
|
setToggleSidebar={setToggleSidebar}
|
|
/>
|
|
)}
|
|
{projectId && !projectMembers ? (
|
|
<div className="flex h-full w-full items-center justify-center">
|
|
<Spinner />
|
|
</div>
|
|
) : isMember ? (
|
|
<div
|
|
className={`w-full flex-grow ${
|
|
noPadding ? "" : settingsLayout ? "p-5 pb-5 lg:px-16 lg:pt-10" : "p-5"
|
|
} ${
|
|
bg === "primary"
|
|
? "bg-primary"
|
|
: bg === "secondary"
|
|
? "bg-secondary"
|
|
: "bg-primary"
|
|
}`}
|
|
>
|
|
{children}
|
|
</div>
|
|
) : (
|
|
<JoinProject isJoiningProject={isJoiningProject} handleJoin={handleJoin} />
|
|
)}
|
|
</main>
|
|
</>
|
|
)}
|
|
</div>
|
|
</Container>
|
|
);
|
|
};
|
|
|
|
export default AppLayout;
|