Skip to content

Commit

Permalink
JobList: add Global Filter
Browse files Browse the repository at this point in the history
This will allow to search across all fields of
all rows, in job list.

Signed-off-by: Vallari Agrawal <[email protected]>
  • Loading branch information
VallariAg committed Sep 1, 2024
1 parent ae5f377 commit 5ead246
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/components/JobList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,23 @@ const columns: MRT_ColumnDef<Job>[] = [
);
},
},
{
header: "tasks",
id: "tasks",
accessorFn: (row: Job) => {
const tasks = Object.values(row.tasks || {});
const keys = tasks.map(task => Object.keys(task)[0]);
const result = keys.join(', ');
return result
},
size: 150,
enableColumnFilter: true,
},
{
header: "description",
accessorKey: "description",
size: 120,
},
{
header: "posted",
id: "posted",
Expand Down Expand Up @@ -209,15 +226,17 @@ export default function JobList({ query, sortMode }: JobListProps) {
...options,
columns,
data: data,
rowCount: data.length,
enableFacetedValues: true,
enableGlobalFilter: true,
initialState: {
...options.initialState,
columnVisibility: {
posted: false,
updated: false,
duration: false,
waiting: false,
tasks: false,
description: false,
},
pagination: {
pageIndex: 0,
Expand Down
6 changes: 6 additions & 0 deletions src/lib/paddles.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ export const JobStatuses = [

export type JobStatus = (typeof JobStatuses)[number];

export type Task = {
[key: string]: any;
}

export type Job = {
id?: string;
job_id: number;
tasks: Task;
description: string;
name: string;
suite: string;
branch: string;
Expand Down

0 comments on commit 5ead246

Please sign in to comment.