Skip to content

Commit

Permalink
✨ Add management column for application dependencies table (#1541)
Browse files Browse the repository at this point in the history
- Add management column for application dependencies table
- Add parsed label conversion for dependency labels
#1339

Depends on konveyor/tackle2-addon-analyzer#62

Signed-off-by: ibolton336 <[email protected]>
  • Loading branch information
ibolton336 authored Nov 15, 2023
1 parent 06d6551 commit d142fdd
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 11 deletions.
12 changes: 9 additions & 3 deletions 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 @@ -201,9 +202,14 @@ export const Dependencies: React.FC = () => {
</Td>
<Td width={10} {...getTdProps({ columnKey: "labels" })}>
<LabelGroup>
{dependency?.labels?.map((label, index) => (
<Label key={index}>{label}</Label>
))}
{dependency?.labels?.map((label) => {
if (getParsedLabel(label).labelType !== "language")
return (
<Label>
{getParsedLabel(label).labelValue}
</Label>
);
})}
</LabelGroup>
</Td>
</TableRowContentWithControls>
Expand Down
37 changes: 29 additions & 8 deletions client/src/app/pages/dependencies/dependency-apps-table.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import * as React from "react";
import { useTranslation } from "react-i18next";
import { Toolbar, ToolbarContent, ToolbarItem } from "@patternfly/react-core";
import {
TextContent,
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 +26,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 +45,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 @@ -158,10 +164,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 @@ -196,13 +202,13 @@ export const DependencyAppsTable: React.FC<IDependencyAppsTableProps> = ({
>
{appDependency.dependency.version}
</Td>
{/* <Td
<Td
width={20}
modifier="nowrap"
{...getTdProps({ columnKey: "management" })}
>
{appDependency.management}
</Td> */}
<DependencyManagementColumn appDependency={appDependency} />
</Td>
<Td
width={20}
modifier="nowrap"
Expand All @@ -227,3 +233,18 @@ export const DependencyAppsTable: React.FC<IDependencyAppsTableProps> = ({
</>
);
};

const DependencyManagementColumn = ({
appDependency,
}: {
appDependency: AnalysisAppDependency;
}) => {
const hasJavaLabel = appDependency.dependency?.labels?.some((label) => {
const labelValue = getParsedLabel(label).labelValue;
return labelValue === "java";
});
const isJavaFile = appDependency.dependency.name.endsWith(".jar");
const isJavaDependency = hasJavaLabel && isJavaFile;

return <TextContent>{isJavaDependency ? "Managed" : "Embedded"}</TextContent>;
};

0 comments on commit d142fdd

Please sign in to comment.