-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ adding filter& sort by analysis to Application-inventory table #2100
base: main
Are you sure you want to change the base?
Changes from all commits
656a1f9
392aa0d
9d163db
fc87877
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
|
@@ -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"; | ||
|
@@ -334,7 +337,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 }, | ||
|
@@ -344,6 +347,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: [ | ||
{ | ||
|
@@ -498,7 +502,38 @@ 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: Object.values(applications) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
.map((a) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You will need to re-use the same mapper for sorting so let's create a named function for that.
Links: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the functions mentioned here are pushed in #2152 |
||
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)), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should sort on label - note also that |
||
|
||
getItemValue: (item) => item?.tasks.currentAnalyzer?.state || "No Task", | ||
rszwajko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
], | ||
|
||
initialItemsPerPage: 10, | ||
hasActionsColumn: true, | ||
isSelectionEnabled: true, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should sort on labels visible on the screen - see the propsed
mapAnalysisStateToLabel
below