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

[V2.5.1] Hide new columns in vm list for release 2.5.1 #733

Merged
merged 1 commit into from
Sep 20, 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
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"Clear all filters": "Clear all filters",
"Click the update credentials button to save your changes, button is disabled until a change is detected.": "Click the update credentials button to save your changes, button is disabled until a change is detected.",
"Close": "Close",
"Cluster": "Cluster",
"Clusters": "Clusters",
"Concerns": "Concerns",
"Conditions": "Conditions",
Expand Down Expand Up @@ -114,27 +113,17 @@
"Error: VDDK init image must be valid.": "Error: VDDK init image must be valid.",
"Failed": "Failed",
"False": "False",
"Filter by cluster": "Filter by cluster",
"Filter by endpoint": "Filter by endpoint",
"Filter by flavor": "Filter by flavor",
"Filter by host": "Filter by host",
"Filter by image": "Filter by image",
"Filter by name": "Filter by name",
"Filter by namespace": "Filter by namespace",
"Filter by network": "Filter by network",
"Filter by path": "Filter by path",
"Filter by status": "Filter by status",
"Filter by tenant": "Filter by tenant",
"Flavor": "Flavor",
"From": "From",
"Hide values": "Hide values",
"Hooks for virtualization": "Hooks for virtualization",
"Host": "Host",
"Host cluster": "Host cluster",
"Hosts": "Hosts",
"If true, the provider's REST API TLS certificate won't be validated.": "If true, the provider's REST API TLS certificate won't be validated.",
"If true, the provider's TLS certificate won't be validated.": "If true, the provider's TLS certificate won't be validated.",
"Image": "Image",
"Invalid application credential ID.": "Invalid application credential ID.",
"Invalid application credential name.": "Invalid application credential name.",
"Invalid application credential secret.": "Invalid application credential secret.",
Expand Down Expand Up @@ -245,11 +234,9 @@
"OpenStack REST API user name.": "OpenStack REST API user name.",
"Operator": "Operator",
"Operator conditions define the current state of the controller": "Operator conditions define the current state of the controller",
"OvaPath": "OvaPath",
"Overview": "Overview",
"Owner": "Owner",
"Password": "Password",
"Path": "Path",
"Plans": "Plans",
"Plans for virtualization": "Plans for virtualization",
"Please choose a NetworkAttachmentDefinition for default data transfer.": "Please choose a NetworkAttachmentDefinition for default data transfer.",
Expand Down Expand Up @@ -333,8 +320,6 @@
"Succeeded": "Succeeded",
"Target and Source": "Target and Source",
"Target provider": "Target provider",
"Template": "Template",
"Tenant": "Tenant",
"The CA certificate is the /etc/pki/ovirt-engine/apache-ca.pem file on the Manager machine.": "The CA certificate is the /etc/pki/ovirt-engine/apache-ca.pem file on the Manager machine.",
"The interval in minutes for precopy. Default value is 60.": "The interval in minutes for precopy. Default value is 60.",
"The interval in seconds for snapshot pooling. Default value is 10.": "The interval in seconds for snapshot pooling. Default value is 10.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@
padding-bottom: var(--pf-global--spacer--lg);
}

.forklift-page-provider-vm_concern-button {
padding: var(--pf-global--spacer--xs);
}

Original file line number Diff line number Diff line change
Expand Up @@ -32,62 +32,6 @@ export const oVirtVmFieldsMetadataFactory: ResourceFieldFactory = (t) => [
values: EnumToTuple({ Critical: 'Critical', Warning: 'Warning', Information: 'Information' }),
},
},
{
resourceFieldId: 'cluster',
jsonPath: '$.vm.cluster',
label: t('Cluster'),
isVisible: true,
isIdentity: false,
filter: {
type: 'freetext',
placeholderLabel: t('Filter by cluster'),
},
sortable: true,
},
{
resourceFieldId: 'host',
jsonPath: '$.vm.host',
label: t('Host'),
isVisible: true,
isIdentity: false,
filter: {
type: 'freetext',
placeholderLabel: t('Filter by host'),
},
sortable: true,
},
{
resourceFieldId: 'path',
jsonPath: '$.vm.path',
label: t('Path'),
isVisible: true,
isIdentity: false,
filter: {
type: 'freetext',
placeholderLabel: t('Filter by path'),
},
sortable: true,
},
{
resourceFieldId: 'status',
jsonPath: '$.vm.status',
label: t('Status'),
isVisible: true,
isIdentity: false,
filter: {
type: 'freetext',
placeholderLabel: t('Filter by status'),
},
sortable: true,
},
{
resourceFieldId: 'description',
jsonPath: '$.vm.description',
label: t('Description'),
isVisible: true,
isIdentity: false,
sortable: false,
},
];

export const OVirtVirtualMachinesList: React.FC<ProviderVirtualMachinesProps> = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,78 +32,6 @@ export const openStackVmFieldsMetadataFactory: ResourceFieldFactory = (t) => [
values: EnumToTuple({ Critical: 'Critical', Warning: 'Warning', Information: 'Information' }),
},
},
{
resourceFieldId: 'hostID',
jsonPath: '$.vm.hostID',
label: t('Host'),
isVisible: true,
isIdentity: false,
filter: {
type: 'freetext',
placeholderLabel: t('Filter by host'),
},
sortable: true,
},
{
resourceFieldId: 'path',
jsonPath: '$.vm.path',
label: t('Path'),
isVisible: true,
isIdentity: false,
filter: {
type: 'freetext',
placeholderLabel: t('Filter by path'),
},
sortable: true,
},
{
resourceFieldId: 'status',
jsonPath: '$.vm.status',
label: t('Status'),
isVisible: true,
isIdentity: false,
filter: {
type: 'freetext',
placeholderLabel: t('Filter by status'),
},
sortable: true,
},
{
resourceFieldId: 'tenantID',
jsonPath: '$.vm.tenantID',
label: t('Tenant'),
isVisible: true,
isIdentity: false,
filter: {
type: 'freetext',
placeholderLabel: t('Filter by tenant'),
},
sortable: true,
},
{
resourceFieldId: 'imageID',
jsonPath: '$.vm.imageID',
label: t('Image'),
isVisible: true,
isIdentity: false,
filter: {
type: 'freetext',
placeholderLabel: t('Filter by image'),
},
sortable: true,
},
{
resourceFieldId: 'flavorID',
jsonPath: '$.vm.flavorID',
label: t('Flavor'),
isVisible: true,
isIdentity: false,
filter: {
type: 'freetext',
placeholderLabel: t('Filter by flavor'),
},
sortable: true,
},
];

export const OpenStackVirtualMachinesList: React.FC<ProviderVirtualMachinesProps> = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,6 @@ export const ovaVmFieldsMetadataFactory: ResourceFieldFactory = (t) => [
values: EnumToTuple({ Critical: 'Critical', Warning: 'Warning', Information: 'Information' }),
},
},
{
resourceFieldId: 'ovaPath',
jsonPath: '$.vm.OvaPath',
label: t('OvaPath'),
isVisible: true,
isIdentity: false,
filter: {
type: 'freetext',
placeholderLabel: t('Filter by path'),
},
sortable: true,
},
];

export const OvaVirtualMachinesList: React.FC<ProviderVirtualMachinesProps> = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,50 +32,6 @@ export const vSphereVmFieldsMetadataFactory: ResourceFieldFactory = (t) => [
values: EnumToTuple({ Critical: 'Critical', Warning: 'Warning', Information: 'Information' }),
},
},
{
resourceFieldId: 'isTemplate',
jsonPath: '$.vm.isTemplate',
label: t('Template'),
isVisible: true,
isIdentity: false,
sortable: true,
},
{
resourceFieldId: 'host',
jsonPath: '$.vm.host',
label: t('Host'),
isVisible: true,
isIdentity: false,
filter: {
type: 'freetext',
placeholderLabel: t('Filter by host'),
},
sortable: true,
},
{
resourceFieldId: 'path',
jsonPath: '$.vm.path',
label: t('Path'),
isVisible: true,
isIdentity: false,
filter: {
type: 'freetext',
placeholderLabel: t('Filter by path'),
},
sortable: true,
},
{
resourceFieldId: 'status',
jsonPath: '$.vm.powerState',
label: t('Status'),
isVisible: true,
isIdentity: false,
filter: {
type: 'freetext',
placeholderLabel: t('Filter by status'),
},
sortable: true,
},
];

export const VSphereVirtualMachinesList: React.FC<ProviderVirtualMachinesProps> = ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,90 @@
import React from 'react';
import { TableCell } from 'src/modules/Providers/utils';

import { Concern } from '@kubev2v/types';
import {
BlueInfoCircleIcon,
RedExclamationCircleIcon,
YellowExclamationTriangleIcon,
} from '@openshift-console/dynamic-plugin-sdk';
import { Stack, StackItem } from '@patternfly/react-core';
import { Button, Flex, FlexItem, Label, Popover, Stack, StackItem } from '@patternfly/react-core';

import { VMCellProps } from './VMCellProps';

const statusIcons = {
Critical: <RedExclamationCircleIcon />,
Information: <BlueInfoCircleIcon />,
Warning: <YellowExclamationTriangleIcon />,
};

const categoryWeights = {
Critical: 1,
Warning: 2,
Information: 3,
type ConcernCategories = {
category: 'Critical' | 'Information' | 'Warning';
label: string;
};

export const VMConcernsCellRenderer: React.FC<VMCellProps> = ({ data }) => {
const groupedConcerns = groupConcernsByCategory(data?.vm?.concerns);

return (
<TableCell>
<Stack>
{data?.vm?.concerns
?.sort((a, b) => categoryWeights[a.category] - categoryWeights[b.category])
?.map((c) => {
return (
<StackItem key={c.label}>
{statusIcons?.[c.category]} {c.label}
</StackItem>
);
})}
</Stack>
<Flex spaceItems={{ default: 'spaceItemsNone' }}>
{['Critical', 'Information', 'Warning'].map((category) => (
<FlexItem key={category}>
<ConcernPopover category={category} concerns={groupedConcerns[category] || []} />
</FlexItem>
))}
</Flex>
</TableCell>
);
};

const groupConcernsByCategory = (concerns: Concern[]): Record<string, ConcernCategories[]> => {
return (
concerns?.reduce((acc, concern) => {
acc[concern.category] = (acc[concern.category] || []).concat(concern);
return acc;
}, {}) || {}
);
};

const ConcernPopover: React.FC<{
category: string;
concerns: ConcernCategories[];
}> = ({ category, concerns }) => {
if (concerns.length < 1) return <></>;

return (
<Popover
aria-label={`${category} popover`}
headerContent={<div>{category} Concerns</div>}
bodyContent={<ConcernList concerns={concerns} />}
footerContent={`Total: ${concerns.length}`}
>
<Button variant="link" className="forklift-page-provider-vm_concern-button">
<ConcernLabel category={category} count={concerns.length} />
</Button>
</Popover>
);
};

const ConcernList: React.FC<{ concerns: ConcernCategories[] }> = ({ concerns }) => (
<Stack>
{concerns.map((c) => (
<StackItem key={c.category}>
{statusIcons[c.category]} {c.label}
</StackItem>
))}
</Stack>
);

const ConcernLabel: React.FC<{ category: string; count: number }> = ({ category, count }) => (
<Label variant="outline" color={categoryColors[category]} icon={statusIcons[category]}>
{count}
</Label>
);

const statusIcons = {
Critical: <RedExclamationCircleIcon />,
Information: <BlueInfoCircleIcon />,
Warning: <YellowExclamationTriangleIcon />,
};

const categoryColors = {
Critical: 'red',
Information: 'blue',
Warning: 'orange',
};