From 656a1f92a846ebb6450e493ed297a27c151a9c51 Mon Sep 17 00:00:00 2001 From: HadasahR Date: Wed, 18 Sep 2024 12:08:41 +0300 Subject: [PATCH 1/3] adding filter by analysis to Application inventory table Signed-off-by: HadasahR --- .../applications-table/applications-table.tsx | 22 ++++++++++++++++++- .../application-analysis-status.tsx | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/client/src/app/pages/applications/applications-table/applications-table.tsx b/client/src/app/pages/applications/applications-table/applications-table.tsx index d102d69a2a..6f023228a2 100644 --- a/client/src/app/pages/applications/applications-table/applications-table.tsx +++ b/client/src/app/pages/applications/applications-table/applications-table.tsx @@ -88,7 +88,10 @@ import { useFetchTagsWithTagItems } from "@app/queries/tags"; // Relative components import { AnalysisWizard } from "../analysis-wizard/analysis-wizard"; -import { ApplicationAnalysisStatus } from "../components/application-analysis-status"; +import { + ApplicationAnalysisStatus, + taskStateToAnalyze, +} 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"; @@ -499,7 +502,24 @@ export const ApplicationsTable: React.FC = () => { ], getItemValue: (item) => normalizeRisk(item.risk) ?? "", }, + { + categoryKey: "analysis", + title: t("terms.analysis"), + type: FilterType.multiselect, + placeholderText: + t("actions.filterBy", { + what: t("terms.analysis").toLowerCase(), + }) + "...", + selectOptions: Array.from(taskStateToAnalyze).map( + ([taskState, displayStatus]) => ({ + value: taskState, + label: t(`${displayStatus}`), + }) + ), + getItemValue: (item) => item?.tasks.currentAnalyzer?.state || "No Task", + }, ], + initialItemsPerPage: 10, hasActionsColumn: true, isSelectionEnabled: true, diff --git a/client/src/app/pages/applications/components/application-analysis-status.tsx b/client/src/app/pages/applications/components/application-analysis-status.tsx index 4462aacaff..94c1e79537 100644 --- a/client/src/app/pages/applications/components/application-analysis-status.tsx +++ b/client/src/app/pages/applications/components/application-analysis-status.tsx @@ -7,7 +7,7 @@ export interface ApplicationAnalysisStatusProps { state: TaskState; } -const taskStateToAnalyze: Map = new Map([ +export const taskStateToAnalyze: Map = new Map([ ["not supported", "Canceled"], ["Canceled", "Canceled"], ["Created", "Scheduled"], From 392aa0d7eff203f1901f318f26815548118130b9 Mon Sep 17 00:00:00 2001 From: HadasahR Date: Sun, 22 Sep 2024 12:25:50 +0300 Subject: [PATCH 2/3] add sort to analysis Signed-off-by: HadasahR --- .../applications/applications-table/applications-table.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/src/app/pages/applications/applications-table/applications-table.tsx b/client/src/app/pages/applications/applications-table/applications-table.tsx index 6f023228a2..018a684c1b 100644 --- a/client/src/app/pages/applications/applications-table/applications-table.tsx +++ b/client/src/app/pages/applications/applications-table/applications-table.tsx @@ -338,7 +338,7 @@ export const ApplicationsTable: React.FC = () => { sort: "sessionStorage", }, isLoading: isFetchingApplications, - sortableColumns: ["name", "businessService", "tags", "effort"], + sortableColumns: ["name", "businessService", "tags", "effort","analysis"], initialSort: { columnKey: "name", direction: "asc" }, initialColumns: { name: { isIdentity: true }, @@ -348,6 +348,7 @@ export const ApplicationsTable: React.FC = () => { businessService: app.businessService?.name || "", tags: app.tags?.length || 0, effort: app.effort || 0, + analysis:app.tasks.currentAnalyzer?.state || "" }), filterCategories: [ { From 9d163dbd2ead96a059575139b5c9ca94e853cbf3 Mon Sep 17 00:00:00 2001 From: HadasahR Date: Wed, 9 Oct 2024 09:56:56 +0300 Subject: [PATCH 3/3] add filter & sort by analysis with no duplicate Signed-off-by: HadasahR --- .../applications-table/applications-table.tsx | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/client/src/app/pages/applications/applications-table/applications-table.tsx b/client/src/app/pages/applications/applications-table/applications-table.tsx index 018a684c1b..b379a42e2e 100644 --- a/client/src/app/pages/applications/applications-table/applications-table.tsx +++ b/client/src/app/pages/applications/applications-table/applications-table.tsx @@ -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, @@ -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 }, @@ -348,7 +348,7 @@ export const ApplicationsTable: React.FC = () => { businessService: app.businessService?.name || "", tags: app.tags?.length || 0, effort: app.effort || 0, - analysis:app.tasks.currentAnalyzer?.state || "" + analysis: app.tasks.currentAnalyzer?.state || "", }), filterCategories: [ { @@ -503,6 +503,7 @@ export const ApplicationsTable: React.FC = () => { ], getItemValue: (item) => normalizeRisk(item.risk) ?? "", }, + { categoryKey: "analysis", title: t("terms.analysis"), @@ -511,12 +512,25 @@ 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: Object.values(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"; + } + 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", }, ],