Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions web/core/components/dropdowns/project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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;
};
Expand Down
7 changes: 4 additions & 3 deletions web/core/components/workspace/sidebar/projects-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions web/core/services/project/project.service.ts
Original file line number Diff line number Diff line change
@@ -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) => {
Expand All @@ -35,23 +35,23 @@ 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) => {
throw error?.response?.data;
});
}

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) => {
throw error?.response?.data;
});
}

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) => {
Expand Down
2 changes: 1 addition & 1 deletion web/core/store/project/project.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 13 additions & 11 deletions web/helpers/project.helper.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;

Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -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]);
Expand Down