forked from github/plane
fix: order by last created (#550)
* feat: block sync * fix: order by last created order
This commit is contained in:
parent
b9e42d116e
commit
37aade5ef6
@ -3,7 +3,7 @@ import useIssuesView from "hooks/use-issues-view";
|
|||||||
// components
|
// components
|
||||||
import { SingleList } from "components/core/list-view/single-list";
|
import { SingleList } from "components/core/list-view/single-list";
|
||||||
// types
|
// types
|
||||||
import { IIssue, IProjectMember, IState, UserAuth } from "types";
|
import { IIssue, IState, UserAuth } from "types";
|
||||||
|
|
||||||
// types
|
// types
|
||||||
type Props = {
|
type Props = {
|
||||||
|
@ -11,10 +11,10 @@ export const GROUP_BY_OPTIONS: Array<{
|
|||||||
|
|
||||||
export const ORDER_BY_OPTIONS: Array<{
|
export const ORDER_BY_OPTIONS: Array<{
|
||||||
name: string;
|
name: string;
|
||||||
key: "created_at" | "updated_at" | "priority" | "sort_order";
|
key: TIssueOrderByOptions;
|
||||||
}> = [
|
}> = [
|
||||||
{ name: "Manual", key: "sort_order" },
|
{ name: "Manual", key: "sort_order" },
|
||||||
{ name: "Last created", key: "created_at" },
|
{ name: "Last created", key: "-created_at" },
|
||||||
{ name: "Last updated", key: "updated_at" },
|
{ name: "Last updated", key: "updated_at" },
|
||||||
{ name: "Priority", key: "priority" },
|
{ name: "Priority", key: "priority" },
|
||||||
];
|
];
|
||||||
@ -37,7 +37,7 @@ export const FILTER_ISSUE_OPTIONS: Array<{
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
import { IIssue, TIssueGroupByOptions } from "types";
|
import { IIssue, TIssueGroupByOptions, TIssueOrderByOptions } from "types";
|
||||||
|
|
||||||
type THandleIssuesMutation = (
|
type THandleIssuesMutation = (
|
||||||
formData: Partial<IIssue>,
|
formData: Partial<IIssue>,
|
||||||
|
@ -10,7 +10,12 @@ import ToastAlert from "components/toast-alert";
|
|||||||
import projectService from "services/project.service";
|
import projectService from "services/project.service";
|
||||||
import viewsService from "services/views.service";
|
import viewsService from "services/views.service";
|
||||||
// types
|
// types
|
||||||
import { IIssueFilterOptions, IProjectMember, TIssueGroupByOptions } from "types";
|
import {
|
||||||
|
IIssueFilterOptions,
|
||||||
|
IProjectMember,
|
||||||
|
TIssueGroupByOptions,
|
||||||
|
TIssueOrderByOptions,
|
||||||
|
} from "types";
|
||||||
// fetch-keys
|
// fetch-keys
|
||||||
import { USER_PROJECT_VIEW, VIEW_DETAILS } from "constants/fetch-keys";
|
import { USER_PROJECT_VIEW, VIEW_DETAILS } from "constants/fetch-keys";
|
||||||
|
|
||||||
@ -19,7 +24,7 @@ export const issueViewContext = createContext<ContextType>({} as ContextType);
|
|||||||
type IssueViewProps = {
|
type IssueViewProps = {
|
||||||
issueView: "list" | "kanban";
|
issueView: "list" | "kanban";
|
||||||
groupByProperty: TIssueGroupByOptions;
|
groupByProperty: TIssueGroupByOptions;
|
||||||
orderBy: "created_at" | "updated_at" | "priority" | "sort_order";
|
orderBy: TIssueOrderByOptions;
|
||||||
showEmptyGroups: boolean;
|
showEmptyGroups: boolean;
|
||||||
filters: IIssueFilterOptions;
|
filters: IIssueFilterOptions;
|
||||||
};
|
};
|
||||||
@ -38,7 +43,7 @@ type ReducerActionType = {
|
|||||||
|
|
||||||
type ContextType = IssueViewProps & {
|
type ContextType = IssueViewProps & {
|
||||||
setGroupByProperty: (property: TIssueGroupByOptions) => void;
|
setGroupByProperty: (property: TIssueGroupByOptions) => void;
|
||||||
setOrderBy: (property: "created_at" | "updated_at" | "priority" | "sort_order") => void;
|
setOrderBy: (property: TIssueOrderByOptions) => void;
|
||||||
setShowEmptyGroups: (property: boolean) => void;
|
setShowEmptyGroups: (property: boolean) => void;
|
||||||
setFilters: (filters: Partial<IIssueFilterOptions>, saveToServer?: boolean) => void;
|
setFilters: (filters: Partial<IIssueFilterOptions>, saveToServer?: boolean) => void;
|
||||||
resetFilterToDefault: () => void;
|
resetFilterToDefault: () => void;
|
||||||
@ -50,7 +55,7 @@ type ContextType = IssueViewProps & {
|
|||||||
type StateType = {
|
type StateType = {
|
||||||
issueView: "list" | "kanban";
|
issueView: "list" | "kanban";
|
||||||
groupByProperty: TIssueGroupByOptions;
|
groupByProperty: TIssueGroupByOptions;
|
||||||
orderBy: "created_at" | "updated_at" | "priority" | "sort_order";
|
orderBy: TIssueOrderByOptions;
|
||||||
showEmptyGroups: boolean;
|
showEmptyGroups: boolean;
|
||||||
filters: IIssueFilterOptions;
|
filters: IIssueFilterOptions;
|
||||||
};
|
};
|
||||||
@ -59,7 +64,7 @@ type ReducerFunctionType = (state: StateType, action: ReducerActionType) => Stat
|
|||||||
export const initialState: StateType = {
|
export const initialState: StateType = {
|
||||||
issueView: "list",
|
issueView: "list",
|
||||||
groupByProperty: null,
|
groupByProperty: null,
|
||||||
orderBy: "created_at",
|
orderBy: "-created_at",
|
||||||
showEmptyGroups: true,
|
showEmptyGroups: true,
|
||||||
filters: {
|
filters: {
|
||||||
type: null,
|
type: null,
|
||||||
@ -111,7 +116,7 @@ export const reducer: ReducerFunctionType = (state, action) => {
|
|||||||
case "SET_ORDER_BY_PROPERTY": {
|
case "SET_ORDER_BY_PROPERTY": {
|
||||||
const newState = {
|
const newState = {
|
||||||
...state,
|
...state,
|
||||||
orderBy: payload?.orderBy || "created_at",
|
orderBy: payload?.orderBy || "-created_at",
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -315,7 +320,7 @@ export const IssueViewContextProvider: React.FC<{ children: React.ReactNode }> =
|
|||||||
);
|
);
|
||||||
|
|
||||||
const setOrderBy = useCallback(
|
const setOrderBy = useCallback(
|
||||||
(property: "created_at" | "updated_at" | "priority" | "sort_order") => {
|
(property: TIssueOrderByOptions) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: "SET_ORDER_BY_PROPERTY",
|
type: "SET_ORDER_BY_PROPERTY",
|
||||||
payload: {
|
payload: {
|
||||||
|
@ -10,21 +10,19 @@ import { issueViewContext } from "contexts/issue-view.context";
|
|||||||
import issuesService from "services/issues.service";
|
import issuesService from "services/issues.service";
|
||||||
import cyclesService from "services/cycles.service";
|
import cyclesService from "services/cycles.service";
|
||||||
import modulesService from "services/modules.service";
|
import modulesService from "services/modules.service";
|
||||||
|
import stateService from "services/state.service";
|
||||||
|
// helpers
|
||||||
|
import { getStatesList } from "helpers/state.helper";
|
||||||
|
// types
|
||||||
|
import type { IIssue } from "types";
|
||||||
// fetch-keys
|
// fetch-keys
|
||||||
import {
|
import {
|
||||||
CYCLE_ISSUES_WITH_PARAMS,
|
CYCLE_ISSUES_WITH_PARAMS,
|
||||||
MODULE_ISSUES_WITH_PARAMS,
|
MODULE_ISSUES_WITH_PARAMS,
|
||||||
PROJECT_ISSUES_LIST_WITH_PARAMS,
|
PROJECT_ISSUES_LIST_WITH_PARAMS,
|
||||||
STATE_LIST,
|
STATE_LIST,
|
||||||
VIEW_ISSUES,
|
|
||||||
} from "constants/fetch-keys";
|
} from "constants/fetch-keys";
|
||||||
|
|
||||||
// types
|
|
||||||
import type { IIssue } from "types";
|
|
||||||
import viewsService from "services/views.service";
|
|
||||||
import stateService from "services/state.service";
|
|
||||||
import { getStatesList } from "helpers/state.helper";
|
|
||||||
|
|
||||||
const useIssuesView = () => {
|
const useIssuesView = () => {
|
||||||
const {
|
const {
|
||||||
issueView,
|
issueView,
|
||||||
@ -128,7 +126,7 @@ const useIssuesView = () => {
|
|||||||
return issuesToGroup ? Object.assign(emptyStatesObject, issuesToGroup) : undefined;
|
return issuesToGroup ? Object.assign(emptyStatesObject, issuesToGroup) : undefined;
|
||||||
|
|
||||||
return issuesToGroup;
|
return issuesToGroup;
|
||||||
}, [projectIssues, cycleIssues, moduleIssues]);
|
}, [projectIssues, cycleIssues, moduleIssues, groupByProperty]);
|
||||||
|
|
||||||
const isEmpty =
|
const isEmpty =
|
||||||
Object.values(groupedByIssues ?? {}).every((group) => group.length === 0) ||
|
Object.values(groupedByIssues ?? {}).every((group) => group.length === 0) ||
|
||||||
|
4
apps/app/types/issues.d.ts
vendored
4
apps/app/types/issues.d.ts
vendored
@ -230,8 +230,10 @@ export interface IIssueFilterOptions {
|
|||||||
|
|
||||||
export type TIssueGroupByOptions = "state" | "priority" | "labels" | "created_by" | null;
|
export type TIssueGroupByOptions = "state" | "priority" | "labels" | "created_by" | null;
|
||||||
|
|
||||||
|
export type TIssueOrderByOptions = "-created_at" | "updated_at" | "priority" | "sort_order";
|
||||||
|
|
||||||
export interface IIssueViewOptions {
|
export interface IIssueViewOptions {
|
||||||
group_by: TIssueGroupByOptions;
|
group_by: TIssueGroupByOptions;
|
||||||
order_by: "created_at" | "updated_at" | "priority" | "sort_order";
|
order_by: TIssueOrderByOptions;
|
||||||
filters: IIssueFilterOptions;
|
filters: IIssueFilterOptions;
|
||||||
}
|
}
|
||||||
|
10
apps/app/types/projects.d.ts
vendored
10
apps/app/types/projects.d.ts
vendored
@ -1,4 +1,10 @@
|
|||||||
import type { IIssueFilterOptions, IUserLite, IWorkspace, TIssueGroupByOptions } from "./";
|
import type {
|
||||||
|
IIssueFilterOptions,
|
||||||
|
IUserLite,
|
||||||
|
IWorkspace,
|
||||||
|
TIssueGroupByOptions,
|
||||||
|
TIssueOrderByOptions,
|
||||||
|
} from "./";
|
||||||
|
|
||||||
export interface IProject {
|
export interface IProject {
|
||||||
cover_image: string | null;
|
cover_image: string | null;
|
||||||
@ -37,7 +43,7 @@ export interface IFavoriteProject {
|
|||||||
type ProjectViewTheme = {
|
type ProjectViewTheme = {
|
||||||
issueView: "list" | "kanban";
|
issueView: "list" | "kanban";
|
||||||
groupByProperty: TIssueGroupByOptions;
|
groupByProperty: TIssueGroupByOptions;
|
||||||
orderBy: "created_at" | "updated_at" | "priority" | "sort_order";
|
orderBy: TIssueOrderByOptions;
|
||||||
filters: IIssueFilterOptions;
|
filters: IIssueFilterOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user