From 60bb44c6baba59631e51a445307ab7a547722b4d Mon Sep 17 00:00:00 2001 From: ibolton336 Date: Tue, 14 Nov 2023 16:19:02 -0500 Subject: [PATCH] - Add parsed label conversion for dependency labels = Add management column for application dependencies table Signed-off-by: ibolton336 --- client/src/app/api/models.ts | 3 +-- .../app/pages/dependencies/dependencies.tsx | 7 +++++- .../dependencies/dependency-apps-table.tsx | 24 +++++++++++++------ 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/client/src/app/api/models.ts b/client/src/app/api/models.ts index 5191e8aa8e..ec4a0bebab 100644 --- a/client/src/app/api/models.ts +++ b/client/src/app/api/models.ts @@ -523,8 +523,7 @@ export interface AnalysisAppDependency { version: string; provider: string; indirect: boolean; - //TODO: Glean from labels somehow - // management?: string; + labels: string[]; }; } diff --git a/client/src/app/pages/dependencies/dependencies.tsx b/client/src/app/pages/dependencies/dependencies.tsx index 648397c7a5..2594584e0d 100644 --- a/client/src/app/pages/dependencies/dependencies.tsx +++ b/client/src/app/pages/dependencies/dependencies.tsx @@ -31,6 +31,7 @@ import { useSelectionState } from "@migtools/lib-ui"; import { DependencyAppsDetailDrawer } from "./dependency-apps-detail-drawer"; import { useSharedAffectedApplicationFilterCategories } from "../issues/helpers"; import spacing from "@patternfly/react-styles/css/utilities/Spacing/spacing"; +import { getParsedLabel } from "@app/utils/rules-utils"; export const Dependencies: React.FC = () => { const { t } = useTranslation(); @@ -229,7 +230,11 @@ export const Dependencies: React.FC = () => { {dependency?.labels?.map((label) => { - return ; + return ( + + ); })} diff --git a/client/src/app/pages/dependencies/dependency-apps-table.tsx b/client/src/app/pages/dependencies/dependency-apps-table.tsx index 2107ca18eb..6448334654 100644 --- a/client/src/app/pages/dependencies/dependency-apps-table.tsx +++ b/client/src/app/pages/dependencies/dependency-apps-table.tsx @@ -4,7 +4,7 @@ import { Toolbar, ToolbarContent, ToolbarItem } from "@patternfly/react-core"; import { Table, Tbody, Td, Th, Thead, Tr } from "@patternfly/react-table"; import spacing from "@patternfly/react-styles/css/utilities/Spacing/spacing"; import { useSelectionState } from "@migtools/lib-ui"; -import { AnalysisDependency } from "@app/api/models"; +import { AnalysisAppDependency, AnalysisDependency } from "@app/api/models"; import { useTableControlState, useTableControlProps, @@ -21,6 +21,7 @@ import { FilterToolbar, FilterType } from "@app/components/FilterToolbar"; import { useFetchAppDependencies } from "@app/queries/dependencies"; import { useFetchBusinessServices } from "@app/queries/businessservices"; import { useFetchTagsWithTagItems } from "@app/queries/tags"; +import { getParsedLabel } from "@app/utils/rules-utils"; export interface IDependencyAppsTableProps { dependency: AnalysisDependency; @@ -39,7 +40,7 @@ export const DependencyAppsTable: React.FC = ({ columnNames: { name: "Application", version: "Version", - // management (3rd party or not boolean... parsed from labels) + management: "Management", relationship: "Relationship", }, isFilterEnabled: true, @@ -139,6 +140,15 @@ export const DependencyAppsTable: React.FC = ({ }, } = tableControls; + const getManagementValue = (appDependency: AnalysisAppDependency) => { + const hasJavaLabel = appDependency.dependency.labels.some((label) => { + const labelValue = getParsedLabel(label).labelValue; + return labelValue === "java"; + }); + const isJavaFile = dependency.name.endsWith(".jar"); + return hasJavaLabel && isJavaFile; + }; + return ( <> @@ -160,10 +170,10 @@ export const DependencyAppsTable: React.FC = ({ - {/* */} + /> = ({ > {appDependency.dependency.version} - {/* - {appDependency.management} - */} + {getManagementValue(appDependency) ? "Managed" : "Embedded"} +