Skip to content

Commit

Permalink
chore: layout refactor (#2522)
Browse files Browse the repository at this point in the history
* chore: pages layout refactor

* chore: view layout refactor

* chore: view layout refactor

* chore: inbox layout refactor

* chore: draft issue layout refactor

* chore: archived issue layout refactor

* chore: draft issue header layout fix

* chore: layout code refactor

* chore: code refactor

* chore: project setting layout fix
  • Loading branch information
anmolsinghbhatia authored Oct 23, 2023
1 parent d7a36f5 commit 1786a39
Show file tree
Hide file tree
Showing 24 changed files with 461 additions and 429 deletions.
11 changes: 1 addition & 10 deletions web/components/headers/cycles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from "react";

import { useRouter } from "next/router";
import Link from "next/link";
import { ArrowLeft, Plus } from "lucide-react";
import { Plus } from "lucide-react";
// ui
import { Breadcrumbs, BreadcrumbItem, Button } from "@plane/ui";
// helpers
Expand All @@ -23,15 +23,6 @@ export const CyclesHeader: React.FC<ICyclesHeader> = (props) => {
className={`relative z-10 flex w-full flex-shrink-0 flex-row items-center justify-between gap-x-2 gap-y-4 border-b border-custom-border-200 bg-custom-sidebar-background-100 p-4`}
>
<div className="flex w-full flex-grow items-center gap-2 overflow-ellipsis whitespace-nowrap">
<div className="block md:hidden">
<button
type="button"
className="grid h-8 w-8 place-items-center rounded border border-custom-border-200"
onClick={() => router.back()}
>
<ArrowLeft fontSize={14} strokeWidth={2} />
</button>
</div>
<div>
<Breadcrumbs onBack={() => router.back()}>
<BreadcrumbItem
Expand Down
5 changes: 5 additions & 0 deletions web/components/headers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ export * from "./cycles";
export * from "./modules";
export * from "./project-settings";
export * from "./workspace-settings";
export * from "./pages";
export * from "./project-draft-issues";
export * from "./project-archived-issue-details";
export * from "./project-archived-issues";
export * from "./project-issue-details";
11 changes: 1 addition & 10 deletions web/components/headers/modules.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Dispatch, FC, SetStateAction } from "react";
import { useRouter } from "next/router";
import Link from "next/link";
import { ArrowLeft, Plus } from "lucide-react";
import { Plus } from "lucide-react";
// components
// ui
import { Breadcrumbs, BreadcrumbItem, Button, Tooltip } from "@plane/ui";
Expand Down Expand Up @@ -37,15 +37,6 @@ export const ModulesHeader: FC<IModulesHeader> = (props) => {
className={`relative z-10 flex w-full flex-shrink-0 flex-row items-center justify-between gap-x-2 gap-y-4 border-b border-custom-border-200 bg-custom-sidebar-background-100 p-4`}
>
<div className="flex w-full flex-grow items-center gap-2 overflow-ellipsis whitespace-nowrap">
<div className="block md:hidden">
<button
type="button"
className="grid h-8 w-8 place-items-center rounded border border-custom-border-200"
onClick={() => router.back()}
>
<ArrowLeft fontSize={14} strokeWidth={2} />
</button>
</div>
<div>
<Breadcrumbs onBack={() => router.back()}>
<BreadcrumbItem
Expand Down
64 changes: 64 additions & 0 deletions web/components/headers/pages.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { FC } from "react";
import Link from "next/link";
import { useRouter } from "next/router";
import { observer } from "mobx-react-lite";
import { Plus } from "lucide-react";
// hooks
import { useMobxStore } from "lib/mobx/store-provider";
// ui
import { Breadcrumbs, BreadcrumbItem, Button } from "@plane/ui";
// helper
import { truncateText } from "helpers/string.helper";

export interface IPagesHeaderProps {
showButton?: boolean;
}

export const PagesHeader: FC<IPagesHeaderProps> = observer((props) => {
const { showButton = false } = props;
const router = useRouter();
const { workspaceSlug, projectId } = router.query;

const { project: projectStore } = useMobxStore();

const projectDetails =
workspaceSlug && projectId
? projectStore.getProjectById(workspaceSlug.toString(), projectId.toString())
: undefined;

return (
<div className="relative flex w-full flex-shrink-0 flex-row z-10 items-center justify-between gap-x-2 gap-y-4 border-b border-custom-border-200 bg-custom-sidebar-background-100 p-4">
<div className="flex items-center gap-2 flex-grow w-full whitespace-nowrap overflow-ellipsis">
<div>
<Breadcrumbs onBack={() => router.back()}>
<BreadcrumbItem
link={
<Link href={`/${workspaceSlug}/projects`}>
<a className={`border-r-2 border-custom-sidebar-border-200 px-3 text-sm `}>
<p>Projects</p>
</a>
</Link>
}
/>
<BreadcrumbItem title={`${truncateText(projectDetails?.name ?? "Project", 32)} Pages`} />
</Breadcrumbs>
</div>
</div>
{showButton && (
<div className="flex items-center gap-2">
<Button
variant="primary"
prependIcon={<Plus />}
size="sm"
onClick={() => {
const e = new KeyboardEvent("keydown", { key: "d" });
document.dispatchEvent(e);
}}
>
Create Page
</Button>
</div>
)}
</div>
);
});
10 changes: 0 additions & 10 deletions web/components/headers/profile-preferences.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useRouter } from "next/router";
import { ArrowLeft } from "lucide-react";
// components
import { BreadcrumbItem, Breadcrumbs } from "@plane/ui";

Expand All @@ -11,15 +10,6 @@ export const ProfilePreferencesHeader = () => {
className={`relative flex w-full flex-shrink-0 flex-row z-10 items-center justify-between gap-x-2 gap-y-4 border-b border-custom-border-200 bg-custom-sidebar-background-100 p-4`}
>
<div className="flex items-center gap-2 flex-grow w-full whitespace-nowrap overflow-ellipsis">
<div className="block md:hidden">
<button
type="button"
className="grid h-8 w-8 place-items-center rounded border border-custom-border-200"
onClick={() => router.back()}
>
<ArrowLeft fontSize={14} strokeWidth={2} />
</button>
</div>
<div>
<Breadcrumbs onBack={() => router.back()}>
<BreadcrumbItem title="My Profile Preferences" />
Expand Down
64 changes: 64 additions & 0 deletions web/components/headers/project-archived-issue-details.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { FC } from "react";
import useSWR from "swr";
import Link from "next/link";
import { useRouter } from "next/router";
import { observer } from "mobx-react-lite";
// hooks
import { useMobxStore } from "lib/mobx/store-provider";
// ui
import { Breadcrumbs, BreadcrumbItem } from "@plane/ui";
// helper
import { truncateText } from "helpers/string.helper";
// types
import { IIssue } from "types";
// constants
import { ISSUE_DETAILS } from "constants/fetch-keys";
// services
import { IssueArchiveService } from "services/issue";

const issueArchiveService = new IssueArchiveService();

export const ProjectArchivedIssueDetailsHeader: FC = observer(() => {
const router = useRouter();
const { workspaceSlug, projectId, archivedIssueId } = router.query;

const { project: projectStore } = useMobxStore();

const projectDetails =
workspaceSlug && projectId
? projectStore.getProjectById(workspaceSlug.toString(), projectId.toString())
: undefined;

const { data: issueDetails } = useSWR<IIssue | undefined>(
workspaceSlug && projectId && archivedIssueId ? ISSUE_DETAILS(archivedIssueId as string) : null,
workspaceSlug && projectId && archivedIssueId
? () =>
issueArchiveService.retrieveArchivedIssue(
workspaceSlug as string,
projectId as string,
archivedIssueId as string
)
: null
);

return (
<div className="relative flex w-full flex-shrink-0 flex-row z-10 items-center justify-between gap-x-2 gap-y-4 border-b border-custom-border-200 bg-custom-sidebar-background-100 p-4">
<div className="flex items-center gap-2 flex-grow w-full whitespace-nowrap overflow-ellipsis">
<div>
<Breadcrumbs onBack={() => router.back()}>
<Link href={`/${workspaceSlug}/projects/${projectId as string}/issues`}>
<a className={`border-r-2 border-custom-sidebar-border-200 px-3 text-sm `}>
<p className="truncate">{`${truncateText(
issueDetails?.project_detail.name ?? "Project",
32
)} Issues`}</p>
</a>
</Link>

<BreadcrumbItem title={`${truncateText(projectDetails?.name ?? "Project", 32)} Archived Issues`} />
</Breadcrumbs>
</div>
</div>
</div>
);
});
40 changes: 40 additions & 0 deletions web/components/headers/project-archived-issues.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { FC } from "react";
import Link from "next/link";
import { useRouter } from "next/router";
import { observer } from "mobx-react-lite";
// hooks
import { useMobxStore } from "lib/mobx/store-provider";
// ui
import { Breadcrumbs, BreadcrumbItem } from "@plane/ui";
// helper
import { truncateText } from "helpers/string.helper";

export const ProjectArchivedIssuesHeader: FC = observer(() => {
const router = useRouter();
const { workspaceSlug, projectId } = router.query;

const { project: projectStore } = useMobxStore();

const projectDetails =
workspaceSlug && projectId
? projectStore.getProjectById(workspaceSlug.toString(), projectId.toString())
: undefined;

return (
<div className="relative flex w-full flex-shrink-0 flex-row z-10 items-center justify-between gap-x-2 gap-y-4 border-b border-custom-border-200 bg-custom-sidebar-background-100 p-4">
<div className="flex items-center gap-2 flex-grow w-full whitespace-nowrap overflow-ellipsis">
<div>
<Breadcrumbs onBack={() => router.back()}>
<Link href={`/${workspaceSlug}/projects`}>
<a className={`border-r-2 border-custom-sidebar-border-200 px-3 text-sm `}>
<p>Projects</p>
</a>
</Link>

<BreadcrumbItem title={`${truncateText(projectDetails?.name ?? "Project", 32)} Archived Issues`} />
</Breadcrumbs>
</div>
</div>
</div>
);
});
44 changes: 44 additions & 0 deletions web/components/headers/project-draft-issues.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { FC } from "react";
import Link from "next/link";
import { useRouter } from "next/router";
import { observer } from "mobx-react-lite";
// hooks
import { useMobxStore } from "lib/mobx/store-provider";
// ui
import { Breadcrumbs, BreadcrumbItem } from "@plane/ui";
// helper
import { truncateText } from "helpers/string.helper";

export const ProjectDraftIssueHeader: FC = observer(() => {
const router = useRouter();
const { workspaceSlug, projectId } = router.query;

const { project: projectStore } = useMobxStore();

const projectDetails =
workspaceSlug && projectId
? projectStore.getProjectById(workspaceSlug.toString(), projectId.toString())
: undefined;

return (
<div className="relative flex w-full flex-shrink-0 flex-row z-10 items-center justify-between gap-x-2 gap-y-4 border-b border-custom-border-200 bg-custom-sidebar-background-100 p-4">
<div className="flex items-center gap-2 flex-grow w-full whitespace-nowrap overflow-ellipsis">
<div>
<Breadcrumbs onBack={() => router.back()}>
<BreadcrumbItem
link={
<Link href={`/${workspaceSlug}/projects`}>
<a className={`border-r-2 border-custom-sidebar-border-200 px-3 text-sm `}>
<p>Projects</p>
</a>
</Link>
}
/>

<BreadcrumbItem title={`${truncateText(projectDetails?.name ?? "Project", 32)} Draft Issues`} />
</Breadcrumbs>
</div>
</div>
</div>
);
});
61 changes: 47 additions & 14 deletions web/components/headers/project-inbox.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,54 @@
import { useState } from "react";

import { FC, useState } from "react";
import Link from "next/link";
import { useRouter } from "next/router";
import { observer } from "mobx-react-lite";
import { Plus } from "lucide-react";
// hooks
import { useMobxStore } from "lib/mobx/store-provider";
// ui
import { Breadcrumbs, BreadcrumbItem, Button } from "@plane/ui";
// components
import { CreateInboxIssueModal } from "components/inbox";
// ui
import { Button } from "@plane/ui";
// icons
import { Plus } from "lucide-react";
// helper
import { truncateText } from "helpers/string.helper";

export const ProjectInboxHeader = () => {
export const ProjectInboxHeader: FC = observer(() => {
const router = useRouter();
const { workspaceSlug, projectId } = router.query;
const [createIssueModal, setCreateIssueModal] = useState(false);

const { project: projectStore } = useMobxStore();

const projectDetails =
workspaceSlug && projectId
? projectStore.getProjectById(workspaceSlug.toString(), projectId.toString())
: undefined;

return (
<>
<CreateInboxIssueModal isOpen={createIssueModal} onClose={() => setCreateIssueModal(false)} />
<Button onClick={() => setCreateIssueModal(true)} size="sm" prependIcon={<Plus />}>
Add Issue
</Button>
</>
<div className="relative flex w-full flex-shrink-0 flex-row z-10 items-center justify-between gap-x-2 gap-y-4 border-b border-custom-border-200 bg-custom-sidebar-background-100 p-4">
<div className="flex items-center gap-2 flex-grow w-full whitespace-nowrap overflow-ellipsis">
<div>
<Breadcrumbs onBack={() => router.back()}>
<BreadcrumbItem
link={
<Link href={`/${workspaceSlug}/projects`}>
<a className={`border-r-2 border-custom-sidebar-border-200 px-3 text-sm `}>
<p>Projects</p>
</a>
</Link>
}
/>
<BreadcrumbItem title={`${truncateText(projectDetails?.name ?? "Project", 32)} Inbox`} />
</Breadcrumbs>
</div>
</div>

<div className="flex items-center gap-2">
<CreateInboxIssueModal isOpen={createIssueModal} onClose={() => setCreateIssueModal(false)} />
<Button variant="primary" prependIcon={<Plus />} size="sm" onClick={() => setCreateIssueModal(true)}>
Add Issue
</Button>
</div>
</div>
);
};
});
Loading

0 comments on commit 1786a39

Please sign in to comment.