Skip to content
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

✨ Add management column for application dependencies table #1541

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>;
};
Loading