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:
@@ -3,8 +3,6 @@ import { observer } from "mobx-react";
|
||||
import { usePopper } from "react-popper";
|
||||
import { Check, ChevronDown, Search } from "lucide-react";
|
||||
import { Combobox } from "@headlessui/react";
|
||||
// types
|
||||
import { IProject } from "@plane/types";
|
||||
// ui
|
||||
import { ComboDropDown } from "@plane/ui";
|
||||
// components
|
||||
@@ -14,6 +12,8 @@ import { cn } from "@/helpers/common.helper";
|
||||
// hooks
|
||||
import { useProject } from "@/hooks/store";
|
||||
import { useDropdown } from "@/hooks/use-dropdown";
|
||||
// plane web types
|
||||
import { TProject } from "@/plane-web/types";
|
||||
// components
|
||||
import { DropdownButton } from "./buttons";
|
||||
// constants
|
||||
@@ -27,7 +27,7 @@ type Props = TDropdownProps & {
|
||||
dropdownArrowClassName?: string;
|
||||
onChange: (val: string) => void;
|
||||
onClose?: () => void;
|
||||
renderCondition?: (project: IProject) => boolean;
|
||||
renderCondition?: (project: TProject) => boolean;
|
||||
value: string | null;
|
||||
renderByDefault?: boolean;
|
||||
};
|
||||
|
||||
@@ -7,8 +7,6 @@ import { observer } from "mobx-react";
|
||||
import { useParams, usePathname } from "next/navigation";
|
||||
import { Briefcase, ChevronRight, Plus } from "lucide-react";
|
||||
import { Disclosure, Transition } from "@headlessui/react";
|
||||
// types
|
||||
import { IProject } from "@plane/types";
|
||||
// ui
|
||||
import { TOAST_TYPE, Tooltip, setToast } from "@plane/ui";
|
||||
// components
|
||||
@@ -20,7 +18,10 @@ import { orderJoinedProjects } from "@/helpers/project.helper";
|
||||
import { copyUrlToClipboard } from "@/helpers/string.helper";
|
||||
// hooks
|
||||
import { useAppTheme, useCommandPalette, useEventTracker, useProject, useUserPermissions } from "@/hooks/store";
|
||||
// plane web constants
|
||||
import { EUserPermissions, EUserPermissionsLevel } from "@/plane-web/constants/user-permissions";
|
||||
// plane web types
|
||||
import { TProject } from "@/plane-web/types";
|
||||
|
||||
export const SidebarProjectsList: FC = observer(() => {
|
||||
// get local storage data for isFavoriteProjectsListOpen and isAllProjectsListOpen
|
||||
@@ -67,7 +68,7 @@ export const SidebarProjectsList: FC = observer(() => {
|
||||
if (!sourceId || !destinationId || !workspaceSlug) return;
|
||||
if (sourceId === destinationId) return;
|
||||
|
||||
const joinedProjectsList: IProject[] = [];
|
||||
const joinedProjectsList: TProject[] = [];
|
||||
joinedProjects.map((projectId) => {
|
||||
const projectDetails = getProjectById(projectId);
|
||||
if (projectDetails) joinedProjectsList.push(projectDetails);
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
import type {
|
||||
GithubRepositoriesResponse,
|
||||
IProject,
|
||||
ISearchIssueResponse,
|
||||
TProjectIssuesSearchParams,
|
||||
} from "@plane/types";
|
||||
// helpers
|
||||
import { API_BASE_URL } from "@/helpers/common.helper";
|
||||
// plane web types
|
||||
import { TProject } from "@/plane-web/types";
|
||||
// services
|
||||
import { APIService } from "@/services/api.service";
|
||||
// types
|
||||
|
||||
export class ProjectService extends APIService {
|
||||
constructor() {
|
||||
super(API_BASE_URL);
|
||||
}
|
||||
|
||||
async createProject(workspaceSlug: string, data: Partial<IProject>): Promise<IProject> {
|
||||
async createProject(workspaceSlug: string, data: Partial<TProject>): Promise<TProject> {
|
||||
return this.post(`/api/workspaces/${workspaceSlug}/projects/`, data)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
@@ -35,7 +35,7 @@ export class ProjectService extends APIService {
|
||||
});
|
||||
}
|
||||
|
||||
async getProjects(workspaceSlug: string): Promise<IProject[]> {
|
||||
async getProjects(workspaceSlug: string): Promise<TProject[]> {
|
||||
return this.get(`/api/workspaces/${workspaceSlug}/projects/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
@@ -43,7 +43,7 @@ export class ProjectService extends APIService {
|
||||
});
|
||||
}
|
||||
|
||||
async getProject(workspaceSlug: string, projectId: string): Promise<IProject> {
|
||||
async getProject(workspaceSlug: string, projectId: string): Promise<TProject> {
|
||||
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
@@ -51,7 +51,7 @@ export class ProjectService extends APIService {
|
||||
});
|
||||
}
|
||||
|
||||
async updateProject(workspaceSlug: string, projectId: string, data: Partial<IProject>): Promise<IProject> {
|
||||
async updateProject(workspaceSlug: string, projectId: string, data: Partial<TProject>): Promise<TProject> {
|
||||
return this.patch(`/api/workspaces/${workspaceSlug}/projects/${projectId}/`, data)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { computedFn } from "mobx-utils";
|
||||
// helpers
|
||||
import { orderProjects, shouldFilterProject } from "@/helpers/project.helper";
|
||||
// services
|
||||
import { TProject } from "@/plane-web/types/projects/projects";
|
||||
import { TProject } from "@/plane-web/types/projects";
|
||||
import { IssueLabelService, IssueService } from "@/services/issue";
|
||||
import { ProjectService, ProjectStateService, ProjectArchiveService } from "@/services/project";
|
||||
// store
|
||||
|
||||
@@ -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