[WEB-578] feat: projects list filtering and ordering (#3926)
* style: project card UI updated * dev: initialize project filter store and types * chore: implemented filtering logic * chore: implemented ordering * chore: my projects filter added * chore: update created at date filter options * refactor: order by dropdown * style: revert project card UI * fix: project card z-index * fix: members filtering * fix: build errors
This commit is contained in:
parent
c3c6ef8830
commit
69e110f4a8
43 changed files with 1452 additions and 186 deletions
|
|
@ -1,25 +1,60 @@
|
|||
import { ReactElement } from "react";
|
||||
import { ReactElement, useCallback } from "react";
|
||||
import { observer } from "mobx-react";
|
||||
// components
|
||||
import { PageHead } from "components/core";
|
||||
import { ProjectsHeader } from "components/headers";
|
||||
import { ProjectCardList } from "components/project";
|
||||
import { ProjectAppliedFiltersList, ProjectCardList } from "components/project";
|
||||
// layouts
|
||||
import { useWorkspace } from "hooks/store";
|
||||
import { useApplication, useProject, useProjectFilter, useWorkspace } from "hooks/store";
|
||||
import { AppLayout } from "layouts/app-layout";
|
||||
// type
|
||||
// helpers
|
||||
import { calculateTotalFilters } from "helpers/filter.helper";
|
||||
// types
|
||||
import { NextPageWithLayout } from "lib/types";
|
||||
import { TProjectFilters } from "@plane/types";
|
||||
|
||||
const ProjectsPage: NextPageWithLayout = observer(() => {
|
||||
// store
|
||||
const {
|
||||
router: { workspaceSlug },
|
||||
} = useApplication();
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { workspaceProjectIds, filteredProjectIds } = useProject();
|
||||
const { currentWorkspaceFilters, clearAllFilters, updateFilters } = useProjectFilter();
|
||||
// derived values
|
||||
const pageTitle = currentWorkspace?.name ? `${currentWorkspace?.name} - Projects` : undefined;
|
||||
|
||||
const handleRemoveFilter = useCallback(
|
||||
(key: keyof TProjectFilters, value: string | null) => {
|
||||
if (!workspaceSlug) return;
|
||||
let newValues = currentWorkspaceFilters?.[key] ?? [];
|
||||
|
||||
if (!value) newValues = [];
|
||||
else newValues = newValues.filter((val) => val !== value);
|
||||
|
||||
updateFilters(workspaceSlug.toString(), { [key]: newValues });
|
||||
},
|
||||
[currentWorkspaceFilters, updateFilters, workspaceSlug]
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageHead title={pageTitle} />
|
||||
<ProjectCardList />
|
||||
<div className="h-full w-full flex flex-col">
|
||||
{calculateTotalFilters(currentWorkspaceFilters ?? {}) !== 0 && (
|
||||
<div className="border-b border-custom-border-200 px-5 py-3">
|
||||
<ProjectAppliedFiltersList
|
||||
appliedFilters={currentWorkspaceFilters ?? {}}
|
||||
handleClearAllFilters={() => clearAllFilters(`${workspaceSlug}`)}
|
||||
handleRemoveFilter={handleRemoveFilter}
|
||||
filteredProjects={filteredProjectIds?.length ?? 0}
|
||||
totalProjects={workspaceProjectIds?.length ?? 0}
|
||||
alwaysAllowEditing
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<ProjectCardList />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue