Add merged patch state

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
Sebastian Martinez
2023-04-03 14:59:37 +02:00
parent a6bc6d3c27
commit 5fbbd824ff
3 changed files with 12 additions and 4 deletions
+9 -2
View File
@@ -59,19 +59,26 @@ export interface Merge {
export type PatchState =
| { status: "draft" }
| { status: "open" }
| { status: "archived" };
| { status: "archived" }
| { status: "merged" };
export function groupPatches(patches: Patch[]): {
open: Patch[];
draft: Patch[];
archived: Patch[];
merged: Patch[];
} {
return patches.reduce(
(acc, patch) => {
acc[patch.state.status].push(patch);
return acc;
},
{ open: [] as Patch[], draft: [] as Patch[], archived: [] as Patch[] },
{
open: [] as Patch[],
draft: [] as Patch[],
archived: [] as Patch[],
merged: [] as Patch[],
},
);
}
+2
View File
@@ -31,6 +31,7 @@ export interface ProjectInfo {
open: number;
draft: number;
archived: number;
merged: number;
};
issues: {
open: number;
@@ -137,6 +138,7 @@ export class Project implements ProjectInfo {
open: number;
draft: number;
archived: number;
merged: number;
};
issues: {
open: number;
+1 -2
View File
@@ -22,7 +22,7 @@
let options: Tab<PatchStatus>[];
const stateOptions: PatchStatus[] = ["draft", "open", "archived"];
const stateOptions: PatchStatus[] = ["draft", "open", "archived", "merged"];
$: options = stateOptions.map<{
value: PatchStatus;
title: string;
@@ -32,7 +32,6 @@
title: `${project.patches[s]} ${s}`,
disabled: project.patches[s] === 0,
}));
$: console.log(patches);
$: filteredPatches = groupPatches(patches)[status];
$: sortedPatches = filteredPatches.sort(
({ revisions: [r1] }, { revisions: [r2] }) => r2.timestamp - r1.timestamp,