Skip to content
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
@@ -1,6 +1,9 @@
import * as React from 'react';
import { AddressBookIcon } from '@patternfly/react-icons';
import { StatusGroupMapper } from '@console/internal/components/dashboard/inventory-card/inventory-item';
import {
StatusGroupMapper,
ExpandedComponentProps,
} from '@console/internal/components/dashboard/inventory-card/inventory-item';

export const getRouteStatusGroups: StatusGroupMapper = (resources) => ({
'demo-inventory-group': {
Expand All @@ -13,3 +16,7 @@ export const getRouteStatusGroups: StatusGroupMapper = (resources) => ({
export const DemoGroupIcon: React.FC<{}> = () => (
<AddressBookIcon className="co-inventory-card__status-icon co-inventory-card__status-icon--warn" />
);

export const ExpandedRoutes: React.FC<ExpandedComponentProps> = ({ resource }) => (
<div>Additional content for {resource.length} routes</div>
);
4 changes: 4 additions & 0 deletions frontend/packages/console-demo-plugin/src/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ const plugin: Plugin<ConsumedExtensions> = [
},
model: RouteModel,
mapper: getRouteStatusGroups,
expandedComponent: () =>
import('./dashboards/inventory' /* webpackChunkName: "demo-inventory-item" */).then(
(m) => m.ExpandedRoutes,
),
required: 'TEST_MODEL_FLAG',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { SubsystemHealth } from '@console/internal/components/dashboards-page/ov
import { GridPosition } from '@console/internal/components/dashboard/grid';
import { FirehoseResource, Humanize, FirehoseResult } from '@console/internal/components/utils';
import { K8sKind, K8sResourceKind } from '@console/internal/module/k8s';
import { StatusGroupMapper } from '@console/internal/components/dashboard/inventory-card/inventory-item';
import {
StatusGroupMapper,
ExpandedComponentProps,
} from '@console/internal/components/dashboard/inventory-card/inventory-item';
import { OverviewQuery } from '@console/internal/components/dashboards-page/overview-dashboard/queries';
import { ConsumerMutator } from '@console/internal/components/dashboards-page/overview-dashboard/top-consumers-card';
import { MetricType } from '@console/internal/components/dashboard/top-consumers-card/metric-type';
Expand Down Expand Up @@ -118,6 +121,9 @@ namespace ExtensionProperties {

/** Function which will map various statuses to groups. */
mapper: StatusGroupMapper;

/** Loader for the component which will be used when item is expanded. */
expandedComponent?: LazyLoader<ExpandedComponentProps>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a brief description here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

}

export interface DashboardsInventoryItemGroup extends DashboardExtension {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
import './inventory.scss';

const VM_STATUS_GROUP_MAPPER = {
[InventoryStatusGroup.OK]: [VM_STATUS_RUNNING],
[InventoryStatusGroup.NOT_MAPPED]: [VM_STATUS_RUNNING],
'vm-off': [VM_STATUS_OFF],
[InventoryStatusGroup.PROGRESS]: [
VM_STATUS_V2V_CONVERSION_IN_PROGRESS,
Expand Down Expand Up @@ -55,7 +55,7 @@ export const getVMStatusGroups: StatusGroupMapper = (vms, { pods, migrations })
statusIDs: [],
count: 0,
},
[InventoryStatusGroup.OK]: {
[InventoryStatusGroup.UNKNOWN]: {
statusIDs: [],
count: 0,
},
Expand All @@ -70,7 +70,7 @@ export const getVMStatusGroups: StatusGroupMapper = (vms, { pods, migrations })
const group =
Object.keys(VM_STATUS_GROUP_MAPPER).find((key) =>
VM_STATUS_GROUP_MAPPER[key].includes(status),
) || InventoryStatusGroup.NOT_MAPPED;
) || InventoryStatusGroup.UNKNOWN;
groups[group].count++;
});
return groups;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ const InventoryCard: React.FC<InventoryCardProps> = ({
<InventoryBody>
<InventoryItem
isLoading={!podData}
singularTitle="Pod"
pluralTitle="Pods"
title="Pod"
count={podCount}
error={podQueryError || podError || !podStats.length}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import { findNodeMaintenance, getHostMachine } from '../../../selectors';
import { getHostFilterStatus } from '../table-filters';

const BMH_STATUS_GROUP_MAPPER = {
[InventoryStatusGroup.OK]: HOST_SUCCESS_STATES,
[InventoryStatusGroup.NOT_MAPPED]: HOST_SUCCESS_STATES,
[InventoryStatusGroup.PROGRESS]: HOST_PROGRESS_STATES,
[InventoryStatusGroup.ERROR]: HOST_ERROR_STATES,
};

export const getBMHStatusGroups: StatusGroupMapper = (hosts, { machines, nodes, maintenances }) => {
const groups = {
[InventoryStatusGroup.OK]: {
[InventoryStatusGroup.NOT_MAPPED]: {
statusIDs: ['ready', 'provisioned'],
count: 0,
filterType: 'host-status',
Expand All @@ -30,7 +30,7 @@ export const getBMHStatusGroups: StatusGroupMapper = (hosts, { machines, nodes,
count: 0,
filterType: 'host-status',
},
[InventoryStatusGroup.NOT_MAPPED]: {
[InventoryStatusGroup.UNKNOWN]: {
statusIDs: ['other'],
count: 0,
filterType: 'host-status',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
.co-inventory-card__item {
align-items: center;
border-bottom: 1px solid $pf-color-black-300;
display: flex;
font-size: 1rem;
justify-content: space-between;
padding: 1em var(--pf-c-card--child--PaddingRight) 1em var(--pf-c-card--child--PaddingLeft);
line-height: 1.5rem;
padding: 1rem var(--pf-c-card--child--PaddingRight) 1rem var(--pf-c-card--child--PaddingLeft);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, the var(x) expression is the standard CSS way of handling variables, equivalent to Sass $x expressions? If so, we should favor the new CSS way to handle variables, right?

Also, what is the rationale behind var(--pf-x) instead of non-prefixed var(pf-x) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldnt find variable in scss form that I could use. Also patternfly-react is using these in same way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, so I guess $pf-stuff comes from PF3 (Sass) and var(--pf-stuff) comes from PF4, is that right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, correct

}

.co-inventory-card__item--border {
border-bottom: 1px solid $pf-color-black-300;
}

.co-inventory-card__item-status {
align-items: center;
display: flex;
flex-wrap: wrap;

:last-child {
margin-right: 0;
}
}

.co-inventory-card__item-title {
margin-right: 0.5em;
display: flex;
margin-right: 0.5rem;
}

.co-inventory-card__status {
align-items: center;
display: flex;
flex-shrink: 0;
margin-right: 0.5em;
margin-left: 1.8rem;
}

.co-inventory-card__status-icon--question {
Expand All @@ -36,10 +37,51 @@
color: $pf-color-black-600;
}

.co-inventory-card__status-icon--warn {
color: $pf-color-gold-400;
.co-inventory-card__status-text {
margin-left: 0.25rem;
}

.co-inventory-card__status-text {
margin-left: 0.25em;
.co-inventory-card__accordion.pf-c-accordion {
border-bottom: 1px solid $pf-color-black-300;
box-shadow: none;
padding: 0;

h5 {
font-size: var(--pf-c-card__body--FontSize);
font-weight: var(--pf-global--FontWeight--normal);
margin: 0;
}

.co-inventory-card__accordion-toggle.pf-c-accordion__toggle {
border-left: none;
padding: 0 var(--pf-c-card--child--PaddingRight) 0 0;

.pf-c-accordion__toggle-text {
width: 100%;
}
}

.co-inventory-card__accordion-body.pf-c-accordion__expanded-content {
border-left: none;

.pf-c-accordion__expanded-content-body {
padding: 1rem var(--pf-c-card--child--PaddingRight) 1rem var(--pf-c-card--child--PaddingLeft);
}
}
}

.skeleton-inventory {
animation: $skeleton-animation;
background: $skeleton-color;
height: 20px;
width: 20px;
opacity: 0;
margin-right: 0.5rem;
&::after {
background-repeat: no-repeat;
content: "";
display: block;
height: 100%;
width: 100%;
}
}
Loading