Skip to content

Commit

Permalink
Add Task Manager
Browse files Browse the repository at this point in the history
Functional changes:
1. create task manager entry in the sidebar navigation list
2. place task page under /tasks route
3. present tasks in a server-filtered table
4. row actions supported: canceling, enable/disable preemption flag
5. use column management to hide optional columns: pod, started,
   terminated

Related features:
1. make id property required in Task type
2. switch task update endpoint to use patch method
3. provide icon-to-state mapping that preserves original state names
   which are required for server filetring

Signed-off-by: Radoslaw Szwajkowski <[email protected]>
  • Loading branch information
rszwajko committed Jun 17, 2024
1 parent d39d7b3 commit 70a7c80
Show file tree
Hide file tree
Showing 11 changed files with 489 additions and 7 deletions.
8 changes: 6 additions & 2 deletions client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@
"createTags": "Create tags",
"cancelAnalysis": "Cancel analysis",
"delete": "Delete",
"disablePreemption": "Disable preemption",
"discardAssessment": "Discard assessment(s)",
"discardReview": "Discard review",
"downloadCsvTemplate": "Download CSV template",
"download": "Download {{what}}",
"duplicate": "Duplicate",
"edit": "Edit",
"enablePreemption": "Enable preemption",
"export": "Export",
"filterBy": "Filter by {{what}}",
"import": "Import",
Expand Down Expand Up @@ -249,7 +251,8 @@
"reports": "Reports",
"migrationWaves": "Migration waves",
"issues": "Issues",
"dependencies": "Dependencies"
"dependencies": "Dependencies",
"tasks": "Task Manager"
},
"terms": {
"accepted": "Accepted",
Expand Down Expand Up @@ -467,7 +470,8 @@
"YAMLTemplate": "YAML template"
},
"titles": {
"archetypeDrawer": "Archetype details"
"archetypeDrawer": "Archetype details",
"taskManager": "Task Manager"
},
"toastr": {
"success": {
Expand Down
1 change: 1 addition & 0 deletions client/src/app/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,5 @@ export enum TablePersistenceKeyPrefix {
issuesRemainingIncidents = "ii",
dependencyApplications = "da",
archetypes = "ar",
tasks = "t",
}
1 change: 1 addition & 0 deletions client/src/app/Paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const DevPaths = {
issuesSingleAppSelected: "/issues/single-app/:applicationId",

dependencies: "/dependencies",
tasks: "/tasks",
} as const;

export type DevPathValues = (typeof DevPaths)[keyof typeof DevPaths];
Expand Down
8 changes: 8 additions & 0 deletions client/src/app/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ const AssessmentSummary = lazy(
"./pages/assessment/components/assessment-summary/assessment-summary-page"
)
);

const TaskManager = lazy(() => import("./pages/tasks/tasks-page"));

export interface IRoute<T> {
path: T;
comp: React.ComponentType<any>;
Expand Down Expand Up @@ -184,6 +187,11 @@ export const devRoutes: IRoute<DevPathValues>[] = [
comp: Archetypes,
exact: false,
},
{
path: Paths.tasks,
comp: TaskManager,
exact: false,
},
];

export const adminRoutes: IRoute<AdminPathValues>[] = [
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/api/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export type TaskState =
| "Postponed";

export interface Task {
id?: number;
id: number;
createUser?: string;
updateUser?: string;
createTime?: string;
Expand Down
3 changes: 3 additions & 0 deletions client/src/app/api/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ export const deleteTask = (id: number) => axios.delete<Task>(`${TASKS}/${id}`);
export const cancelTask = (id: number) =>
axios.put<Task>(`${TASKS}/${id}/cancel`);

export const updateTask = (task: Partial<Task> & { id: number }) =>
axios.patch<Task>(`${TASKS}/${task.id}`, task);

export const createTaskgroup = (obj: Taskgroup) =>
axios.post<Taskgroup>(TASKGROUPS, obj).then((response) => response.data);

Expand Down
1 change: 1 addition & 0 deletions client/src/app/components/Icons/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./OptionalTooltip";
export * from "./IconedStatus";
export * from "./IconWithLabel";
export * from "./taskStateToIcon";
38 changes: 38 additions & 0 deletions client/src/app/components/Icons/taskStateToIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { TaskState } from "@app/api/models";
import React from "react";
import { Icon } from "@patternfly/react-core";
import CheckCircleIcon from "@patternfly/react-icons/dist/esm/icons/check-circle-icon";
import TimesCircleIcon from "@patternfly/react-icons/dist/esm/icons/times-circle-icon";
import InProgressIcon from "@patternfly/react-icons/dist/esm/icons/in-progress-icon";
import ExclamationCircleIcon from "@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon";
import UnknownIcon from "@patternfly/react-icons/dist/esm/icons/unknown-icon";

export const taskStateToIcon = (state?: TaskState) => {
switch (state) {
case "not supported":
case "No task":
return <UnknownIcon />;
case "Canceled":
return <TimesCircleIcon />;
case "Succeeded":
return (
<Icon status={"success"}>
<CheckCircleIcon />
</Icon>
);
case "Failed":
return (
<Icon status={"danger"}>
<ExclamationCircleIcon />
</Icon>
);
case "Pending":
return <InProgressIcon />;
case "Created":
case "Running":
case "Ready":
case "Postponed":
default:
return <></>;
}
};
5 changes: 5 additions & 0 deletions client/src/app/layout/SidebarApp/SidebarApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ export const MigrationSidebar = () => {
</NavItem>
</>
) : null}
<NavItem>
<NavLink to={DevPaths.tasks} activeClassName="pf-m-current">
{t("sidebar.tasks")}
</NavLink>
</NavItem>
</NavList>
</PersonaSidebar>
);
Expand Down
Loading

0 comments on commit 70a7c80

Please sign in to comment.