Skip to content

Commit

Permalink
Fixing bug MTA-3095
Browse files Browse the repository at this point in the history
Signed-off-by: TalyaNaima <[email protected]>
  • Loading branch information
TalyaNaima committed Oct 7, 2024
1 parent dcea907 commit 01b7f08
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 96 deletions.
2 changes: 1 addition & 1 deletion client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@
"success": {
"saveWhat": "{{type}} {{what}} was successfully saved.",
"save": "{{type}} was successfully saved.",
"applicationDeleted": "{{appIDCount}} application(s) successfully deleted.",
"applicationDeleted": "{{appName}} application(s) successfully deleted.",
"assessmentAndReviewCopied": "Success! Assessment and review copied to selected applications",
"assessmentCopied": "Success! Assessment copied to selected applications",
"assessmentDiscarded": "Success! Assessment discarded for {{application}}.",
Expand Down
2 changes: 1 addition & 1 deletion client/public/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@
"toastr": {
"success": {
"added": "Éxito! {{what}} fue creado como un {{type}}.",
"applicationDeleted": "{{appIDCount}} aplicacione(s) descheda.",
"applicationDeleted": "{{appName}} aplicacione(s) descheda.",
"assessmentAndReviewCopied": "Éxito! Evaluación y revisión copiada a las aplicaciones seleccionadas",
"assessmentCopied": "Éxito! Evaluación copiada a las aplicaciones seleccionadas",
"assessmentDiscarded": "Éxito! Evaluación de {{application}} desechada.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ import { TaskState } from "@app/api/models";

// Relative components
import { AnalysisWizard } from "../analysis-wizard/analysis-wizard";
import { ApplicationAnalysisStatus, taskStateToAnalyze } 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";
Expand All @@ -110,8 +113,6 @@ import {
DecoratedApplication,
useDecoratedApplications,
} from "./useDecoratedApplications";
import { Item } from "@app/pages/migration-targets/components/dnd/item";
import AnalysisDetails from "../analysis-details";

export const ApplicationsTable: React.FC = () => {
const { t } = useTranslation();
Expand Down Expand Up @@ -239,7 +240,7 @@ export const ApplicationsTable: React.FC = () => {
const onDeleteApplicationSuccess = (appIDCount: number) => {
pushNotification({
title: t("toastr.success.applicationDeleted", {
appIDCount: appIDCount,
appName: applicationsToDelete[0].name,
}),
variant: "success",
});
Expand Down Expand Up @@ -338,7 +339,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 +349,7 @@ export const ApplicationsTable: React.FC = () => {
businessService: app.businessService?.name || "",
tags: app.tags?.length || 0,
effort: app.effort || 0,
analysis: app.tasks.currentAnalyzer?.state || 0
analysis: app.tasks.currentAnalyzer?.state || 0,
}),
filterCategories: [
{
Expand Down Expand Up @@ -503,6 +504,23 @@ 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)
// .map(a => ({
// value: a?.tasks.currentAnalyzer?.state || "No Task",
// label: a?.tasks.currentAnalyzer?.state || "Not Started",
// }))
// .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",
// }
{
categoryKey: "analysis",
title: t("terms.analysis"),
Expand All @@ -511,13 +529,18 @@ export const ApplicationsTable: React.FC = () => {
t("actions.filterBy", {
what: t("terms.analysis").toLowerCase(),
}) + "...",
selectOptions: Array.from(taskStateToAnalyze).map(([taskState, displayStatus]) => ({
value: taskState, // The task state will be the value
label: t(`${displayStatus}`) // The display status translated using t()
})),

getItemValue: (item) => item?.tasks.currentAnalyzer?.state ||
"No task"
selectOptions: Object.values(applications)
.map((a) => {
let value = a?.tasks.currentAnalyzer?.state || "No Task";
if (value === "No Task") {
value = "No task";
}
const label = taskStateToAnalyze.get(value as TaskState) || value;
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",
},
],
initialItemsPerPage: 10,
Expand Down Expand Up @@ -567,48 +590,48 @@ export const ApplicationsTable: React.FC = () => {

const importDropdownItems = importWriteAccess
? [
<DropdownItem
key="import-applications"
component="button"
onClick={() => setIsApplicationImportModalOpen(true)}
>
{t("actions.import")}
</DropdownItem>,
<DropdownItem
key="manage-import-applications"
onClick={() => {
history.push(Paths.applicationsImports);
}}
>
{t("actions.manageImports")}
</DropdownItem>,
]
<DropdownItem
key="import-applications"
component="button"
onClick={() => setIsApplicationImportModalOpen(true)}
>
{t("actions.import")}
</DropdownItem>,
<DropdownItem
key="manage-import-applications"
onClick={() => {
history.push(Paths.applicationsImports);
}}
>
{t("actions.manageImports")}
</DropdownItem>,
]
: [];
const applicationDropdownItems = applicationWriteAccess
? [
<DropdownItem
key="applications-bulk-delete"
isDisabled={selectedRows.length < 1}
onClick={() => {
setApplicationsToDelete(selectedRows);
}}
>
{t("actions.delete")}
</DropdownItem>,
...(credentialsReadAccess
? [
<DropdownItem
key="manage-applications-credentials"
isDisabled={selectedRows.length < 1}
onClick={() => {
setSaveApplicationsCredentialsModalState(selectedRows);
}}
>
{t("actions.manageCredentials")}
</DropdownItem>,
]
: []),
]
<DropdownItem
key="applications-bulk-delete"
isDisabled={selectedRows.length < 1}
onClick={() => {
setApplicationsToDelete(selectedRows);
}}
>
{t("actions.delete")}
</DropdownItem>,
...(credentialsReadAccess
? [
<DropdownItem
key="manage-applications-credentials"
isDisabled={selectedRows.length < 1}
onClick={() => {
setSaveApplicationsCredentialsModalState(selectedRows);
}}
>
{t("actions.manageCredentials")}
</DropdownItem>,
]
: []),
]
: [];

const dropdownItems = [...importDropdownItems, ...applicationDropdownItems];
Expand Down Expand Up @@ -997,58 +1020,58 @@ export const ApplicationsTable: React.FC = () => {
onClick: () => assessSelectedApp(application),
},
assessmentWriteAccess &&
(application.assessments?.length ?? 0) > 0 && {
title: t("actions.discardAssessment"),
onClick: () =>
setAssessmentToDiscard(application),
},
(application.assessments?.length ?? 0) > 0 && {
title: t("actions.discardAssessment"),
onClick: () =>
setAssessmentToDiscard(application),
},
reviewsWriteAccess && {
title: t("actions.review"),
onClick: () => reviewSelectedApp(application),
},
reviewsWriteAccess &&
application?.review && {
title: t("actions.discardReview"),
onClick: () => setReviewToDiscard(application),
},
application?.review && {
title: t("actions.discardReview"),
onClick: () => setReviewToDiscard(application),
},
dependenciesWriteAccess && {
title: t("actions.manageDependencies"),
onClick: () =>
setApplicationDependenciesToManage(application),
},
credentialsReadAccess &&
applicationWriteAccess && {
title: t("actions.manageCredentials"),
onClick: () =>
setSaveApplicationsCredentialsModalState([
application,
]),
},
applicationWriteAccess && {
title: t("actions.manageCredentials"),
onClick: () =>
setSaveApplicationsCredentialsModalState([
application,
]),
},
analysesReadAccess &&
!!application.tasks.currentAnalyzer && {
title: t("actions.analysisDetails"),
onClick: () => {
const taskId =
application.tasks.currentAnalyzer?.id;
if (taskId && application.id) {
history.push(
formatPath(
Paths.applicationsAnalysisDetails,
{
applicationId: application.id,
taskId,
}
)
);
}
!!application.tasks.currentAnalyzer && {
title: t("actions.analysisDetails"),
onClick: () => {
const taskId =
application.tasks.currentAnalyzer?.id;
if (taskId && application.id) {
history.push(
formatPath(
Paths.applicationsAnalysisDetails,
{
applicationId: application.id,
taskId,
}
)
);
}
},
},
},
tasksReadAccess &&
tasksWriteAccess &&
isTaskCancellable(application) && {
title: t("actions.cancelAnalysis"),
onClick: () => cancelAnalysis(application),
},
tasksWriteAccess &&
isTaskCancellable(application) && {
title: t("actions.cancelAnalysis"),
onClick: () => cancelAnalysis(application),
},
applicationWriteAccess && { isSeparator: true },
applicationWriteAccess && {
title: t("actions.delete"),
Expand Down Expand Up @@ -1151,10 +1174,11 @@ export const ApplicationsTable: React.FC = () => {
)}
titleIconVariant={"warning"}
isOpen={applicationsToDelete.length > 0}
message={`${applicationsToDelete.length > 1
? t("dialog.message.applicationsBulkDelete")
: ""
} ${t("dialog.message.delete")}`}
message={`${
applicationsToDelete.length > 1
? t("dialog.message.applicationsBulkDelete")
: ""
} ${t("dialog.message.delete")}`}
aria-label="Applications bulk delete"
confirmBtnVariant={ButtonVariant.danger}
confirmBtnLabel={t("actions.delete")}
Expand Down

0 comments on commit 01b7f08

Please sign in to comment.