From 2a87d100f9ef25c61d958e3d76288db5c078eb0c Mon Sep 17 00:00:00 2001 From: Radoslaw Szwajkowski Date: Wed, 24 Nov 2021 17:29:16 +0100 Subject: [PATCH] Migrate VM Details to PF4 Functional changes: 1. error handling on Create/Edit Disk modal is now handled via field level errors. Note that information about resizing disk was moved from tooltip to permanent helper text (as per PF4 guidelines) 2. New break-point for responsive resize was added for medium screens. PF4 uses bigger fonts so i.e. snapshot card was breaking during resizing 3. Overview card in edit mode does not show the OS icon - this saves space and prevents layout changes during editing i.e. when error message is shown. --- src/components/Grid/style.css | 4 +- src/components/VmDetails/BaseCard.js | 47 ++- src/components/VmDetails/CardEditButton.js | 14 +- .../DetailsCard/CloudInit/CloudInitForm.js | 35 +-- .../DetailsCard/CloudInit/SysprepForm.js | 63 ++-- .../VmDetails/cards/DetailsCard/FieldRow.js | 25 +- .../VmDetails/cards/DetailsCard/index.js | 58 ++-- .../VmDetails/cards/DetailsCard/style.css | 22 +- .../cards/DisksCard/DiskImageEditor.js | 287 ++++++++---------- .../VmDetails/cards/DisksCard/DiskListItem.js | 17 +- .../cards/DisksCard/DiskStateIcon.js | 45 +-- .../VmDetails/cards/DisksCard/index.js | 11 +- .../VmDetails/cards/DisksCard/style.css | 12 - .../VmDetails/cards/NicsCard/NicEditor.js | 177 +++++------ .../cards/NicsCard/NicLinkStateIcon.js | 32 +- .../VmDetails/cards/NicsCard/NicListItem.js | 14 +- .../VmDetails/cards/NicsCard/index.js | 6 +- .../VmDetails/cards/OverviewCard/index.js | 64 ++-- .../VmDetails/cards/OverviewCard/style.css | 1 + .../cards/SnapshotsCard/NewSnapshotModal.js | 94 +++--- .../cards/SnapshotsCard/SnapshotDetail.js | 271 ++++++----------- .../cards/SnapshotsCard/SnapshotItem.js | 58 ++-- .../VmDetails/cards/SnapshotsCard/index.js | 3 +- .../VmDetails/cards/SnapshotsCard/style.css | 23 +- .../cards/UtilizationCard/CpuCharts.js | 30 +- .../cards/UtilizationCard/DiskCharts.js | 47 ++- .../cards/UtilizationCard/MemoryCharts.js | 47 ++- .../cards/UtilizationCard/NetworkingCharts.js | 30 +- .../cards/UtilizationCard/NoHistoricData.js | 4 +- .../cards/UtilizationCard/NoLiveData.js | 4 +- .../UtilizationCard/UtilizationCardData.js | 25 ++ .../VmDetails/cards/UtilizationCard/style.css | 35 +++ src/components/VmDetails/index.js | 13 +- src/components/VmDetails/style.css | 37 ++- 34 files changed, 759 insertions(+), 896 deletions(-) create mode 100644 src/components/VmDetails/cards/UtilizationCard/UtilizationCardData.js diff --git a/src/components/Grid/style.css b/src/components/Grid/style.css index 37864c9fa..ea1857cd3 100644 --- a/src/components/Grid/style.css +++ b/src/components/Grid/style.css @@ -17,8 +17,8 @@ position: relative; width: 100%; min-height: 1px; - padding-right: 20px; - padding-left: 20px; + padding-right: 10px; + padding-left: 10px; flex: 1 1 0; /* grow shrink basis */ max-width: 100%; diff --git a/src/components/VmDetails/BaseCard.js b/src/components/VmDetails/BaseCard.js index a4d9f3b0f..95c4c3458 100644 --- a/src/components/VmDetails/BaseCard.js +++ b/src/components/VmDetails/BaseCard.js @@ -4,18 +4,16 @@ import { Badge, Button, Card, - CardHeading, + CardHeader, CardTitle, CardBody, CardFooter, - Icon, - noop, - excludeKeys, -} from 'patternfly-react' +} from '@patternfly/react-core' import style from './style.css' import CardEditButton from './CardEditButton' import { Tooltip } from '_/components/tooltips' +import { CheckIcon, TimesIcon } from '@patternfly/react-icons/dist/esm/icons' /** * Base VM details card. Support common layouts and view vs edit modes. @@ -76,7 +74,7 @@ class BaseCard extends React.Component { } renderChildren (childProps) { - const children = this.props.children || noop + const children = this.props.children || (() => {}) return typeof children === 'function' ? children(childProps) : React.isValidElement(children) @@ -87,7 +85,7 @@ class BaseCard extends React.Component { render () { const { title = undefined, - icon = undefined, + icon: TheIcon = undefined, itemCount = undefined, editMode = undefined, editable = true, @@ -101,13 +99,18 @@ class BaseCard extends React.Component { const editing = editMode === undefined ? this.state.edit : editMode const hasHeading = !!title const hasBadge = itemCount !== undefined - const hasIcon = icon && icon.type && icon.name const RenderChildren = this.renderChildren return ( - + {hasHeading && ( - + + + + {TheIcon && } + {title} + {hasBadge && {itemCount}} + - - {hasIcon && } - {title} - {hasBadge && {itemCount}} - - + )} @@ -143,10 +141,8 @@ class BaseCard extends React.Component { {editing && ( - - +