Skip to content

Commit

Permalink
Merge branch 'main' into buildPresets_&_mapAnalysisState_functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mguetta1 authored Jan 28, 2025
2 parents f628c04 + ea8405e commit e2ddd08
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 34 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# - https://github.com/konveyor/tackle2-ui/pull/1781

# Builder image
FROM registry.access.redhat.com/ubi9/nodejs-20:1-59.1726663413 as builder
FROM registry.access.redhat.com/ubi9/nodejs-20:9.5 as builder

USER 1001
COPY --chown=1001 . .
Expand All @@ -21,7 +21,7 @@ RUN \
npm run dist

# Runner image
FROM registry.access.redhat.com/ubi9/nodejs-20-minimal:1-63
FROM registry.access.redhat.com/ubi9/nodejs-20-minimal:9.5

# Add ps package to allow liveness probe for k8s cluster
# Add tar package to allow copying files with kubectl scp
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 @@ -371,6 +371,9 @@ export const deleteTask = (id: number) => axios.delete<void>(`${TASKS}/${id}`);
export const cancelTask = (id: number) =>
axios.put<void>(`${TASKS}/${id}/cancel`);

export const cancelTasks = (ids: number[]) =>
axios.put<void>(`${TASKS}/cancel?filter=id:(${ids.join("|")})`);

export const getTaskQueue = (addon?: string): Promise<TaskQueue> =>
axios
.get<TaskQueue>(`${TASKS}/report/queue`, { params: { addon } })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import {
import {
TaskStates,
useCancelTaskMutation,
useCancelTasksMutation,
useFetchTaskDashboard,
} from "@app/queries/tasks";
import { useDeleteAssessmentMutation } from "@app/queries/assessments";
Expand Down Expand Up @@ -202,15 +203,42 @@ export const ApplicationsTable: React.FC = () => {
variant: "danger",
});
};
const completedCancelTasks = () => {
pushNotification({
title: "Tasks",
message: "Canceled",
variant: "info",
});
};
const failedCancelTasks = () => {
pushNotification({
title: "Tasks",
message: "Cancelation failed.",
variant: "danger",
});
};

const { mutate: cancelTask } = useCancelTaskMutation(
completedCancelTask,
failedCancelTask
);
const { mutate: cancelTasks } = useCancelTasksMutation(
completedCancelTasks,
failedCancelTasks
);

const cancelAnalysis = (application: DecoratedApplication) => {
const task = application.tasks.currentAnalyzer;
if (task?.id) cancelTask(task.id);
const cancelAnalysis = (
application: DecoratedApplication | DecoratedApplication[]
) => {
if (!Array.isArray(application)) {
const task = application.tasks.currentAnalyzer;
if (task?.id) cancelTask(task.id);
} else {
const tasks = application
.map((app) => app.tasks.currentAnalyzer?.id)
.filter((id): id is number => id !== undefined);
cancelTasks(tasks);
}
};

const isTaskCancellable = (application: DecoratedApplication) => {
Expand Down Expand Up @@ -1196,9 +1224,7 @@ export const ApplicationsTable: React.FC = () => {
onCancel={() => setTasksToCancel([])}
onClose={() => setTasksToCancel([])}
onConfirm={() => {
tasksToCancel.forEach((application) => {
cancelAnalysis(application);
});
cancelAnalysis(tasksToCancel);
setTasksToCancel([]);
}}
/>
Expand Down
29 changes: 6 additions & 23 deletions client/src/app/pages/controls/tags/components/tag-table.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import React from "react";
import { useTranslation } from "react-i18next";
import {
Table,
Thead,
Tr,
Th,
Tbody,
Td,
ActionsColumn,
} from "@patternfly/react-table";
import { Table, Thead, Tr, Th, Tbody, Td } from "@patternfly/react-table";
import { Tag, TagCategory } from "@app/api/models";
import "./tag-table.css";
import { universalComparator } from "@app/utils/utils";
import { ControlTableActionButtons } from "../../ControlTableActionButtons";

export interface TabTableProps {
tagCategory: TagCategory;
Expand Down Expand Up @@ -40,20 +33,10 @@ export const TagTable: React.FC<TabTableProps> = ({
.map((tag) => (
<Tr key={tag.name}>
<Td>{tag.name}</Td>
<Td isActionCell>
<ActionsColumn
items={[
{
title: t("actions.edit"),
onClick: () => onEdit(tag),
},
{
title: t("actions.delete"),
onClick: () => onDelete(tag),
},
]}
/>
</Td>
<ControlTableActionButtons
onEdit={() => onEdit(tag)}
onDelete={() => onDelete(tag)}
/>
</Tr>
))}
</Tbody>
Expand Down
6 changes: 3 additions & 3 deletions client/src/app/pages/controls/tags/tags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import { COLOR_NAMES_BY_HEX_VALUE } from "@app/Constants";
import { TagForm } from "./components/tag-form";
import { TagCategoryForm } from "./components/tag-category-form";
import { getTagCategoryFallbackColor } from "@app/components/labels/item-tag-label/item-tag-label";
import { AppTableActionButtons } from "@app/components/AppTableActionButtons";
import { Color } from "@app/components/Color";
import { ConditionalRender } from "@app/components/ConditionalRender";
import { AppPlaceholder } from "@app/components/AppPlaceholder";
Expand All @@ -57,6 +56,7 @@ import {
import { useLocalTableControls } from "@app/hooks/table-controls";
import { RBAC, controlsWriteScopes, RBAC_TYPE } from "@app/rbac";
import { TagTable } from "./components/tag-table";
import { ControlTableActionButtons } from "../ControlTableActionButtons";

export const Tags: React.FC = () => {
const { t } = useTranslation();
Expand Down Expand Up @@ -385,9 +385,9 @@ export const Tags: React.FC = () => {
>
{tagCategory.tags?.length || 0}
</Td>
<AppTableActionButtons
<ControlTableActionButtons
isDeleteEnabled={!!tagCategory.tags?.length}
tooltipMessage={t(
deleteTooltipMessage={t(
"message.cannotDeleteNonEmptyTagCategory"
)}
onEdit={() => setTagCategoryModalState(tagCategory)}
Expand Down
18 changes: 18 additions & 0 deletions client/src/app/queries/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {

import {
cancelTask,
cancelTasks,
deleteTask,
getServerTasks,
getTaskById,
Expand Down Expand Up @@ -192,6 +193,23 @@ export const useCancelTaskMutation = (
});
};

export const useCancelTasksMutation = (
onSuccess: (statusCode: number) => void,
onError: (err: Error | null) => void
) => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: cancelTasks,
onSuccess: (response) => {
queryClient.invalidateQueries([TasksQueryKey]);
onSuccess && onSuccess(response.status);
},
onError: (err: Error) => {
onError && onError(err);
},
});
};

export const useUpdateTaskMutation = (
onSuccess: (statusCode: number) => void,
onError: (err: Error | null) => void
Expand Down

0 comments on commit e2ddd08

Please sign in to comment.