forked from github/plane
chore: workspace issues types and fetch key added
This commit is contained in:
parent
3a7ea55e81
commit
3440fb962d
@ -21,6 +21,7 @@ type Props = {
|
||||
labels: IIssueLabels[] | undefined;
|
||||
members: IUserLite[] | undefined;
|
||||
states: IState[] | undefined;
|
||||
stateGroup?: string[] | undefined;
|
||||
};
|
||||
|
||||
export const FiltersList: React.FC<Props> = ({
|
||||
|
@ -23,7 +23,7 @@ import { GROUP_CHOICES, PRIORITIES } from "constants/project";
|
||||
import { DATE_FILTER_OPTIONS } from "constants/filters";
|
||||
|
||||
type Props = {
|
||||
filters: Partial<IIssueFilterOptions> | IQuery;
|
||||
filters: Partial<IIssueFilterOptions>;
|
||||
onSelect: (option: any) => void;
|
||||
direction?: "left" | "right";
|
||||
height?: "sm" | "md" | "rg" | "lg";
|
||||
|
@ -17,6 +17,7 @@ import { DangerButton, SecondaryButton } from "components/ui";
|
||||
import { ExclamationTriangleIcon } from "@heroicons/react/24/outline";
|
||||
// types
|
||||
import type { ICurrentUserResponse, IView } from "types";
|
||||
import { IWorkspaceView } from "types/workspace-view";
|
||||
// fetch-keys
|
||||
import { VIEWS_LIST, WORKSPACE_VIEWS_LIST } from "constants/fetch-keys";
|
||||
|
||||
@ -24,7 +25,7 @@ type Props = {
|
||||
isOpen: boolean;
|
||||
viewType: "project" | "workspace";
|
||||
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
||||
data: IView | null;
|
||||
data: IView | IWorkspaceView | null;
|
||||
user: ICurrentUserResponse | undefined;
|
||||
};
|
||||
|
||||
|
@ -21,6 +21,7 @@ import { getStatesList } from "helpers/state.helper";
|
||||
// types
|
||||
import { IQuery, IView } from "types";
|
||||
import issuesService from "services/issues.service";
|
||||
import { IWorkspaceView } from "types/workspace-view";
|
||||
// fetch-keys
|
||||
import { PROJECT_ISSUE_LABELS, STATES_LIST } from "constants/fetch-keys";
|
||||
|
||||
@ -28,7 +29,7 @@ type Props = {
|
||||
handleFormSubmit: (values: IView) => Promise<void>;
|
||||
handleClose: () => void;
|
||||
status: boolean;
|
||||
data?: IView | null;
|
||||
data?: IView | IWorkspaceView | null;
|
||||
preLoadedData?: Partial<IView> | null;
|
||||
};
|
||||
|
||||
@ -96,7 +97,6 @@ export const ViewForm: React.FC<Props> = ({
|
||||
state: null,
|
||||
start_date: null,
|
||||
target_date: null,
|
||||
type: null,
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -15,6 +15,7 @@ import useToast from "hooks/use-toast";
|
||||
import { ViewForm } from "components/views";
|
||||
// types
|
||||
import { ICurrentUserResponse, IView } from "types";
|
||||
import { IWorkspaceView } from "types/workspace-view";
|
||||
// fetch-keys
|
||||
import { VIEWS_LIST, WORKSPACE_VIEWS_LIST } from "constants/fetch-keys";
|
||||
|
||||
@ -22,7 +23,7 @@ type Props = {
|
||||
isOpen: boolean;
|
||||
viewType: "project" | "workspace";
|
||||
handleClose: () => void;
|
||||
data?: IView | null;
|
||||
data?: IView | IWorkspaceView | null;
|
||||
preLoadedData?: Partial<IView> | null;
|
||||
user: ICurrentUserResponse | undefined;
|
||||
};
|
||||
|
@ -12,6 +12,7 @@ import { CustomMenu } from "components/ui";
|
||||
import viewsService from "services/views.service";
|
||||
// types
|
||||
import { IView } from "types";
|
||||
import { IWorkspaceView } from "types/workspace-view";
|
||||
// fetch keys
|
||||
import { VIEWS_LIST } from "constants/fetch-keys";
|
||||
// hooks
|
||||
@ -20,7 +21,7 @@ import useToast from "hooks/use-toast";
|
||||
import { truncateText } from "helpers/string.helper";
|
||||
|
||||
type Props = {
|
||||
view: IView;
|
||||
view: IView | IWorkspaceView;
|
||||
viewType: "project" | "workspace";
|
||||
handleEditView: () => void;
|
||||
handleDeleteView: () => void;
|
||||
|
@ -4,6 +4,7 @@ import { IAnalyticsParams, IJiraMetadata, INotificationParams } from "types";
|
||||
const paramsToKey = (params: any) => {
|
||||
const {
|
||||
state,
|
||||
state_group,
|
||||
priority,
|
||||
assignees,
|
||||
created_by,
|
||||
@ -17,6 +18,7 @@ const paramsToKey = (params: any) => {
|
||||
|
||||
let projectKey = project ? project.split(",") : [];
|
||||
let stateKey = state ? state.split(",") : [];
|
||||
let stateGroupKey = state_group ? state_group.split(",") : [];
|
||||
let priorityKey = priority ? priority.split(",") : [];
|
||||
let assigneesKey = assignees ? assignees.split(",") : [];
|
||||
let createdByKey = created_by ? created_by.split(",") : [];
|
||||
@ -31,12 +33,13 @@ const paramsToKey = (params: any) => {
|
||||
// sorting each keys in ascending order
|
||||
projectKey = projectKey.sort().join("_");
|
||||
stateKey = stateKey.sort().join("_");
|
||||
stateGroupKey = stateGroupKey.sort().join("_");
|
||||
priorityKey = priorityKey.sort().join("_");
|
||||
assigneesKey = assigneesKey.sort().join("_");
|
||||
createdByKey = createdByKey.sort().join("_");
|
||||
labelsKey = labelsKey.sort().join("_");
|
||||
|
||||
return `${projectKey}_${stateKey}_${priorityKey}_${assigneesKey}_${createdByKey}_${type}_${groupBy}_${orderBy}_${labelsKey}_${startDateKey}_${targetDateKey}_${sub_issue}_${startTargetDate}`;
|
||||
return `${projectKey}_${stateGroupKey}_${stateKey}_${priorityKey}_${assigneesKey}_${createdByKey}_${type}_${groupBy}_${orderBy}_${labelsKey}_${startDateKey}_${targetDateKey}_${sub_issue}_${startTargetDate}`;
|
||||
};
|
||||
|
||||
const inboxParamsToKey = (params: any) => {
|
||||
@ -154,14 +157,14 @@ export const PROJECT_DRAFT_ISSUES_LIST_WITH_PARAMS = (projectId: string, params?
|
||||
|
||||
export const WORKSPACE_VIEWS_LIST = (workspaceSlug: string) =>
|
||||
`WORKSPACE_VIEWS_LIST_${workspaceSlug.toUpperCase()}`;
|
||||
export const WORKSPACE_VIEW_DETAILS = (viewId: string) =>
|
||||
`WORKSPACE_VIEW_DETAILS_${viewId.toUpperCase()}`;
|
||||
export const WORKSPACE_VIEW_ISSUES = (viewId: string, params: any) => {
|
||||
if (!params) return `WORKSPACE_VIEW_ISSUES_${viewId.toUpperCase()}`;
|
||||
export const WORKSPACE_VIEW_DETAILS = (workspaceViewId: string) =>
|
||||
`WORKSPACE_VIEW_DETAILS_${workspaceViewId.toUpperCase()}`;
|
||||
export const WORKSPACE_VIEW_ISSUES = (workspaceViewId: string, params: any) => {
|
||||
if (!params) return `WORKSPACE_VIEW_ISSUES_${workspaceViewId.toUpperCase()}`;
|
||||
|
||||
const paramsKey = paramsToKey(params);
|
||||
|
||||
return `WORKSPACE_VIEW_ISSUES_${viewId.toUpperCase()}_${paramsKey.toUpperCase()}`;
|
||||
return `WORKSPACE_VIEW_ISSUES_${workspaceViewId.toUpperCase()}_${paramsKey.toUpperCase()}`;
|
||||
};
|
||||
|
||||
export const PROJECT_ISSUES_DETAILS = (issueId: string) =>
|
||||
|
@ -25,27 +25,25 @@ import { PhotoFilterOutlined } from "@mui/icons-material";
|
||||
import emptyView from "public/empty-state/view.svg";
|
||||
// types
|
||||
import type { NextPage } from "next";
|
||||
import { IView } from "types";
|
||||
import { IWorkspaceView } from "types/workspace-view";
|
||||
// constants
|
||||
import { WORKSPACE_VIEWS_LIST } from "constants/fetch-keys";
|
||||
// helper
|
||||
import { truncateText } from "helpers/string.helper";
|
||||
|
||||
const WorkspaceViews: NextPage = () => {
|
||||
console.log("test");
|
||||
// const [currentView, setCurrentView] = useState("");
|
||||
const [createUpdateViewModal, setCreateUpdateViewModal] = useState(false);
|
||||
const [selectedViewToUpdate, setSelectedViewToUpdate] = useState<IView | null>(null);
|
||||
const [selectedViewToUpdate, setSelectedViewToUpdate] = useState<IWorkspaceView | null>(null);
|
||||
|
||||
const [deleteViewModal, setDeleteViewModal] = useState(false);
|
||||
const [selectedViewToDelete, setSelectedViewToDelete] = useState<IView | null>(null);
|
||||
const [selectedViewToDelete, setSelectedViewToDelete] = useState<IWorkspaceView | null>(null);
|
||||
|
||||
const handleEditView = (view: IView) => {
|
||||
const handleEditView = (view: IWorkspaceView) => {
|
||||
setSelectedViewToUpdate(view);
|
||||
setCreateUpdateViewModal(true);
|
||||
};
|
||||
|
||||
const handleDeleteView = (view: IView) => {
|
||||
const handleDeleteView = (view: IWorkspaceView) => {
|
||||
setSelectedViewToDelete(view);
|
||||
setDeleteViewModal(true);
|
||||
};
|
||||
|
@ -14,9 +14,9 @@ import {
|
||||
ICurrentUserResponse,
|
||||
IWorkspaceBulkInviteFormData,
|
||||
IWorkspaceViewProps,
|
||||
IView,
|
||||
WorkspaceViewIssueParams,
|
||||
IIssueFilterOptions,
|
||||
} from "types";
|
||||
import { IWorkspaceView } from "types/workspace-view";
|
||||
|
||||
class WorkspaceService extends APIService {
|
||||
constructor() {
|
||||
@ -264,7 +264,7 @@ class WorkspaceService extends APIService {
|
||||
});
|
||||
}
|
||||
|
||||
async createView(workspaceSlug: string, data: IView): Promise<any> {
|
||||
async createView(workspaceSlug: string, data: IWorkspaceView): Promise<any> {
|
||||
return this.post(`/api/workspaces/${workspaceSlug}/views/`, data)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
@ -272,7 +272,11 @@ class WorkspaceService extends APIService {
|
||||
});
|
||||
}
|
||||
|
||||
async updateView(workspaceSlug: string, viewId: string, data: Partial<IView>): Promise<any> {
|
||||
async updateView(
|
||||
workspaceSlug: string,
|
||||
viewId: string,
|
||||
data: Partial<IWorkspaceView>
|
||||
): Promise<any> {
|
||||
return this.patch(`/api/workspaces/${workspaceSlug}/views/${viewId}/`, data)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
@ -288,7 +292,7 @@ class WorkspaceService extends APIService {
|
||||
});
|
||||
}
|
||||
|
||||
async getAllViews(workspaceSlug: string): Promise<IView[]> {
|
||||
async getAllViews(workspaceSlug: string): Promise<IWorkspaceView[]> {
|
||||
return this.get(`/api/workspaces/${workspaceSlug}/views/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
@ -296,7 +300,7 @@ class WorkspaceService extends APIService {
|
||||
});
|
||||
}
|
||||
|
||||
async getViewDetails(workspaceSlug: string, viewId: string): Promise<IView> {
|
||||
async getViewDetails(workspaceSlug: string, viewId: string): Promise<IWorkspaceView> {
|
||||
return this.get(`/api/workspaces/${workspaceSlug}/views/${viewId}/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
@ -304,7 +308,7 @@ class WorkspaceService extends APIService {
|
||||
});
|
||||
}
|
||||
|
||||
async getViewIssues(workspaceSlug: string, params: WorkspaceViewIssueParams): Promise<any> {
|
||||
async getViewIssues(workspaceSlug: string, params: IIssueFilterOptions): Promise<any> {
|
||||
return this.get(`/api/workspaces/${workspaceSlug}/issues/`, {
|
||||
params,
|
||||
})
|
||||
|
4
web/types/view-props.d.ts
vendored
4
web/types/view-props.d.ts
vendored
@ -35,9 +35,11 @@ export interface IIssueFilterOptions {
|
||||
priority?: string[] | null;
|
||||
start_date?: string[] | null;
|
||||
state?: string[] | null;
|
||||
state_group?: TStateGroups[] | null;
|
||||
state_group?: string[] | null;
|
||||
subscriber?: string[] | null;
|
||||
target_date?: string[] | null;
|
||||
estimate_point?: string[] | null;
|
||||
projects?: string[] | null;
|
||||
}
|
||||
|
||||
export interface IIssueDisplayFilterOptions {
|
||||
|
6
web/types/views.d.ts
vendored
6
web/types/views.d.ts
vendored
@ -1,3 +1,5 @@
|
||||
import { IIssueFilterOptions } from "./view-props";
|
||||
|
||||
export interface IView {
|
||||
id: string;
|
||||
access: string;
|
||||
@ -8,8 +10,8 @@ export interface IView {
|
||||
updated_by: string;
|
||||
name: string;
|
||||
description: string;
|
||||
query: IQuery;
|
||||
query_data: IQuery;
|
||||
query: IIssueFilterOptions;
|
||||
query_data: IIssueFilterOptions;
|
||||
project: string;
|
||||
workspace: string;
|
||||
}
|
||||
|
21
web/types/workspace-view.d.ts
vendored
Normal file
21
web/types/workspace-view.d.ts
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
import { IIssueFilterOptions } from "./view-props";
|
||||
|
||||
export interface IWorkspaceView {
|
||||
access: string;
|
||||
created_at: Date;
|
||||
created_by: string;
|
||||
description: string;
|
||||
id: string;
|
||||
name: string;
|
||||
query: IIssueFilterOptions;
|
||||
query_data: IIssueFilterOptions;
|
||||
updated_at: Date;
|
||||
updated_by: string;
|
||||
is_favorite: boolean;
|
||||
workspace: string;
|
||||
workspace_detail: {
|
||||
id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
};
|
||||
}
|
15
web/types/workspace.d.ts
vendored
15
web/types/workspace.d.ts
vendored
@ -114,21 +114,6 @@ export interface IWorkspaceSearchResults {
|
||||
};
|
||||
}
|
||||
|
||||
export interface WorkspaceViewIssueParams {
|
||||
assignees: string | undefined;
|
||||
created_by: string | undefined;
|
||||
estimate_point: string | undefined;
|
||||
labels: string | undefined;
|
||||
priority: string | undefined;
|
||||
state: string | undefined;
|
||||
state_group: string | undefined;
|
||||
start_date: string | undefined;
|
||||
target_date: string | undefined;
|
||||
type: "active" | "backlog" | undefined;
|
||||
project: string | undefined;
|
||||
sub_issue: boolean;
|
||||
}
|
||||
|
||||
export interface IProductUpdateResponse {
|
||||
url: string;
|
||||
assets_url: string;
|
||||
|
Loading…
Reference in New Issue
Block a user