Skip to content

Commit

Permalink
add filter & sort by analysis with no duplicate
Browse files Browse the repository at this point in the history
Signed-off-by: HadasahR <[email protected]>
  • Loading branch information
HadasahR committed Nov 3, 2024
1 parent 1908938 commit d9cc16d
Showing 1 changed file with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ import { useLocalTableControls } from "@app/hooks/table-controls";

// Queries
import { getArchetypeById, getAssessmentsByItemId } from "@app/api/rest";
import { Assessment, Ref } from "@app/api/models";
import { Assessment, Ref, TaskState } from "@app/api/models";
import {
useBulkDeleteApplicationMutation,
useFetchApplications,
Expand All @@ -90,7 +90,7 @@ import { useFetchTagsWithTagItems } from "@app/queries/tags";
import { AnalysisWizard } from "../analysis-wizard/analysis-wizard";
import {
ApplicationAnalysisStatus,
taskStateToAnalyze,
mapAnalysisStateToLabel,
} from "../components/application-analysis-status";
import { ApplicationAssessmentStatus } from "../components/application-assessment-status";
import { ApplicationBusinessService } from "../components/application-business-service";
Expand Down Expand Up @@ -338,7 +338,7 @@ export const ApplicationsTable: React.FC = () => {
sort: "sessionStorage",
},
isLoading: isFetchingApplications,
sortableColumns: ["name", "businessService", "tags", "effort","analysis"],
sortableColumns: ["name", "businessService", "tags", "effort", "analysis"],
initialSort: { columnKey: "name", direction: "asc" },
initialColumns: {
name: { isIdentity: true },
Expand All @@ -348,7 +348,9 @@ 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(ApplicationAnalysisStatus.name as TaskState) ||
"",
}),
filterCategories: [
{
Expand Down Expand Up @@ -503,6 +505,7 @@ export const ApplicationsTable: React.FC = () => {
],
getItemValue: (item) => normalizeRisk(item.risk) ?? "",
},

{
categoryKey: "analysis",
title: t("terms.analysis"),
Expand All @@ -511,12 +514,20 @@ export const ApplicationsTable: React.FC = () => {
t("actions.filterBy", {
what: t("terms.analysis").toLowerCase(),
}) + "...",
selectOptions: Array.from(taskStateToAnalyze).map(
([taskState, displayStatus]) => ({
value: taskState,
label: t(`${displayStatus}`),

selectOptions: applications
.map((a) => {
const value = a?.tasks.currentAnalyzer?.state || "No Task";
const label = mapAnalysisStateToLabel(value as TaskState);
return { value, label };
})
),
.filter((v, i, a) => a.findIndex((v2) => v2.label === v.label) === i)
.sort((a, b) =>
mapAnalysisStateToLabel(a.value as TaskState).localeCompare(
mapAnalysisStateToLabel(b.value as TaskState)
)
),

getItemValue: (item) => item?.tasks.currentAnalyzer?.state || "No Task",
},
],
Expand Down

0 comments on commit d9cc16d

Please sign in to comment.