mirror of
https://github.com/makeplane/plane
synced 2025-08-07 19:59:33 +00:00
fix: improvements for project types. (#5857)
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
import sortBy from "lodash/sortBy";
|
||||
// types
|
||||
import { IProject, TProjectDisplayFilters, TProjectFilters, TProjectOrderByOptions } from "@plane/types";
|
||||
// constants
|
||||
import { TProjectDisplayFilters, TProjectFilters, TProjectOrderByOptions } from "@plane/types";
|
||||
// helpers
|
||||
import { getDate } from "@/helpers/date-time.helper";
|
||||
import { satisfiesDateFilter } from "@/helpers/filter.helper";
|
||||
// plane web constants
|
||||
import { EUserPermissions } from "@/plane-web/constants/user-permissions";
|
||||
// types
|
||||
import { TProject } from "@/plane-web/types";
|
||||
|
||||
/**
|
||||
* Updates the sort order of the project.
|
||||
@@ -18,7 +20,7 @@ export const orderJoinedProjects = (
|
||||
sourceIndex: number,
|
||||
destinationIndex: number,
|
||||
currentProjectId: string,
|
||||
joinedProjects: IProject[]
|
||||
joinedProjects: TProject[]
|
||||
): number | undefined => {
|
||||
if (!currentProjectId || sourceIndex < 0 || destinationIndex < 0 || joinedProjects.length <= 0) return undefined;
|
||||
|
||||
@@ -49,21 +51,21 @@ export const projectIdentifierSanitizer = (identifier: string): string =>
|
||||
|
||||
/**
|
||||
* @description Checks if the project should be rendered or not based on the user role
|
||||
* @param {IProject} project
|
||||
* @param {TProject} project
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export const shouldRenderProject = (project: IProject): boolean =>
|
||||
export const shouldRenderProject = (project: TProject): boolean =>
|
||||
!!project.member_role && project.member_role >= EUserPermissions.MEMBER;
|
||||
|
||||
/**
|
||||
* @description filters projects based on the filter
|
||||
* @param {IProject} project
|
||||
* @param {TProject} project
|
||||
* @param {TProjectFilters} filters
|
||||
* @param {TProjectDisplayFilters} displayFilters
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export const shouldFilterProject = (
|
||||
project: IProject,
|
||||
project: TProject,
|
||||
displayFilters: TProjectDisplayFilters,
|
||||
filters: TProjectFilters
|
||||
): boolean => {
|
||||
@@ -94,12 +96,12 @@ export const shouldFilterProject = (
|
||||
|
||||
/**
|
||||
* @description orders projects based on the orderByKey
|
||||
* @param {IProject[]} projects
|
||||
* @param {TProject[]} projects
|
||||
* @param {TProjectOrderByOptions | undefined} orderByKey
|
||||
* @returns {IProject[]}
|
||||
* @returns {TProject[]}
|
||||
*/
|
||||
export const orderProjects = (projects: IProject[], orderByKey: TProjectOrderByOptions | undefined): IProject[] => {
|
||||
let orderedProjects: IProject[] = [];
|
||||
export const orderProjects = (projects: TProject[], orderByKey: TProjectOrderByOptions | undefined): TProject[] => {
|
||||
let orderedProjects: TProject[] = [];
|
||||
if (projects.length === 0) return orderedProjects;
|
||||
|
||||
if (orderByKey === "sort_order") orderedProjects = sortBy(projects, [(p) => p.sort_order]);
|
||||
|
||||
Reference in New Issue
Block a user