π₯π₯π₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.
TypeScript boardsbug-trackerdjangodockerganttissue-trackerjirajira-alternativekanbanlinearpostgresqlproduct-managementproject-managementproject-planningpythonreactredistypesciptvitework-management
[WEB-2192] fix: order of state groups in space app (#5317)
rahulramesha91142659ca31
diff --git a/apiserver/plane/space/views/state.py b/apiserver/plane/space/views/state.pyindex 853bf022c2..7ffcef5b9d 100644--- a/apiserver/plane/space/views/state.py+++ b/apiserver/plane/space/views/state.py@@ -27,14 +27,11 @@ class ProjectStatesEndpoint(BaseAPIView):status=status.HTTP_404_NOT_FOUND,)- states = (- State.objects.filter(- ~Q(name="Triage"),- workspace__slug=deploy_board.workspace.slug,- project_id=deploy_board.project_id,- )- .values("name", "group", "color", "id")- )+ states = State.objects.filter(+ ~Q(name="Triage"),+ workspace__slug=deploy_board.workspace.slug,+ project_id=deploy_board.project_id,+ ).values("name", "group", "color", "id", "sequence")return Response(states,diff --git a/space/core/components/issues/issue-layouts/utils.tsx b/space/core/components/issues/issue-layouts/utils.tsxindex edb67b4f71..992f6367c9 100644--- a/space/core/components/issues/issue-layouts/utils.tsx+++ b/space/core/components/issues/issue-layouts/utils.tsx@@ -109,10 +109,10 @@ const getModuleColumns = (moduleStore: IIssueModuleStore): IGroupByColumn[] | un};const getStateColumns = (projectState: IStateStore): IGroupByColumn[] | undefined => {- const { states } = projectState;- if (!states) return;+ const { sortedStates } = projectState;+ if (!sortedStates) return;- return states.map((state) => ({+ return sortedStates.map((state) => ({id: state.id,name: state.name,icon: (diff --git a/space/core/store/state.store.ts b/space/core/store/state.store.tsindex 36a0ceaf7a..aff22a22a8 100644--- a/space/core/store/state.store.ts+++ b/space/core/store/state.store.ts@@ -1,11 +1,15 @@-import { action, makeObservable, observable, runInAction } from "mobx";+import clone from "lodash/clone";+import { action, computed, makeObservable, observable, runInAction } from "mobx";import { IState } from "@plane/types";+import { sortStates } from "@/helpers/state.helper";import { StateService } from "@/services/state.service";import { CoreRootStore } from "./root.store";export interface IStateStore {// observablesstates: IState[] | undefined;+ //computed+ sortedStates: IState[] | undefined;// computed actionsgetStateById: (stateId: string | undefined) => IState | undefined;// fetch actions@@ -21,6 +25,8 @@ export class StateStore implements IStateStore {makeObservable(this, {// observablesstates: observable,+ // computed+ sortedStates: computed,// fetch actionfetchStates: action,});@@ -28,6 +34,11 @@ export class StateStore implements IStateStore {this.rootStore = _rootStore;}+ get sortedStates() {+ if (!this.states) return;+ return sortStates(clone(this.states));+ }+getStateById = (stateId: string | undefined) => this.states?.find((state) => state.id === stateId);fetchStates = async (anchor: string) => {diff --git a/space/helpers/state.helper.ts b/space/helpers/state.helper.tsnew file mode 100644index 0000000000..81bffdef96--- /dev/null+++ b/space/helpers/state.helper.ts@@ -0,0 +1,13 @@+import { IState } from "@plane/types";+import { STATE_GROUPS } from "@/constants/state";++export const sortStates = (states: IState[]) => {+ if (!states || states.length === 0) return;++ return states.sort((stateA, stateB) => {+ if (stateA.group === stateB.group) {+ return stateA.sequence - stateB.sequence;+ }+ return Object.keys(STATE_GROUPS).indexOf(stateA.group) - Object.keys(STATE_GROUPS).indexOf(stateB.group);+ });+};