Skip to content

Commit

Permalink
Task Manager
Browse files Browse the repository at this point in the history
Signed-off-by: Radoslaw Szwajkowski <[email protected]>
  • Loading branch information
rszwajko committed Jun 14, 2024
1 parent 3c30a7c commit e3e951e
Show file tree
Hide file tree
Showing 11 changed files with 495 additions and 8 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
15 changes: 13 additions & 2 deletions client/src/app/api/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,15 @@ export type TaskState =
| "Postponed";

export interface Task {
id?: number;
id: number;
createTime?: string;
application: { id: number };
application: Ref;
name: string;
addon: string;
kind?: string;
createUser?: string;
pod?: string;
priority: number;
data: TaskData;
error?: string;
image?: string;
Expand All @@ -319,6 +323,13 @@ export interface Task {
state?: TaskState;
job?: string;
report?: TaskReport;
policy?: TaskPolicy;
}

export interface TaskPolicy {
isolated?: boolean;
preemptEnabled?: boolean;
preemptExempt?: boolean;
}

export interface TaskData {
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: Task) =>
axios.put<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 e3e951e

Please sign in to comment.