From 91c583ce1ecd6d83747db9103e65151f6bcce720 Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal Date: Fri, 3 Nov 2023 18:24:17 +0530 Subject: [PATCH] chore: update all layout selections --- web/components/headers/modules-list.tsx | 50 ++++++++++-------- web/components/project/priority-select.tsx | 2 +- web/constants/cycle.tsx | 5 +- web/constants/page.ts | 37 +++++++++++++ web/layouts/auth-layout/user-wrapper.tsx | 2 +- .../projects/[projectId]/cycles/index.tsx | 40 +++++++------- .../projects/[projectId]/pages/index.tsx | 52 +++++++++---------- 7 files changed, 116 insertions(+), 72 deletions(-) create mode 100644 web/constants/page.ts diff --git a/web/components/headers/modules-list.tsx b/web/components/headers/modules-list.tsx index ec6e88ebd35..1ad827d225e 100644 --- a/web/components/headers/modules-list.tsx +++ b/web/components/headers/modules-list.tsx @@ -9,20 +9,23 @@ import useLocalStorage from "hooks/use-local-storage"; // ui import { Breadcrumbs, BreadcrumbItem, Button, Tooltip } from "@plane/ui"; // helper -import { replaceUnderscoreIfSnakeCase, truncateText } from "helpers/string.helper"; +import { truncateText } from "helpers/string.helper"; -const moduleViewOptions: { type: "list" | "grid" | "gantt_chart"; icon: any }[] = [ +const MODULE_VIEW_LAYOUTS: { key: "list" | "grid" | "gantt_chart"; icon: any; title: string }[] = [ { - type: "list", + key: "list", icon: List, + title: "List layout", }, { - type: "grid", + key: "grid", icon: LayoutGrid, + title: "Grid layout", }, { - type: "gantt_chart", + key: "gantt_chart", icon: GanttChartSquare, + title: "Gantt layout", }, ]; @@ -57,23 +60,26 @@ export const ModulesListHeader: React.FC = observer(() => {
- {moduleViewOptions.map((option) => ( - {replaceUnderscoreIfSnakeCase(option.type)} Layout} - position="bottom" - > - - - ))} +
+ {MODULE_VIEW_LAYOUTS.map((layout) => ( + + + + ))} +
diff --git a/web/constants/cycle.tsx b/web/constants/cycle.tsx index aa0063067aa..697dc36608c 100644 --- a/web/constants/cycle.tsx +++ b/web/constants/cycle.tsx @@ -23,18 +23,21 @@ export const CYCLE_TAB_LIST = [ }, ]; -export const CYCLE_VIEWS = [ +export const CYCLE_VIEW_LAYOUTS = [ { key: "list", icon: List, + title: "List layout", }, { key: "board", icon: LayoutGrid, + title: "Grid layout", }, { key: "gantt", icon: GanttChartSquare, + title: "Gantt layout", }, ]; diff --git a/web/constants/page.ts b/web/constants/page.ts new file mode 100644 index 00000000000..424f1b59c67 --- /dev/null +++ b/web/constants/page.ts @@ -0,0 +1,37 @@ +import { LayoutGrid, List } from "lucide-react"; + +export const PAGE_VIEW_LAYOUTS = [ + { + key: "list", + icon: List, + title: "List layout", + }, + { + key: "detailed", + icon: LayoutGrid, + title: "Detailed layout", + }, +]; + +export const PAGE_TABS_LIST: { key: string; title: string }[] = [ + { + key: "recent", + title: "Recent", + }, + { + key: "all", + title: "All", + }, + { + key: "favorites", + title: "Favorites", + }, + { + key: "created-by-me", + title: "Created by me", + }, + { + key: "created-by-others", + title: "Created by others", + }, +]; diff --git a/web/layouts/auth-layout/user-wrapper.tsx b/web/layouts/auth-layout/user-wrapper.tsx index 7e4f51fb7ca..83cf9e99580 100644 --- a/web/layouts/auth-layout/user-wrapper.tsx +++ b/web/layouts/auth-layout/user-wrapper.tsx @@ -25,7 +25,7 @@ export const UserAuthWrapper: FC = (props) => { if (!currentUser && !error) { return ( -
+
diff --git a/web/pages/[workspaceSlug]/projects/[projectId]/cycles/index.tsx b/web/pages/[workspaceSlug]/projects/[projectId]/cycles/index.tsx index 095cad0e762..21fd5fe8b49 100644 --- a/web/pages/[workspaceSlug]/projects/[projectId]/cycles/index.tsx +++ b/web/pages/[workspaceSlug]/projects/[projectId]/cycles/index.tsx @@ -20,11 +20,9 @@ import emptyCycle from "public/empty-state/cycle.svg"; import { TCycleView, TCycleLayout } from "types"; import { NextPageWithLayout } from "types/app"; // constants -import { CYCLE_TAB_LIST, CYCLE_VIEWS } from "constants/cycle"; +import { CYCLE_TAB_LIST, CYCLE_VIEW_LAYOUTS } from "constants/cycle"; // lib cookie import { setLocalStorage, getLocalStorage } from "lib/local-storage"; -// helpers -import { replaceUnderscoreIfSnakeCase } from "helpers/string.helper"; const ProjectCyclesPage: NextPageWithLayout = observer(() => { const [createModal, setCreateModal] = useState(false); @@ -118,7 +116,7 @@ const ProjectCyclesPage: NextPageWithLayout = observer(() => { handleCurrentView(CYCLE_TAB_LIST[i].key as TCycleView); }} > -
+
{CYCLE_TAB_LIST.map((tab) => ( { ))} - {CYCLE_VIEWS && CYCLE_VIEWS.length > 0 && cycleStore?.cycleView != "active" && ( -
- {CYCLE_VIEWS.map((view) => { - if (view.key === "gantt" && cycleStore?.cycleView === "draft") return null; + {cycleStore?.cycleView != "active" && ( +
+ {CYCLE_VIEW_LAYOUTS.map((layout) => { + if (layout.key === "gantt" && cycleStore?.cycleView === "draft") return null; + return ( - {replaceUnderscoreIfSnakeCase(view.key)} Layout - } - position="bottom" - > + ); diff --git a/web/pages/[workspaceSlug]/projects/[projectId]/pages/index.tsx b/web/pages/[workspaceSlug]/projects/[projectId]/pages/index.tsx index 6d821ce6541..5ad969fde41 100644 --- a/web/pages/[workspaceSlug]/projects/[projectId]/pages/index.tsx +++ b/web/pages/[workspaceSlug]/projects/[projectId]/pages/index.tsx @@ -5,16 +5,18 @@ import { Tab } from "@headlessui/react"; // hooks import useLocalStorage from "hooks/use-local-storage"; import useUserAuth from "hooks/use-user-auth"; -// icons -import { LayoutGrid, List } from "lucide-react"; // layouts import { AppLayout } from "layouts/app-layout"; // components import { RecentPagesList, CreateUpdatePageModal, TPagesListProps } from "components/pages"; import { PagesHeader } from "components/headers"; +// ui +import { Tooltip } from "@plane/ui"; // types import { TPageViewProps } from "types"; import { NextPageWithLayout } from "types/app"; +// constants +import { PAGE_TABS_LIST, PAGE_VIEW_LAYOUTS } from "constants/page"; const AllPagesList = dynamic(() => import("components/pages").then((a) => a.AllPagesList), { ssr: false, @@ -32,8 +34,6 @@ const OtherPagesList = dynamic(() => import("components/pages") ssr: false, }); -const tabsList = ["Recent", "All", "Favorites", "Created by me", "Created by others"]; - const ProjectPagesPage: NextPageWithLayout = () => { const router = useRouter(); const { workspaceSlug, projectId } = router.query; @@ -77,25 +77,25 @@ const ProjectPagesPage: NextPageWithLayout = () => {

Pages

-
- - +
+ {PAGE_VIEW_LAYOUTS.map((layout) => ( + + + + ))}
{ >
- {tabsList.map((tab, index) => ( + {PAGE_TABS_LIST.map((tab) => ( `rounded-full border px-5 py-1.5 text-sm outline-none ${ selected @@ -132,7 +132,7 @@ const ProjectPagesPage: NextPageWithLayout = () => { }` } > - {tab} + {tab.title} ))}