Skip to content

Commit

Permalink
Changes after review
Browse files Browse the repository at this point in the history
Signed-off-by: Maayan Hadasi <[email protected]>
  • Loading branch information
mguetta1 committed Jan 29, 2025
1 parent d4a66ed commit ae0d7d5
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 51 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// External libraries
import React, { useState } from "react";
import { AxiosError } from "axios";
import { useHistory } from "react-router-dom";
import { Trans, useTranslation } from "react-i18next";
import dayjs from "dayjs";
import React, { useState } from "react";
import { Trans, useTranslation } from "react-i18next";
import { useHistory } from "react-router-dom";

// @patternfly
import {
Toolbar,
ToolbarContent,
ToolbarItem,
Button,
ToolbarGroup,
ButtonVariant,
DropdownItem,
Modal,
Toolbar,
ToolbarContent,
ToolbarGroup,
ToolbarItem,
Tooltip,
} from "@patternfly/react-core";
import {
Expand All @@ -24,32 +24,31 @@ import {
} from "@patternfly/react-icons";

import {
ActionsColumn,
Table,
Tbody,
Td,
Th,
Thead,
Tr,
Th,
Td,
ActionsColumn,
Tbody,
} from "@patternfly/react-table";

// @app components and utilities
import { Paths } from "@app/Paths";
import { AppPlaceholder } from "@app/components/AppPlaceholder";
import { ConfirmDialog } from "@app/components/ConfirmDialog";
import {
FilterType,
FilterToolbar,
FilterType,
} from "@app/components/FilterToolbar/FilterToolbar";
import { NotificationsContext } from "@app/components/NotificationsContext";
import { SimplePagination } from "@app/components/SimplePagination";
import {
TableHeaderContentWithControls,
ConditionalTableBody,
TableHeaderContentWithControls,
TableRowContentWithControls,
} from "@app/components/TableControls";
import { ToolbarBulkSelector } from "@app/components/ToolbarBulkSelector";
import { ConfirmDialog } from "@app/components/ConfirmDialog";
import { NotificationsContext } from "@app/components/NotificationsContext";
import { formatPath, getAxiosErrorMessage } from "@app/utils/utils";
import { Paths } from "@app/Paths";
import keycloak from "@app/keycloak";
import {
RBAC,
Expand All @@ -64,51 +63,56 @@ import {
tasksReadScopes,
tasksWriteScopes,
} from "@app/rbac";
import { normalizeRisk } from "@app/utils/type-utils";
import { checkAccess } from "@app/utils/rbac-utils";
import { normalizeRisk } from "@app/utils/type-utils";
import {
formatPath,
getAxiosErrorMessage,
universalComparator,
} from "@app/utils/utils";

// Hooks
import { useLocalTableControls } from "@app/hooks/table-controls";

// Queries
import { getArchetypeById, getAssessmentsByItemId } from "@app/api/rest";
import { Assessment, Ref, TaskState } from "@app/api/models";
import { getArchetypeById, getAssessmentsByItemId } from "@app/api/rest";
import {
useBulkDeleteApplicationMutation,
useFetchApplications,
} from "@app/queries/applications";
import { useDeleteAssessmentMutation } from "@app/queries/assessments";
import { useDeleteReviewMutation } from "@app/queries/reviews";
import { useFetchTagsWithTagItems } from "@app/queries/tags";
import {
TaskStates,
useCancelTaskMutation,
useCancelTasksMutation,
useFetchTaskDashboard,
} from "@app/queries/tasks";
import { useDeleteAssessmentMutation } from "@app/queries/assessments";
import { useDeleteReviewMutation } from "@app/queries/reviews";
import { useFetchTagsWithTagItems } from "@app/queries/tags";

// Relative components
import { ApplicationDependenciesForm } from "@app/components/ApplicationDependenciesFormContainer/ApplicationDependenciesForm";
import { ConditionalRender } from "@app/components/ConditionalRender";
import { ConditionalTooltip } from "@app/components/ConditionalTooltip";
import { IconWithLabel } from "@app/components/Icons";
import { KebabDropdown } from "@app/components/KebabDropdown";
import { NoDataEmptyState } from "@app/components/NoDataEmptyState";
import { AnalysisWizard } from "../analysis-wizard/analysis-wizard";
import { TaskGroupProvider } from "../analysis-wizard/components/TaskGroupContext";
import {
ApplicationAnalysisStatus,
taskStateToAnalyze,
mapAnalysisStateToLabel,
} from "../components/application-analysis-status";
import { ApplicationAssessmentStatus } from "../components/application-assessment-status";
import { ApplicationBusinessService } from "../components/application-business-service";
import { ApplicationDependenciesForm } from "@app/components/ApplicationDependenciesFormContainer/ApplicationDependenciesForm";
import { ApplicationDetailDrawer } from "../components/application-detail-drawer/application-detail-drawer";
import { ApplicationFormModal } from "../components/application-form";
import { ApplicationIdentityForm } from "../components/application-identity-form/application-identity-form";
import { ApplicationReviewStatus } from "../components/application-review-status/application-review-status";
import { ConditionalRender } from "@app/components/ConditionalRender";
import { ConditionalTooltip } from "@app/components/ConditionalTooltip";
import { IconWithLabel } from "@app/components/Icons";
import { ImportApplicationsForm } from "../components/import-applications-form";
import { KebabDropdown } from "@app/components/KebabDropdown";
import { ManageColumnsToolbar } from "./components/manage-columns-toolbar";
import { NoDataEmptyState } from "@app/components/NoDataEmptyState";
import { TaskGroupProvider } from "../analysis-wizard/components/TaskGroupContext";
import { ColumnApplicationName } from "./components/column-application-name";
import { ManageColumnsToolbar } from "./components/manage-columns-toolbar";
import {
DecoratedApplication,
useDecoratedApplications,
Expand Down Expand Up @@ -375,7 +379,10 @@ export const ApplicationsTable: React.FC = () => {
businessService: app.businessService?.name || "",
tags: app.tags?.length || 0,
effort: app.effort || 0,
analysis: app.tasks.currentAnalyzer?.state || "",
analysis: mapAnalysisStateToLabel(
(app.tasks.currentAnalyzer?.state as TaskState) || "No task",
t
),
}),
filterCategories: [
{
Expand Down Expand Up @@ -530,7 +537,6 @@ export const ApplicationsTable: React.FC = () => {
],
getItemValue: (item) => normalizeRisk(item.risk) ?? "",
},

{
categoryKey: "analysis",
title: t("terms.analysis"),
Expand All @@ -540,28 +546,17 @@ export const ApplicationsTable: React.FC = () => {
what: t("terms.analysis").toLowerCase(),
}) + "...",

selectOptions: Object.values(applications)
selectOptions: applications
.map((a) => {
let value = a?.tasks.currentAnalyzer?.state || "No Task";

if (value === "No Task") {
value = "No task";
}

let label = taskStateToAnalyze.get(value as TaskState) || value;

if (label === "NotStarted") {
label = "Not started";
}
const value = a.tasks.currentAnalyzer?.state || "No task";
const label = mapAnalysisStateToLabel(value as TaskState, t);
return { value, label };
})
.filter((v, i, a) => a.findIndex((v2) => v2.label === v.label) === i)
.sort((a, b) => a.value.localeCompare(b.value)),

getItemValue: (item) => item?.tasks.currentAnalyzer?.state || "No Task",
.sort((a, b) => universalComparator(a.value, b.value)),
getItemValue: (item) => item.tasks.currentAnalyzer?.state || "No task",
},
],

initialItemsPerPage: 10,
hasActionsColumn: true,
isSelectionEnabled: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ export const ApplicationAnalysisStatus: React.FC<
};

export const mapAnalysisStateToLabel = (
value: TaskState,
state: TaskState,
t: (key: string) => string
) => {
const presetKey: IconedStatusPreset = getTaskStatus(value);
const presetKey: IconedStatusPreset = getTaskStatus(state);
const presets = buildPresetLabels(t);
const label = presets[presetKey]?.label ?? presets.Unknown.label;
return label;
Expand Down

0 comments on commit ae0d7d5

Please sign in to comment.