feat(filters): add 'Has PR' task sidebar filter (#713)
Co-authored-by: Kandev Agent <agent@kandev.dev>
This commit is contained in:
@@ -52,6 +52,14 @@ export const DIMENSION_METAS: DimensionMeta[] = [
|
||||
defaultOp: "is",
|
||||
defaultValue: true,
|
||||
},
|
||||
{
|
||||
dimension: "hasPR",
|
||||
label: "Has PR",
|
||||
valueKind: "boolean",
|
||||
ops: ["is", "is_not"],
|
||||
defaultOp: "is",
|
||||
defaultValue: true,
|
||||
},
|
||||
{
|
||||
dimension: "state",
|
||||
label: "State",
|
||||
|
||||
@@ -21,6 +21,26 @@ describe("applyFilters — basics", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("applyFilters — hasPR", () => {
|
||||
it("filters by hasPR is true (task with linked PR)", () => {
|
||||
const tasks = [task({ id: "a", prInfo: { number: 1, state: "Open" } }), task({ id: "b" })];
|
||||
const out = applyFilters(tasks, [C({ dimension: "hasPR", op: "is", value: true })]);
|
||||
expect(out.map((t) => t.id)).toEqual(["a"]);
|
||||
});
|
||||
|
||||
it("filters by hasPR is false (task without linked PR)", () => {
|
||||
const tasks = [task({ id: "a", prInfo: { number: 1, state: "Open" } }), task({ id: "b" })];
|
||||
const out = applyFilters(tasks, [C({ dimension: "hasPR", op: "is", value: false })]);
|
||||
expect(out.map((t) => t.id)).toEqual(["b"]);
|
||||
});
|
||||
|
||||
it("supports is_not negation on hasPR", () => {
|
||||
const tasks = [task({ id: "a", prInfo: { number: 1, state: "Open" } }), task({ id: "b" })];
|
||||
const out = applyFilters(tasks, [C({ dimension: "hasPR", op: "is_not", value: true })]);
|
||||
expect(out.map((t) => t.id)).toEqual(["b"]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("applyFilters — per-dimension", () => {
|
||||
it("filters by isPRReview is true (watcher-created task)", () => {
|
||||
const tasks = [task({ id: "a", isPRReview: true }), task({ id: "b" })];
|
||||
|
||||
@@ -46,6 +46,7 @@ const dimensionExtractors: Record<FilterDimension, DimensionExtractor> = {
|
||||
const ds = t.diffStats;
|
||||
return !!ds && (ds.additions > 0 || ds.deletions > 0);
|
||||
},
|
||||
hasPR: (t) => !!t.prInfo,
|
||||
isPRReview: (t) => t.isPRReview === true,
|
||||
isIssueWatch: (t) => t.isIssueWatch === true,
|
||||
titleMatch: (t) => t.title ?? "",
|
||||
|
||||
@@ -6,6 +6,7 @@ export type FilterDimension =
|
||||
| "executorType"
|
||||
| "repository"
|
||||
| "hasDiff"
|
||||
| "hasPR"
|
||||
| "isPRReview"
|
||||
| "isIssueWatch"
|
||||
| "titleMatch";
|
||||
|
||||
Reference in New Issue
Block a user