Files
plane/web/ee/components/projects/page.tsx
Ketan Sharma f387fc1241 [WEB-2484] fix: workspace projects with grouping bugs (#1526)
* Fix on hover problem and add header

* made progress

* fix header done

* fix cleanup code

* fix remove unnexessary file

* fix remove archive from header

* add seperate local storage for archives

* fix related bugs

* code cleanup

* code cleanup

* fix archive colour and no of projects listed

* code cleanup

* made recommended changes
2024-10-24 19:12:57 +05:30

62 lines
2.2 KiB
TypeScript

"use client";
import { useEffect } from "react";
import { observer } from "mobx-react";
import { useParams, usePathname } from "next/navigation";
// components
import { PageHead } from "@/components/core";
// hooks
import Root from "@/components/project/root";
import { useWorkspace } from "@/hooks/store";
// plane web components
import { WorkspaceProjectsRoot } from "@/plane-web/components/projects";
import { useProjectFilter, useWorkspaceFeatures } from "@/plane-web/hooks/store";
import { E_FEATURE_FLAGS, useFlag } from "@/plane-web/hooks/store/use-flag";
import { EWorkspaceFeatures } from "@/plane-web/types/workspace-feature";
import { EProjectLayouts } from "@/plane-web/types/workspace-project-filters";
export const ProjectPageRoot = observer(() => {
// store
const { workspaceSlug } = useParams();
const { currentWorkspace } = useWorkspace();
const { isWorkspaceFeatureEnabled } = useWorkspaceFeatures();
const pathname = usePathname();
const { updateAttributes, updateLayout } = useProjectFilter();
// derived values
const pageTitle = currentWorkspace?.name ? `${currentWorkspace?.name} - Projects` : undefined;
const currentWorkspaceId = currentWorkspace?.id;
const isProjectGroupingEnabled =
isWorkspaceFeatureEnabled(EWorkspaceFeatures.IS_PROJECT_GROUPING_ENABLED) &&
useFlag(workspaceSlug.toString(), E_FEATURE_FLAGS.PROJECT_GROUPING);
const isArchived = pathname.includes("/archives");
useEffect(() => {
if (isArchived) {
updateAttributes(workspaceSlug.toString(), "archived", true, isArchived);
updateLayout(workspaceSlug.toString(), EProjectLayouts.GALLERY, isArchived);
} else {
updateAttributes(workspaceSlug.toString(), "archived", false, isArchived);
}
}, [isArchived, updateAttributes, updateLayout, workspaceSlug]);
if (!currentWorkspaceId || !workspaceSlug) return <></>;
return (
<>
<PageHead title={pageTitle} />
{isProjectGroupingEnabled ? (
<div className="h-full w-full overflow-hidden">
<WorkspaceProjectsRoot
workspaceSlug={workspaceSlug.toString()}
workspaceId={currentWorkspaceId}
isArchived={isArchived}
/>
</div>
) : (
<Root />
)}
</>
);
});