Skip to content

Commit f904e98

Browse files
feat: Add machine name search and multi-select reporter filter (Closes #818, Closes #607)
1 parent b394a4c commit f904e98

File tree

3 files changed

+35
-14
lines changed

3 files changed

+35
-14
lines changed

src/components/issues/IssueFilters.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ export function IssueFilters({
159159
params.set("assignee", merged.assignee.join(","));
160160
if (merged.owner && merged.owner.length > 0)
161161
params.set("owner", merged.owner.join(","));
162-
if (merged.reporter) params.set("reporter", merged.reporter);
162+
if (merged.reporter && merged.reporter.length > 0)
163+
params.set("reporter", merged.reporter.join(","));
163164
if (merged.consistency && merged.consistency.length > 0)
164165
params.set("consistency", merged.consistency.join(","));
165166
if (merged.watching) params.set("watching", "true");
@@ -340,15 +341,20 @@ export function IssueFilters({
340341
});
341342
});
342343

343-
// Reporter
344-
if (filters.reporter) {
345-
const user = users.find((u) => u.id === filters.reporter);
344+
filters.reporter?.forEach((id) => {
345+
const user = users.find((u) => u.id === id);
346346
badges.push({
347-
id: `reporter-${filters.reporter}`,
348-
label: `Reporter: ${user?.name ?? filters.reporter}`,
349-
clear: () => pushFilters({ reporter: undefined, page: 1 }),
347+
id: `reporter-${id}`,
348+
label: `Reporter: ${user?.name ?? id}`,
349+
clear: () => {
350+
const current = filters.reporter ?? [];
351+
pushFilters({
352+
reporter: current.filter((v) => v !== id),
353+
page: 1,
354+
});
355+
},
350356
});
351-
}
357+
});
352358

353359
if (filters.createdFrom || filters.createdTo) {
354360
badges.push({
@@ -673,8 +679,8 @@ export function IssueFilters({
673679
/>
674680
<MultiSelect
675681
options={userOptions}
676-
value={filters.reporter ? [filters.reporter] : []}
677-
onChange={(val) => pushFilters({ reporter: val[0], page: 1 })}
682+
value={filters.reporter ?? []}
683+
onChange={(val) => pushFilters({ reporter: val, page: 1 })}
678684
placeholder="Reporter"
679685
data-testid="filter-reporter"
680686
/>

src/lib/issues/filters-queries.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,21 @@ export function buildWhereConditions(filters: IssueFilters): SQL[] {
127127
)
128128
);
129129

130+
// Search in machine names
131+
searchConditions.push(
132+
exists(
133+
db
134+
.select()
135+
.from(machines)
136+
.where(
137+
and(
138+
eq(machines.initials, issues.machineInitials),
139+
ilike(machines.name, search)
140+
)
141+
)
142+
)
143+
);
144+
130145
// Search in issue comments
131146
searchConditions.push(
132147
exists(
@@ -193,8 +208,8 @@ export function buildWhereConditions(filters: IssueFilters): SQL[] {
193208
}
194209
}
195210

196-
if (filters.reporter) {
197-
conditions.push(eq(issues.reportedBy, filters.reporter));
211+
if (filters.reporter && filters.reporter.length > 0) {
212+
conditions.push(inArray(issues.reportedBy, filters.reporter));
198213
}
199214

200215
if (filters.owner && filters.owner.length > 0) {

src/lib/issues/filters.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export interface IssueFilters {
1717
priority?: IssuePriority[] | undefined;
1818
assignee?: string[] | undefined;
1919
owner?: string[] | undefined;
20-
reporter?: string | undefined;
20+
reporter?: string[] | undefined;
2121
consistency?: IssueConsistency[] | undefined;
2222
watching?: boolean | undefined;
2323
createdFrom?: Date | undefined;
@@ -81,7 +81,7 @@ export function parseIssueFilters(params: URLSearchParams): IssueFilters {
8181
const owner = params.get("owner")?.split(",");
8282
if (owner) filters.owner = owner;
8383

84-
const reporter = params.get("reporter");
84+
const reporter = params.get("reporter")?.split(",");
8585
if (reporter) filters.reporter = reporter;
8686

8787
const consistency = parseCommaList(

0 commit comments

Comments
 (0)