Skip to content

Commit

Permalink
- Add parsed label conversion for dependency labels
Browse files Browse the repository at this point in the history
= Add management column for application dependencies table

Signed-off-by: ibolton336 <[email protected]>
  • Loading branch information
ibolton336 committed Nov 14, 2023
1 parent 44e6eeb commit 60bb44c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
3 changes: 1 addition & 2 deletions client/src/app/api/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,7 @@ export interface AnalysisAppDependency {
version: string;
provider: string;
indirect: boolean;
//TODO: Glean from labels somehow
// management?: string;
labels: string[];
};
}

Expand Down
7 changes: 6 additions & 1 deletion client/src/app/pages/dependencies/dependencies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -229,7 +230,11 @@ export const Dependencies: React.FC = () => {
<Td width={10} {...getTdProps({ columnKey: "labels" })}>
<LabelGroup>
{dependency?.labels?.map((label) => {
return <Label>{label}</Label>;
return (
<Label>
{getParsedLabel(label).labelValue}
</Label>
);
})}
</LabelGroup>
</Td>
Expand Down
24 changes: 17 additions & 7 deletions client/src/app/pages/dependencies/dependency-apps-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand All @@ -39,7 +40,7 @@ export const DependencyAppsTable: React.FC<IDependencyAppsTableProps> = ({
columnNames: {
name: "Application",
version: "Version",
// management (3rd party or not boolean... parsed from labels)
management: "Management",
relationship: "Relationship",
},
isFilterEnabled: true,
Expand Down Expand Up @@ -139,6 +140,15 @@ export const DependencyAppsTable: React.FC<IDependencyAppsTableProps> = ({
},
} = 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 (
<>
<Toolbar {...toolbarProps} className={spacing.mtSm}>
Expand All @@ -160,10 +170,10 @@ export const DependencyAppsTable: React.FC<IDependencyAppsTableProps> = ({
<TableHeaderContentWithControls {...tableControls}>
<Th {...getThProps({ columnKey: "name" })} />
<Th {...getThProps({ columnKey: "version" })} modifier="nowrap" />
{/* <Th
<Th
{...getThProps({ columnKey: "management" })}
modifier="nowrap"
/> */}
/>
<Th
{...getThProps({ columnKey: "relationship" })}
modifier="nowrap"
Expand Down Expand Up @@ -198,13 +208,13 @@ export const DependencyAppsTable: React.FC<IDependencyAppsTableProps> = ({
>
{appDependency.dependency.version}
</Td>
{/* <Td
<Td
width={20}
modifier="nowrap"
{...getTdProps({ columnKey: "management" })}
>
{appDependency.management}
</Td> */}
{getManagementValue(appDependency) ? "Managed" : "Embedded"}
</Td>
<Td
width={20}
modifier="nowrap"
Expand Down

0 comments on commit 60bb44c

Please sign in to comment.