Skip to content

Commit 30ad160

Browse files
authored
Merge branch 'main' into task-state-checks
2 parents c9209ef + 2bd0d6f commit 30ad160

File tree

6 files changed

+27
-16
lines changed

6 files changed

+27
-16
lines changed

client/src/app/api/models.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -312,16 +312,16 @@ export interface Task {
312312
updateUser?: string;
313313
createTime?: string;
314314

315-
name: string;
316-
kind: string;
317-
addon: string;
318-
extensions: string[];
315+
name?: string;
316+
kind?: string;
317+
addon?: string;
318+
extensions?: string[];
319319
state?: TaskState;
320320
locator?: string;
321321
priority?: number;
322-
policy: TaskPolicy;
323-
ttl: TTL;
324-
data: TaskData;
322+
policy?: TaskPolicy;
323+
ttl?: TTL;
324+
data?: TaskData;
325325
application: Ref;
326326
bucket?: Ref;
327327
pod?: string;
@@ -407,9 +407,10 @@ export interface TaskgroupTask {
407407
}
408408

409409
export interface Taskgroup {
410-
id?: number;
410+
id: number;
411411
name: string;
412-
addon: string;
412+
kind?: string;
413+
addon?: string;
413414
data: TaskData;
414415
tasks: TaskgroupTask[];
415416
}

client/src/app/api/rest.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ export const getTaskQueue = (addon?: string): Promise<TaskQueue> =>
376376
export const updateTask = (task: Partial<Task> & { id: number }) =>
377377
axios.patch<Task>(`${TASKS}/${task.id}`, task);
378378

379-
export const createTaskgroup = (obj: Taskgroup) =>
379+
export const createTaskgroup = (obj: New<Taskgroup>) =>
380380
axios.post<Taskgroup>(TASKGROUPS, obj).then((response) => response.data);
381381

382382
export const submitTaskgroup = (obj: Taskgroup) =>

client/src/app/pages/applications/analysis-wizard/analysis-wizard.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { useTranslation } from "react-i18next";
1414

1515
import {
1616
Application,
17+
New,
1718
TaskData,
1819
Taskgroup,
1920
TaskgroupTask,
@@ -70,9 +71,9 @@ const defaultTaskData: TaskData = {
7071
},
7172
};
7273

73-
export const defaultTaskgroup: Taskgroup = {
74+
export const defaultTaskgroup: New<Taskgroup> = {
7475
name: `taskgroup.analyzer`,
75-
addon: "analyzer",
76+
kind: "analyzer",
7677
data: {
7778
...defaultTaskData,
7879
},

client/src/app/pages/applications/applications-table/applications-table.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export const ApplicationsTable: React.FC = () => {
148148
tasks.find((task: Task) => task.application?.id === application.id);
149149

150150
const { tasks, hasActiveTasks } = useFetchTasks(
151-
{ addon: "analyzer" },
151+
{ kind: "analyzer", addon: "analyzer" },
152152
isAnalyzeModalOpen
153153
);
154154

client/src/app/pages/tasks/tasks-page.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,7 @@ export const TasksPage: React.FC = () => {
164164

165165
const tableControls = useTableControlProps({
166166
...tableControlState,
167-
// task.id is defined as optional
168-
idProperty: "name",
167+
idProperty: "id",
169168
currentPageItems,
170169
totalItemCount,
171170
isLoading: isFetching,

client/src/app/queries/tasks.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121

2222
interface FetchTasksFilters {
2323
addon?: string;
24+
kind?: string;
2425
}
2526

2627
export const TasksQueryKey = "tasks";
@@ -39,7 +40,16 @@ export const useFetchTasks = (
3940
select: (allTasks) => {
4041
const uniqSorted = allTasks
4142
.filter((task) =>
42-
filters?.addon ? filters.addon === task.addon : true
43+
// If there are any tasks with the addon field, we will still need to consider those older
44+
// tasks that do not have the kind field. This is because the kind field was added later and is
45+
// preferred over the addon field.
46+
47+
// The task manager will determine and assign the addon field when the addon is specified and addon isnt
48+
// which will result in both being set.
49+
50+
filters?.kind || filters?.addon
51+
? filters.kind === task.kind || filters.addon === task.addon
52+
: true
4353
)
4454
// sort by application.id (ascending) then createTime (newest to oldest)
4555
.sort((a, b) =>

0 commit comments

Comments
 (0)