Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Improve dev server performance #5962

Open
wants to merge 11 commits into
base: preview
Choose a base branch
from
10 changes: 9 additions & 1 deletion web/app/[workspaceSlug]/(projects)/notifications/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,29 @@

import { useCallback, useEffect } from "react";
import { observer } from "mobx-react";
import dynamic from "next/dynamic";
import { useParams } from "next/navigation";
import useSWR from "swr";
// components
import { LogoSpinner } from "@/components/common";
import { PageHead } from "@/components/core";
import { EmptyState } from "@/components/empty-state";
import { InboxContentRoot } from "@/components/inbox";
import { IssuePeekOverview } from "@/components/issues";
// constants
import { EmptyStateType } from "@/constants/empty-state";
import { ENotificationLoader, ENotificationQueryParamType } from "@/constants/notification";
// hooks
import { useIssueDetail, useUserPermissions, useWorkspace, useWorkspaceNotifications } from "@/hooks/store";
import { useWorkspaceIssueProperties } from "@/hooks/use-workspace-issue-properties";

const IssuePeekOverview = dynamic(
() => import("@/components/issues/peek-overview/root").then((m) => m.IssuePeekOverview),
{
ssr: false,
loading: () => null,
}
);

const WorkspaceDashboardPage = observer(() => {
const { workspaceSlug } = useParams();
// hooks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Head from "next/head";
import { useParams } from "next/navigation";
// components
import { PageHead } from "@/components/core";
import { ProjectLayoutRoot } from "@/components/issues";
import { ProjectLayoutRoot } from "@/components/issues/issue-layouts";
prateekshourya29 marked this conversation as resolved.
Show resolved Hide resolved
// hooks
import { useProject } from "@/hooks/store";

Expand Down
2 changes: 1 addition & 1 deletion web/ce/hooks/use-editor-flagging.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// editor
import { TExtensions } from "@plane/editor";
import type { TExtensions } from "@plane/editor";

/**
* @description extensions disabled in various editors
Expand Down
18 changes: 17 additions & 1 deletion web/core/components/analytics/project-modal/modal.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { useState } from "react";
import { observer } from "mobx-react";
import dynamic from "next/dynamic";
import { Dialog, Transition } from "@headlessui/react";
import { ICycle, IModule, IProject } from "@plane/types";

// components
import { ProjectAnalyticsModalHeader, ProjectAnalyticsModalMainContent } from "@/components/analytics";
// types

type Props = {
Expand All @@ -15,6 +15,22 @@ type Props = {
projectDetails?: IProject | undefined;
};

const ProjectAnalyticsModalHeader = dynamic(
() => import("@/components/analytics").then((m) => m.ProjectAnalyticsModalHeader),
{
ssr: false,
loading: () => null,
}
);
prateekshourya29 marked this conversation as resolved.
Show resolved Hide resolved

const ProjectAnalyticsModalMainContent = dynamic(
() => import("@/components/analytics").then((m) => m.ProjectAnalyticsModalMainContent),
{
ssr: false,
loading: () => null,
}
);

export const ProjectAnalyticsModal: React.FC<Props> = observer((props) => {
const { isOpen, onClose, cycleDetails, moduleDetails, projectDetails } = props;

Expand Down
7 changes: 5 additions & 2 deletions web/core/components/cycles/cycles-view.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { FC } from "react";
import { observer } from "mobx-react";
import dynamic from "next/dynamic";
import Image from "next/image";
// components
import { CyclesList } from "@/components/cycles";
// ui
import { CycleModuleListLayout } from "@/components/ui";
// hooks
Expand All @@ -15,7 +15,10 @@ export interface ICyclesView {
workspaceSlug: string;
projectId: string;
}

const CyclesList = dynamic(() => import("@/components/cycles/list/root").then((m) => m.CyclesList), {
ssr: false,
loading: () => <CycleModuleListLayout />,
});
export const CyclesView: FC<ICyclesView> = observer((props) => {
const { workspaceSlug, projectId } = props;
// store hooks
Expand Down
19 changes: 18 additions & 1 deletion web/core/components/inbox/content/root.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
import { FC, useEffect, useState } from "react";
import { observer } from "mobx-react";
import dynamic from "next/dynamic";
import useSWR from "swr";
import { TNameDescriptionLoader } from "@plane/types";
// components
import { ContentWrapper } from "@plane/ui";
import { InboxIssueActionsHeader, InboxIssueMainContent } from "@/components/inbox";
// hooks
import { IssuePeekOverviewLoader } from "@/components/issues/peek-overview/loader";
import { useProjectInbox, useUser, useUserPermissions } from "@/hooks/store";
import { useAppRouter } from "@/hooks/use-app-router";
import { EUserPermissions, EUserPermissionsLevel } from "@/plane-web/constants/user-permissions";

const InboxIssueActionsHeader = dynamic(
() => import("@/components/inbox/content/inbox-issue-header").then((m) => m.InboxIssueActionsHeader),
{
ssr: false,
loading: () => null,
}
);

const InboxIssueMainContent = dynamic(
() => import("@/components/inbox/content/issue-root").then((m) => m.InboxIssueMainContent),
{
ssr: false,
loading: () => <IssuePeekOverviewLoader removeRoutePeekId={() => null} />,
}
);

type TInboxContentRoot = {
workspaceSlug: string;
projectId: string;
Expand Down
3 changes: 2 additions & 1 deletion web/core/components/issues/filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { EIssueLayoutTypes, EIssueFilterType, EIssuesStoreType } from "@plane/co
import { IIssueDisplayFilterOptions, IIssueDisplayProperties, IIssueFilterOptions } from "@plane/types";
import { Button } from "@plane/ui";
// components
import { ProjectAnalyticsModal } from "@/components/analytics";
import { DisplayFiltersSelection, FiltersDropdown, FilterSelection, LayoutSelection } from "@/components/issues";
// constants
import { ISSUE_STORE_TO_FILTERS_MAP } from "@/constants/issue";
Expand All @@ -17,7 +18,7 @@ import { isIssueFilterActive } from "@/helpers/filter.helper";
import { useLabel, useProjectState, useMember, useIssues } from "@/hooks/store";
// plane web types
import { TProject } from "@/plane-web/types";
import { ProjectAnalyticsModal } from "../analytics";
// local components

type Props = {
currentProjectDetails: TProject | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,75 @@

import { FC, Fragment } from "react";
import { observer } from "mobx-react";
import dynamic from "next/dynamic";
import { useParams } from "next/navigation";
import useSWR from "swr";
// plane constants
import { EIssueLayoutTypes, EIssuesStoreType } from "@plane/constants";
// components
import { Spinner } from "@plane/ui";
import { LogoSpinner } from "@/components/common";

// constants
import {
ListLayout,
CalendarLayout,
BaseGanttRoot,
KanBanLayout,
ProjectAppliedFiltersRoot,
ProjectSpreadsheetLayout,
IssuePeekOverview,
} from "@/components/issues";
CalendarLayoutLoader,
GanttLayoutLoader,
KanbanLayoutLoader,
ListLayoutLoader,
SpreadsheetLayoutLoader,
} from "@/components/ui";

// hooks
import { useIssues } from "@/hooks/store";
import { IssuesStoreContext } from "@/hooks/use-issue-layout-store";

const ProjectAppliedFiltersRoot = dynamic(
() =>
import("@/components/issues/issue-layouts/filters/applied-filters/roots/project-root").then(
(m) => m.ProjectAppliedFiltersRoot
),
{
ssr: false,
loading: () => null,
}
);
const ListLayout = dynamic(
() => import("@/components/issues/issue-layouts/list/roots/project-root").then((m) => m.ListLayout),
{
ssr: false,
loading: () => <ListLayoutLoader />,
}
);
const KanBanLayout = dynamic(
() => import("@/components/issues/issue-layouts/kanban/roots/project-root").then((m) => m.KanBanLayout),
{
ssr: false,
loading: () => <KanbanLayoutLoader />,
}
);
const CalendarLayout = dynamic(
() => import("@/components/issues/issue-layouts/calendar/roots/project-root").then((m) => m.CalendarLayout),
{
ssr: false,
loading: () => <CalendarLayoutLoader />,
}
);
const BaseGanttRoot = dynamic(
() => import("@/components/issues/issue-layouts/gantt/base-gantt-root").then((m) => m.BaseGanttRoot),
{
ssr: false,
loading: () => <GanttLayoutLoader />,
}
);
const ProjectSpreadsheetLayout = dynamic(
() =>
import("@/components/issues/issue-layouts/spreadsheet/roots/project-root").then((m) => m.ProjectSpreadsheetLayout),
{
ssr: false,
loading: () => <SpreadsheetLayoutLoader />,
}
);

const ProjectIssueLayout = (props: { activeLayout: EIssueLayoutTypes | undefined }) => {
switch (props.activeLayout) {
case EIssueLayoutTypes.LIST:
Expand All @@ -38,6 +87,13 @@ const ProjectIssueLayout = (props: { activeLayout: EIssueLayoutTypes | undefined
return null;
}
};
const IssuePeekOverview = dynamic(
() => import("@/components/issues/peek-overview/root").then((m) => m.IssuePeekOverview),
{
ssr: false,
loading: () => null,
}
);

export const ProjectLayoutRoot: FC = observer(() => {
// router
Expand Down
28 changes: 25 additions & 3 deletions web/core/components/page-views/workspace-dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { useEffect } from "react";
import { observer } from "mobx-react";
import dynamic from "next/dynamic";
import { useParams } from "next/navigation";
// components
import { ContentWrapper } from "@plane/ui";
import { DashboardWidgets } from "@/components/dashboard";
// import { DashboardWidgets } from "@/components/dashboard";
import { LogoSpinner } from "@/components/common";
import { EmptyState } from "@/components/empty-state";
import { IssuePeekOverview } from "@/components/issues";
// import { IssuePeekOverview } from "@/components/issues";
import { TourRoot } from "@/components/onboarding";
import { UserGreetingsView } from "@/components/user";
// constants
Expand All @@ -14,9 +16,29 @@ import { PRODUCT_TOUR_COMPLETED } from "@/constants/event-tracker";
// helpers
import { cn } from "@/helpers/common.helper";
// hooks
import { useCommandPalette, useUserProfile, useEventTracker, useDashboard, useProject, useUser } from "@/hooks/store";
import { useCommandPalette, useDashboard, useEventTracker, useProject, useUser, useUserProfile } from "@/hooks/store";
import useSize from "@/hooks/use-window-size";

//@to-do Add loader matching the layout
const DashboardWidgets = dynamic(
() => import("@/components/dashboard/home-dashboard-widgets").then((m) => m.DashboardWidgets),
{
ssr: false,
loading: () => (
<div className="h-full w-full flex items-center justify-center">
<LogoSpinner />
</div>
),
}
);
const IssuePeekOverview = dynamic(
() => import("@/components/issues/peek-overview/root").then((m) => m.IssuePeekOverview),
{
ssr: false,
loading: () => null,
}
);

export const WorkspaceDashboardView = observer(() => {
// store hooks
const {
Expand Down
9 changes: 8 additions & 1 deletion web/core/components/pages/editor/header/options-dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
// ui
import { ArchiveIcon, CustomMenu, type ISvgIcons, TOAST_TYPE, ToggleSwitch, setToast } from "@plane/ui";
// components
import { ExportPageModal } from "@/components/pages";
// helpers
import { copyTextToClipboard, copyUrlToClipboard } from "@/helpers/string.helper";
// hooks
Expand All @@ -29,13 +28,21 @@
import { useQueryParams } from "@/hooks/use-query-params";
// store
import { IPage } from "@/store/pages/page";
import dynamic from "next/dynamic";

Check failure on line 31 in web/core/components/pages/editor/header/options-dropdown.tsx

View workflow job for this annotation

GitHub Actions / lint-web

`next/dynamic` import should occur before import of `next/navigation`

type Props = {
editorRef: EditorRefApi | null;
handleDuplicatePage: () => void;
page: IPage;
};

const ExportPageModal = dynamic(
() => import("@/components/pages/modals/export-page-modal").then((m) => m.ExportPageModal),
{
ssr: false,
loading: () => null,
}
);
export const PageOptionsDropdown: React.FC<Props> = observer((props) => {
const { editorRef, handleDuplicatePage, page } = props;
// router
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use client";
import React, { FC } from "react";
// helpers
import { SidebarHamburgerToggle } from "@/components/core";
import { cn } from "@/helpers/common.helper";
import { SidebarHamburgerToggle } from "../core";

type Props = {
children: React.ReactNode;
Expand Down
2 changes: 1 addition & 1 deletion web/core/hooks/use-workspace-issue-properties.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCycle, useLabel, useModule, useProjectEstimates, useProjectState } from "@/hooks/store";
import useSWR from "swr";

Check failure on line 2 in web/core/hooks/use-workspace-issue-properties.ts

View workflow job for this annotation

GitHub Actions / lint-web

`swr` import should occur before import of `@/hooks/store`
import { useCycle, useProjectEstimates, useLabel, useModule, useProjectState } from "./store";

export const useWorkspaceIssueProperties = (workspaceSlug: string | string[] | undefined) => {
const { fetchWorkspaceLabels } = useLabel();
Expand Down
Loading
Loading