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
|
||||
import { SingleList } from "components/core/list-view/single-list";
|
||||
// types
|
||||
import { IIssue, IProjectMember, IState, UserAuth } from "types";
|
||||
import { IIssue, IState, UserAuth } from "types";
|
||||
|
||||
// types
|
||||
type Props = {
|
||||
|
@ -11,10 +11,10 @@ export const GROUP_BY_OPTIONS: Array<{
|
||||
|
||||
export const ORDER_BY_OPTIONS: Array<{
|
||||
name: string;
|
||||
key: "created_at" | "updated_at" | "priority" | "sort_order";
|
||||
key: TIssueOrderByOptions;
|
||||
}> = [
|
||||
{ name: "Manual", key: "sort_order" },
|
||||
{ name: "Last created", key: "created_at" },
|
||||
{ name: "Last created", key: "-created_at" },
|
||||
{ name: "Last updated", key: "updated_at" },
|
||||
{ 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 = (
|
||||
formData: Partial<IIssue>,
|
||||
|
@ -10,7 +10,12 @@ import ToastAlert from "components/toast-alert";
|
||||
import projectService from "services/project.service";
|
||||
import viewsService from "services/views.service";
|
||||
// types
|
||||
import { IIssueFilterOptions, IProjectMember, TIssueGroupByOptions } from "types";
|
||||
import {
|
||||
IIssueFilterOptions,
|
||||
IProjectMember,
|
||||
TIssueGroupByOptions,
|
||||
TIssueOrderByOptions,
|
||||
} from "types";
|
||||
// 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 = {
|
||||
issueView: "list" | "kanban";
|
||||
groupByProperty: TIssueGroupByOptions;
|
||||
orderBy: "created_at" | "updated_at" | "priority" | "sort_order";
|
||||
orderBy: TIssueOrderByOptions;
|
||||
showEmptyGroups: boolean;
|
||||
filters: IIssueFilterOptions;
|
||||
};
|
||||
@ -38,7 +43,7 @@ type ReducerActionType = {
|
||||
|
||||
type ContextType = IssueViewProps & {
|
||||
setGroupByProperty: (property: TIssueGroupByOptions) => void;
|
||||
setOrderBy: (property: "created_at" | "updated_at" | "priority" | "sort_order") => void;
|
||||
setOrderBy: (property: TIssueOrderByOptions) => void;
|
||||
setShowEmptyGroups: (property: boolean) => void;
|
||||
setFilters: (filters: Partial<IIssueFilterOptions>, saveToServer?: boolean) => void;
|
||||
resetFilterToDefault: () => void;
|
||||
@ -50,7 +55,7 @@ type ContextType = IssueViewProps & {
|
||||
type StateType = {
|
||||
issueView: "list" | "kanban";
|
||||
groupByProperty: TIssueGroupByOptions;
|
||||
orderBy: "created_at" | "updated_at" | "priority" | "sort_order";
|
||||
orderBy: TIssueOrderByOptions;
|
||||
showEmptyGroups: boolean;
|
||||
filters: IIssueFilterOptions;
|
||||
};
|
||||
@ -59,7 +64,7 @@ type ReducerFunctionType = (state: StateType, action: ReducerActionType) => Stat
|
||||
export const initialState: StateType = {
|
||||
issueView: "list",
|
||||
groupByProperty: null,
|
||||
orderBy: "created_at",
|
||||
orderBy: "-created_at",
|
||||
showEmptyGroups: true,
|
||||
filters: {
|
||||
type: null,
|
||||
@ -111,7 +116,7 @@ export const reducer: ReducerFunctionType = (state, action) => {
|
||||
case "SET_ORDER_BY_PROPERTY": {
|
||||
const newState = {
|
||||
...state,
|
||||
orderBy: payload?.orderBy || "created_at",
|
||||
orderBy: payload?.orderBy || "-created_at",
|
||||
};
|
||||
|
||||
return {
|
||||
@ -315,7 +320,7 @@ export const IssueViewContextProvider: React.FC<{ children: React.ReactNode }> =
|
||||
);
|
||||
|
||||
const setOrderBy = useCallback(
|
||||
(property: "created_at" | "updated_at" | "priority" | "sort_order") => {
|
||||
(property: TIssueOrderByOptions) => {
|
||||
dispatch({
|
||||
type: "SET_ORDER_BY_PROPERTY",
|
||||
payload: {
|
||||
|
@ -10,21 +10,19 @@ import { issueViewContext } from "contexts/issue-view.context";
|
||||
import issuesService from "services/issues.service";
|
||||
import cyclesService from "services/cycles.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
|
||||
import {
|
||||
CYCLE_ISSUES_WITH_PARAMS,
|
||||
MODULE_ISSUES_WITH_PARAMS,
|
||||
PROJECT_ISSUES_LIST_WITH_PARAMS,
|
||||
STATE_LIST,
|
||||
VIEW_ISSUES,
|
||||
} 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 {
|
||||
issueView,
|
||||
@ -128,7 +126,7 @@ const useIssuesView = () => {
|
||||
return issuesToGroup ? Object.assign(emptyStatesObject, issuesToGroup) : undefined;
|
||||
|
||||
return issuesToGroup;
|
||||
}, [projectIssues, cycleIssues, moduleIssues]);
|
||||
}, [projectIssues, cycleIssues, moduleIssues, groupByProperty]);
|
||||
|
||||
const isEmpty =
|
||||
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 TIssueOrderByOptions = "-created_at" | "updated_at" | "priority" | "sort_order";
|
||||
|
||||
export interface IIssueViewOptions {
|
||||
group_by: TIssueGroupByOptions;
|
||||
order_by: "created_at" | "updated_at" | "priority" | "sort_order";
|
||||
order_by: TIssueOrderByOptions;
|
||||
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 {
|
||||
cover_image: string | null;
|
||||
@ -37,7 +43,7 @@ export interface IFavoriteProject {
|
||||
type ProjectViewTheme = {
|
||||
issueView: "list" | "kanban";
|
||||
groupByProperty: TIssueGroupByOptions;
|
||||
orderBy: "created_at" | "updated_at" | "priority" | "sort_order";
|
||||
orderBy: TIssueOrderByOptions;
|
||||
filters: IIssueFilterOptions;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user