Files
plane/web/ee/components/projects/root.tsx

108 lines
3.5 KiB
TypeScript
Raw Permalink Normal View History

[WEB-1986] Feat: Project Grouping (#715) * feat: project grouping migrations * chore: implemented workspace features * chore: updated worksapce feature import in types * chore: project states endpoint * chore: updated migration file * chore: migration file changes * chore: workspace project states * feat: project states * fix: project states * chore: replaced base modal with project base modal in project attribute * chore: removed 002 migration * chore: project attribute migration * chore: project states feature flagged * chore: project state marking as default * chore: code cleanup * chore: updated the project attributes operations in the project crud endpoints * fix: wip * chore: feature flag validation on project create and update. * fix: sync develope * dev: project state feature flag and removed read only fields from serializer * wip * chore: updated project id and project validation when we toggle the workspace project_grouping feature is true * wip: layouts * chore: updated project filter store * wip: default screens * chore: filters update * chore: filters updates * chore: display filter updates * wip: state dropdown * chore: seperated project components for CE * chore: splitted the code for project creation form * fix: code structure optimization * chore: handled project filters * wip: gallery layout for projects * wip: spreadsheet filters * chore: added state and priority filters * fix: project page root moved * fix: synced with preview * dev: updated sorting * wip: role based permissions * fix: header sorting fixed * fix: project types + state filter * fix: optimizations * fix: optimizations * fix: partial feature flagging * fix: project states * fix: css * fix: css foxes * fix: * chore: handled board layout in project grouping * fix: post ce sync changes * fix: gantt permissions + member bugs * fix: mobile header + layout fixes * fix: workspace sidebar + archives * fix: build errors * fix: dark theme handling * fix: archive fix + miscellaneous * Fix: build errors * fix: kandban drag and drop + miscellaneous * fix: kanban drag and drop * fix: imports * fix: drag & drop + project dropdown * fix: merge changes --------- Co-authored-by: pablohashescobar <nikhilschacko@gmail.com> Co-authored-by: NarayanBavisetti <narayan3119@gmail.com> Co-authored-by: gakshita <akshitagoyal1516@gmail.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2024-08-12 21:08:16 +05:30
"use client";
import { FC, useCallback, useEffect } from "react";
[WEB-1986] Feat: Project Grouping (#715) * feat: project grouping migrations * chore: implemented workspace features * chore: updated worksapce feature import in types * chore: project states endpoint * chore: updated migration file * chore: migration file changes * chore: workspace project states * feat: project states * fix: project states * chore: replaced base modal with project base modal in project attribute * chore: removed 002 migration * chore: project attribute migration * chore: project states feature flagged * chore: project state marking as default * chore: code cleanup * chore: updated the project attributes operations in the project crud endpoints * fix: wip * chore: feature flag validation on project create and update. * fix: sync develope * dev: project state feature flag and removed read only fields from serializer * wip * chore: updated project id and project validation when we toggle the workspace project_grouping feature is true * wip: layouts * chore: updated project filter store * wip: default screens * chore: filters update * chore: filters updates * chore: display filter updates * wip: state dropdown * chore: seperated project components for CE * chore: splitted the code for project creation form * fix: code structure optimization * chore: handled project filters * wip: gallery layout for projects * wip: spreadsheet filters * chore: added state and priority filters * fix: project page root moved * fix: synced with preview * dev: updated sorting * wip: role based permissions * fix: header sorting fixed * fix: project types + state filter * fix: optimizations * fix: optimizations * fix: partial feature flagging * fix: project states * fix: css * fix: css foxes * fix: * chore: handled board layout in project grouping * fix: post ce sync changes * fix: gantt permissions + member bugs * fix: mobile header + layout fixes * fix: workspace sidebar + archives * fix: build errors * fix: dark theme handling * fix: archive fix + miscellaneous * Fix: build errors * fix: kandban drag and drop + miscellaneous * fix: kanban drag and drop * fix: imports * fix: drag & drop + project dropdown * fix: merge changes --------- Co-authored-by: pablohashescobar <nikhilschacko@gmail.com> Co-authored-by: NarayanBavisetti <narayan3119@gmail.com> Co-authored-by: gakshita <akshitagoyal1516@gmail.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2024-08-12 21:08:16 +05:30
import { observer } from "mobx-react";
// plane web components
import { usePathname, useSearchParams } from "next/navigation";
2024-09-11 13:13:53 +05:30
import { useProject } from "@/hooks/store";
[WEB-1986] Feat: Project Grouping (#715) * feat: project grouping migrations * chore: implemented workspace features * chore: updated worksapce feature import in types * chore: project states endpoint * chore: updated migration file * chore: migration file changes * chore: workspace project states * feat: project states * fix: project states * chore: replaced base modal with project base modal in project attribute * chore: removed 002 migration * chore: project attribute migration * chore: project states feature flagged * chore: project state marking as default * chore: code cleanup * chore: updated the project attributes operations in the project crud endpoints * fix: wip * chore: feature flag validation on project create and update. * fix: sync develope * dev: project state feature flag and removed read only fields from serializer * wip * chore: updated project id and project validation when we toggle the workspace project_grouping feature is true * wip: layouts * chore: updated project filter store * wip: default screens * chore: filters update * chore: filters updates * chore: display filter updates * wip: state dropdown * chore: seperated project components for CE * chore: splitted the code for project creation form * fix: code structure optimization * chore: handled project filters * wip: gallery layout for projects * wip: spreadsheet filters * chore: added state and priority filters * fix: project page root moved * fix: synced with preview * dev: updated sorting * wip: role based permissions * fix: header sorting fixed * fix: project types + state filter * fix: optimizations * fix: optimizations * fix: partial feature flagging * fix: project states * fix: css * fix: css foxes * fix: * chore: handled board layout in project grouping * fix: post ce sync changes * fix: gantt permissions + member bugs * fix: mobile header + layout fixes * fix: workspace sidebar + archives * fix: build errors * fix: dark theme handling * fix: archive fix + miscellaneous * Fix: build errors * fix: kandban drag and drop + miscellaneous * fix: kanban drag and drop * fix: imports * fix: drag & drop + project dropdown * fix: merge changes --------- Co-authored-by: pablohashescobar <nikhilschacko@gmail.com> Co-authored-by: NarayanBavisetti <narayan3119@gmail.com> Co-authored-by: gakshita <akshitagoyal1516@gmail.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2024-08-12 21:08:16 +05:30
import { ProjectLayoutRoot } from "@/plane-web/components/projects";
// plane web hooks
import { useProjectFilter } from "@/plane-web/hooks/store";
import {
EProjectFilters,
EProjectScope,
TProjectFilters,
TProjectAttributes,
} from "@/plane-web/types/workspace-project-filters";
import { ProjectAppliedFiltersList } from "./applied-filters";
[WEB-1986] Feat: Project Grouping (#715) * feat: project grouping migrations * chore: implemented workspace features * chore: updated worksapce feature import in types * chore: project states endpoint * chore: updated migration file * chore: migration file changes * chore: workspace project states * feat: project states * fix: project states * chore: replaced base modal with project base modal in project attribute * chore: removed 002 migration * chore: project attribute migration * chore: project states feature flagged * chore: project state marking as default * chore: code cleanup * chore: updated the project attributes operations in the project crud endpoints * fix: wip * chore: feature flag validation on project create and update. * fix: sync develope * dev: project state feature flag and removed read only fields from serializer * wip * chore: updated project id and project validation when we toggle the workspace project_grouping feature is true * wip: layouts * chore: updated project filter store * wip: default screens * chore: filters update * chore: filters updates * chore: display filter updates * wip: state dropdown * chore: seperated project components for CE * chore: splitted the code for project creation form * fix: code structure optimization * chore: handled project filters * wip: gallery layout for projects * wip: spreadsheet filters * chore: added state and priority filters * fix: project page root moved * fix: synced with preview * dev: updated sorting * wip: role based permissions * fix: header sorting fixed * fix: project types + state filter * fix: optimizations * fix: optimizations * fix: partial feature flagging * fix: project states * fix: css * fix: css foxes * fix: * chore: handled board layout in project grouping * fix: post ce sync changes * fix: gantt permissions + member bugs * fix: mobile header + layout fixes * fix: workspace sidebar + archives * fix: build errors * fix: dark theme handling * fix: archive fix + miscellaneous * Fix: build errors * fix: kandban drag and drop + miscellaneous * fix: kanban drag and drop * fix: imports * fix: drag & drop + project dropdown * fix: merge changes --------- Co-authored-by: pablohashescobar <nikhilschacko@gmail.com> Co-authored-by: NarayanBavisetti <narayan3119@gmail.com> Co-authored-by: gakshita <akshitagoyal1516@gmail.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2024-08-12 21:08:16 +05:30
type TWorkspaceProjectsRoot = {
workspaceSlug: string;
workspaceId: string;
isArchived?: boolean;
[WEB-1986] Feat: Project Grouping (#715) * feat: project grouping migrations * chore: implemented workspace features * chore: updated worksapce feature import in types * chore: project states endpoint * chore: updated migration file * chore: migration file changes * chore: workspace project states * feat: project states * fix: project states * chore: replaced base modal with project base modal in project attribute * chore: removed 002 migration * chore: project attribute migration * chore: project states feature flagged * chore: project state marking as default * chore: code cleanup * chore: updated the project attributes operations in the project crud endpoints * fix: wip * chore: feature flag validation on project create and update. * fix: sync develope * dev: project state feature flag and removed read only fields from serializer * wip * chore: updated project id and project validation when we toggle the workspace project_grouping feature is true * wip: layouts * chore: updated project filter store * wip: default screens * chore: filters update * chore: filters updates * chore: display filter updates * wip: state dropdown * chore: seperated project components for CE * chore: splitted the code for project creation form * fix: code structure optimization * chore: handled project filters * wip: gallery layout for projects * wip: spreadsheet filters * chore: added state and priority filters * fix: project page root moved * fix: synced with preview * dev: updated sorting * wip: role based permissions * fix: header sorting fixed * fix: project types + state filter * fix: optimizations * fix: optimizations * fix: partial feature flagging * fix: project states * fix: css * fix: css foxes * fix: * chore: handled board layout in project grouping * fix: post ce sync changes * fix: gantt permissions + member bugs * fix: mobile header + layout fixes * fix: workspace sidebar + archives * fix: build errors * fix: dark theme handling * fix: archive fix + miscellaneous * Fix: build errors * fix: kandban drag and drop + miscellaneous * fix: kanban drag and drop * fix: imports * fix: drag & drop + project dropdown * fix: merge changes --------- Co-authored-by: pablohashescobar <nikhilschacko@gmail.com> Co-authored-by: NarayanBavisetti <narayan3119@gmail.com> Co-authored-by: gakshita <akshitagoyal1516@gmail.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2024-08-12 21:08:16 +05:30
};
export const WorkspaceProjectsRoot: FC<TWorkspaceProjectsRoot> = observer((props) => {
const { workspaceSlug, isArchived = false } = props;
//pathname
const pathname = usePathname();
[WEB-1986] Feat: Project Grouping (#715) * feat: project grouping migrations * chore: implemented workspace features * chore: updated worksapce feature import in types * chore: project states endpoint * chore: updated migration file * chore: migration file changes * chore: workspace project states * feat: project states * fix: project states * chore: replaced base modal with project base modal in project attribute * chore: removed 002 migration * chore: project attribute migration * chore: project states feature flagged * chore: project state marking as default * chore: code cleanup * chore: updated the project attributes operations in the project crud endpoints * fix: wip * chore: feature flag validation on project create and update. * fix: sync develope * dev: project state feature flag and removed read only fields from serializer * wip * chore: updated project id and project validation when we toggle the workspace project_grouping feature is true * wip: layouts * chore: updated project filter store * wip: default screens * chore: filters update * chore: filters updates * chore: display filter updates * wip: state dropdown * chore: seperated project components for CE * chore: splitted the code for project creation form * fix: code structure optimization * chore: handled project filters * wip: gallery layout for projects * wip: spreadsheet filters * chore: added state and priority filters * fix: project page root moved * fix: synced with preview * dev: updated sorting * wip: role based permissions * fix: header sorting fixed * fix: project types + state filter * fix: optimizations * fix: optimizations * fix: partial feature flagging * fix: project states * fix: css * fix: css foxes * fix: * chore: handled board layout in project grouping * fix: post ce sync changes * fix: gantt permissions + member bugs * fix: mobile header + layout fixes * fix: workspace sidebar + archives * fix: build errors * fix: dark theme handling * fix: archive fix + miscellaneous * Fix: build errors * fix: kandban drag and drop + miscellaneous * fix: kanban drag and drop * fix: imports * fix: drag & drop + project dropdown * fix: merge changes --------- Co-authored-by: pablohashescobar <nikhilschacko@gmail.com> Co-authored-by: NarayanBavisetti <narayan3119@gmail.com> Co-authored-by: gakshita <akshitagoyal1516@gmail.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2024-08-12 21:08:16 +05:30
// hooks
const {
initWorkspaceFilters,
appliedAttributesCount,
filters,
filteredProjectIds,
clearAllFilters,
updateAttributes,
scopeProjectsCount,
} = useProjectFilter();
const searchParams = useSearchParams();
const showAllProjects = searchParams.get("show-all-projects");
2024-09-11 13:13:53 +05:30
const { loader } = useProject();
[WEB-1986] Feat: Project Grouping (#715) * feat: project grouping migrations * chore: implemented workspace features * chore: updated worksapce feature import in types * chore: project states endpoint * chore: updated migration file * chore: migration file changes * chore: workspace project states * feat: project states * fix: project states * chore: replaced base modal with project base modal in project attribute * chore: removed 002 migration * chore: project attribute migration * chore: project states feature flagged * chore: project state marking as default * chore: code cleanup * chore: updated the project attributes operations in the project crud endpoints * fix: wip * chore: feature flag validation on project create and update. * fix: sync develope * dev: project state feature flag and removed read only fields from serializer * wip * chore: updated project id and project validation when we toggle the workspace project_grouping feature is true * wip: layouts * chore: updated project filter store * wip: default screens * chore: filters update * chore: filters updates * chore: display filter updates * wip: state dropdown * chore: seperated project components for CE * chore: splitted the code for project creation form * fix: code structure optimization * chore: handled project filters * wip: gallery layout for projects * wip: spreadsheet filters * chore: added state and priority filters * fix: project page root moved * fix: synced with preview * dev: updated sorting * wip: role based permissions * fix: header sorting fixed * fix: project types + state filter * fix: optimizations * fix: optimizations * fix: partial feature flagging * fix: project states * fix: css * fix: css foxes * fix: * chore: handled board layout in project grouping * fix: post ce sync changes * fix: gantt permissions + member bugs * fix: mobile header + layout fixes * fix: workspace sidebar + archives * fix: build errors * fix: dark theme handling * fix: archive fix + miscellaneous * Fix: build errors * fix: kandban drag and drop + miscellaneous * fix: kanban drag and drop * fix: imports * fix: drag & drop + project dropdown * fix: merge changes --------- Co-authored-by: pablohashescobar <nikhilschacko@gmail.com> Co-authored-by: NarayanBavisetti <narayan3119@gmail.com> Co-authored-by: gakshita <akshitagoyal1516@gmail.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2024-08-12 21:08:16 +05:30
// derived values
const selectedScope = filters?.scope;
const selectedScopeCount = selectedScope && scopeProjectsCount?.[selectedScope];
const allProjectCount = scopeProjectsCount[EProjectScope.ALL_PROJECTS];
[WEB-1986] Feat: Project Grouping (#715) * feat: project grouping migrations * chore: implemented workspace features * chore: updated worksapce feature import in types * chore: project states endpoint * chore: updated migration file * chore: migration file changes * chore: workspace project states * feat: project states * fix: project states * chore: replaced base modal with project base modal in project attribute * chore: removed 002 migration * chore: project attribute migration * chore: project states feature flagged * chore: project state marking as default * chore: code cleanup * chore: updated the project attributes operations in the project crud endpoints * fix: wip * chore: feature flag validation on project create and update. * fix: sync develope * dev: project state feature flag and removed read only fields from serializer * wip * chore: updated project id and project validation when we toggle the workspace project_grouping feature is true * wip: layouts * chore: updated project filter store * wip: default screens * chore: filters update * chore: filters updates * chore: display filter updates * wip: state dropdown * chore: seperated project components for CE * chore: splitted the code for project creation form * fix: code structure optimization * chore: handled project filters * wip: gallery layout for projects * wip: spreadsheet filters * chore: added state and priority filters * fix: project page root moved * fix: synced with preview * dev: updated sorting * wip: role based permissions * fix: header sorting fixed * fix: project types + state filter * fix: optimizations * fix: optimizations * fix: partial feature flagging * fix: project states * fix: css * fix: css foxes * fix: * chore: handled board layout in project grouping * fix: post ce sync changes * fix: gantt permissions + member bugs * fix: mobile header + layout fixes * fix: workspace sidebar + archives * fix: build errors * fix: dark theme handling * fix: archive fix + miscellaneous * Fix: build errors * fix: kandban drag and drop + miscellaneous * fix: kanban drag and drop * fix: imports * fix: drag & drop + project dropdown * fix: merge changes --------- Co-authored-by: pablohashescobar <nikhilschacko@gmail.com> Co-authored-by: NarayanBavisetti <narayan3119@gmail.com> Co-authored-by: gakshita <akshitagoyal1516@gmail.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2024-08-12 21:08:16 +05:30
useEffect(() => {
2024-09-11 13:13:53 +05:30
if (workspaceSlug) {
let filtersToInit = [EProjectFilters.LAYOUT, EProjectFilters.ATTRIBUTES, EProjectFilters.DISPLAY_FILTERS];
filtersToInit = loader ? filtersToInit : [EProjectFilters.SCOPE, ...filtersToInit];
initWorkspaceFilters(
workspaceSlug,
typeof showAllProjects === "string"
? showAllProjects === "true"
? EProjectScope.ALL_PROJECTS
: EProjectScope.MY_PROJECTS
2024-09-11 13:13:53 +05:30
: undefined,
filtersToInit,
isArchived
);
2024-09-11 13:13:53 +05:30
}
}, [workspaceSlug, initWorkspaceFilters, pathname, showAllProjects, loader, isArchived]);
const handleClearAllFilters = useCallback(() => {
if (!workspaceSlug) return;
clearAllFilters(workspaceSlug, isArchived);
}, [clearAllFilters, isArchived, workspaceSlug]);
// TProjectAttributes has arrays of different types, value is an element of that array
const handleRemoveFilter = useCallback(
<T extends keyof TProjectAttributes>(key: T, value: any) => {
if (!workspaceSlug || !filters) return;
if (!value) {
updateAttributes(workspaceSlug, key, [] as unknown as TProjectAttributes[T], isArchived);
return;
}
let newValues = filters.attributes[key];
if (Array.isArray(newValues)) {
newValues = newValues.filter((val) => val !== value) as TProjectAttributes[T];
updateAttributes(workspaceSlug, key, newValues, isArchived);
} else if (typeof value === "boolean") {
updateAttributes(workspaceSlug, "archived", !value, isArchived);
}
},
[filters, isArchived, updateAttributes, workspaceSlug]
);
[WEB-1986] Feat: Project Grouping (#715) * feat: project grouping migrations * chore: implemented workspace features * chore: updated worksapce feature import in types * chore: project states endpoint * chore: updated migration file * chore: migration file changes * chore: workspace project states * feat: project states * fix: project states * chore: replaced base modal with project base modal in project attribute * chore: removed 002 migration * chore: project attribute migration * chore: project states feature flagged * chore: project state marking as default * chore: code cleanup * chore: updated the project attributes operations in the project crud endpoints * fix: wip * chore: feature flag validation on project create and update. * fix: sync develope * dev: project state feature flag and removed read only fields from serializer * wip * chore: updated project id and project validation when we toggle the workspace project_grouping feature is true * wip: layouts * chore: updated project filter store * wip: default screens * chore: filters update * chore: filters updates * chore: display filter updates * wip: state dropdown * chore: seperated project components for CE * chore: splitted the code for project creation form * fix: code structure optimization * chore: handled project filters * wip: gallery layout for projects * wip: spreadsheet filters * chore: added state and priority filters * fix: project page root moved * fix: synced with preview * dev: updated sorting * wip: role based permissions * fix: header sorting fixed * fix: project types + state filter * fix: optimizations * fix: optimizations * fix: partial feature flagging * fix: project states * fix: css * fix: css foxes * fix: * chore: handled board layout in project grouping * fix: post ce sync changes * fix: gantt permissions + member bugs * fix: mobile header + layout fixes * fix: workspace sidebar + archives * fix: build errors * fix: dark theme handling * fix: archive fix + miscellaneous * Fix: build errors * fix: kandban drag and drop + miscellaneous * fix: kanban drag and drop * fix: imports * fix: drag & drop + project dropdown * fix: merge changes --------- Co-authored-by: pablohashescobar <nikhilschacko@gmail.com> Co-authored-by: NarayanBavisetti <narayan3119@gmail.com> Co-authored-by: gakshita <akshitagoyal1516@gmail.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2024-08-12 21:08:16 +05:30
return (
<div className="flex h-full w-full flex-col">
{appliedAttributesCount > 0 && (
<ProjectAppliedFiltersList
appliedFilters={filters ?? ({} as TProjectFilters)}
handleClearAllFilters={handleClearAllFilters}
filteredProjects={filteredProjectIds?.length ?? 0}
totalProjects={selectedScopeCount ?? allProjectCount}
handleRemoveFilter={handleRemoveFilter}
alwaysAllowEditing
/>
)}
<ProjectLayoutRoot />
</div>
);
[WEB-1986] Feat: Project Grouping (#715) * feat: project grouping migrations * chore: implemented workspace features * chore: updated worksapce feature import in types * chore: project states endpoint * chore: updated migration file * chore: migration file changes * chore: workspace project states * feat: project states * fix: project states * chore: replaced base modal with project base modal in project attribute * chore: removed 002 migration * chore: project attribute migration * chore: project states feature flagged * chore: project state marking as default * chore: code cleanup * chore: updated the project attributes operations in the project crud endpoints * fix: wip * chore: feature flag validation on project create and update. * fix: sync develope * dev: project state feature flag and removed read only fields from serializer * wip * chore: updated project id and project validation when we toggle the workspace project_grouping feature is true * wip: layouts * chore: updated project filter store * wip: default screens * chore: filters update * chore: filters updates * chore: display filter updates * wip: state dropdown * chore: seperated project components for CE * chore: splitted the code for project creation form * fix: code structure optimization * chore: handled project filters * wip: gallery layout for projects * wip: spreadsheet filters * chore: added state and priority filters * fix: project page root moved * fix: synced with preview * dev: updated sorting * wip: role based permissions * fix: header sorting fixed * fix: project types + state filter * fix: optimizations * fix: optimizations * fix: partial feature flagging * fix: project states * fix: css * fix: css foxes * fix: * chore: handled board layout in project grouping * fix: post ce sync changes * fix: gantt permissions + member bugs * fix: mobile header + layout fixes * fix: workspace sidebar + archives * fix: build errors * fix: dark theme handling * fix: archive fix + miscellaneous * Fix: build errors * fix: kandban drag and drop + miscellaneous * fix: kanban drag and drop * fix: imports * fix: drag & drop + project dropdown * fix: merge changes --------- Co-authored-by: pablohashescobar <nikhilschacko@gmail.com> Co-authored-by: NarayanBavisetti <narayan3119@gmail.com> Co-authored-by: gakshita <akshitagoyal1516@gmail.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2024-08-12 21:08:16 +05:30
});