From 6a99d3435602cb17c38c1accb913ec6b138bb8f2 Mon Sep 17 00:00:00 2001 From: Scott Dickerson Date: Jun 03 2022 13:08:12 +0000 Subject: Merge pull request #1540 from rszwajko/vmDetailsPF4 Migrate VM Details to PF4 --- diff --git a/src/components/Grid/style.css b/src/components/Grid/style.css index 37864c9..ea1857c 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 a4d9f3b..9f36c7d 100644 --- a/src/components/VmDetails/BaseCard.js +++ b/src/components/VmDetails/BaseCard.js @@ -4,18 +4,18 @@ 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' + +import { withMsg } from '_/intl' /** * Base VM details card. Support common layouts and view vs edit modes. @@ -76,7 +76,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 +87,7 @@ class BaseCard extends React.Component { render () { const { title = undefined, - icon = undefined, + icon: TheIcon = undefined, itemCount = undefined, editMode = undefined, editable = true, @@ -97,17 +97,23 @@ class BaseCard extends React.Component { disableSaveButton = false, disableTooltip = undefined, editTooltipPlacement = 'top', + msg, } = this.props 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 +144,22 @@ class BaseCard extends React.Component { {editing && ( - + - )} @@ -155,10 +168,7 @@ class BaseCard extends React.Component { } BaseCard.propTypes = { title: PropTypes.string, - icon: PropTypes.shape({ - type: PropTypes.string.isRequired, - name: PropTypes.string.isRequired, - }), + icon: PropTypes.any, itemCount: PropTypes.number, idPrefix: PropTypes.string, className: PropTypes.string, @@ -174,11 +184,13 @@ BaseCard.propTypes = { onCancel: PropTypes.func, onSave: PropTypes.func, children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]).isRequired, + + msg: PropTypes.object.isRequired, } BaseCard.defaultProps = { - onStartEdit: noop, - onCancel: noop, - onSave: noop, + onStartEdit: () => {}, + onCancel: () => {}, + onSave: () => {}, } -export default BaseCard +export default withMsg(BaseCard) diff --git a/src/components/VmDetails/CardEditButton.js b/src/components/VmDetails/CardEditButton.js index 4207c59..eb63e00 100644 --- a/src/components/VmDetails/CardEditButton.js +++ b/src/components/VmDetails/CardEditButton.js @@ -1,9 +1,7 @@ import React from 'react' import PropTypes from 'prop-types' -import { - Icon, - noop, -} from 'patternfly-react' + +import { PencilAltIcon } from '@patternfly/react-icons/dist/esm/icons' import style from './style.css' @@ -42,7 +40,7 @@ class CardEditButton extends React.Component { const { editEnabled } = this.state const classes = `${style['card-edit-button']} ${style[editEnabled ? 'card-edit-button-enabled' : 'card-edit-button-disabled']}` - const myClick = editEnabled ? noop : this.enableEditHandler + const myClick = editEnabled ? () => {} : this.enableEditHandler if (!editable && disableTooltip) { return ( @@ -52,7 +50,7 @@ class CardEditButton extends React.Component { id={`${id}-card-edit-button-tooltip`} > - + ) @@ -64,7 +62,7 @@ class CardEditButton extends React.Component { return ( { e.preventDefault(); myClick() }}> - + ) @@ -82,7 +80,7 @@ CardEditButton.propTypes = { CardEditButton.defaultProps = { tooltip: '', editEnabled: false, - onClick: noop, + onClick: () => {}, } export default CardEditButton diff --git a/src/components/VmDetails/cards/DetailsCard/CloudInit/CloudInitForm.js b/src/components/VmDetails/cards/DetailsCard/CloudInit/CloudInitForm.js index c5a6d73..7453866 100644 --- a/src/components/VmDetails/cards/DetailsCard/CloudInit/CloudInitForm.js +++ b/src/components/VmDetails/cards/DetailsCard/CloudInit/CloudInitForm.js @@ -1,10 +1,10 @@ import React, { useContext } from 'react' import PropTypes from 'prop-types' import { - FormControl, - ControlLabel, FormGroup, -} from 'patternfly-react' + TextArea, + TextInput, +} from '@patternfly/react-core' import { MsgContext } from '_/intl' const CloudInitForm = ({ idPrefix, vm, onChange }) => { @@ -13,24 +13,25 @@ const CloudInitForm = ({ idPrefix, vm, onChange }) => { const cloudInitSshAuthorizedKeys = vm.getIn(['cloudInit', 'sshAuthorizedKeys']) return ( <> - - - {msg.hostName()} - - + onChange('cloudInitHostName', e.target.value)} + onChange={value => onChange('cloudInitHostName', value)} /> - - - {msg.sshAuthorizedKeys()} - - +