From cc27e8076ca3520b892a0b5e83a425e8a7c844c2 Mon Sep 17 00:00:00 2001 From: Scott Dickerson Date: May 18 2022 17:44:04 +0000 Subject: Revert "Replace PF3 Alerts" --- diff --git a/src/actions/error.js b/src/actions/error.js index 9e2f1a1..d6119c4 100644 --- a/src/actions/error.js +++ b/src/actions/error.js @@ -13,7 +13,7 @@ export function extractErrorText (exception: Object): string { : (exception.statusText || 'UNKNOWN') } -export function failedExternalAction ({ message, titleDescriptor, messageDescriptor, exception, failedAction }: FailedExternalActionInputType): FailedExternalActionType { +export function failedExternalAction ({ message, messageDescriptor, exception, failedAction }: FailedExternalActionInputType): FailedExternalActionType { if (exception) { message = message || extractErrorText(exception) message = customizeErrorMessage(message) @@ -25,7 +25,6 @@ export function failedExternalAction ({ message, titleDescriptor, messageDescrip payload: { message, messageDescriptor, - titleDescriptor, type, failedAction, }, @@ -35,9 +34,8 @@ export function failedExternalAction ({ message, titleDescriptor, messageDescrip return { type: FAILED_EXTERNAL_ACTION, payload: { - message, messageDescriptor, - titleDescriptor, + message, failedAction, }, } diff --git a/src/actions/types.js b/src/actions/types.js index be4f2bf..854e25c 100644 --- a/src/actions/types.js +++ b/src/actions/types.js @@ -38,7 +38,6 @@ export type MessageDescriptorType = { export type FailedExternalActionInputType = { message: string, messageDescriptor: ?MessageDescriptorType, - titleDescriptor: ?MessageDescriptorType, exception?: Object, failedAction?: Object } @@ -49,7 +48,6 @@ export type FailedExternalActionType = { message: string, failedAction?: Object, messageDescriptor: ?MessageDescriptorType, - titleDescriptor: ?MessageDescriptorType, type?: number | 'ERROR' } } diff --git a/src/components/CounterAlert.js b/src/components/CounterAlert.js index f4a9d24..b50cde1 100644 --- a/src/components/CounterAlert.js +++ b/src/components/CounterAlert.js @@ -2,7 +2,7 @@ import React from 'react' import PropTypes from 'prop-types' -import { Alert, AlertActionCloseButton } from '@patternfly/react-core' +import { Alert } from 'patternfly-react' import style from './sharedStyle.css' class CounterAlert extends React.Component { @@ -45,13 +45,10 @@ class CounterAlert extends React.Component { render () { const { title, type, children } = this.props return this.state.showAlert && ( - } - className={style['text-align-left']} - title={title} - children={children} - /> + + {title} + {children} + ) } } diff --git a/src/components/CreateVmWizard/steps/SummaryReview.js b/src/components/CreateVmWizard/steps/SummaryReview.js index b87819f..26f1f61 100644 --- a/src/components/CreateVmWizard/steps/SummaryReview.js +++ b/src/components/CreateVmWizard/steps/SummaryReview.js @@ -1,8 +1,7 @@ import React, { useContext } from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' -import { Icon, Spinner, Label } from 'patternfly-react' -import { Alert } from '@patternfly/react-core' +import { Alert, Icon, Spinner, Label } from 'patternfly-react' import { InfoCircleIcon } from '@patternfly/react-icons' import { MsgContext, enumMsg } from '_/intl' @@ -291,13 +290,13 @@ const SummaryReview = ({ {msg.createVmWizardReviewSuccess()} { progress.messages && progress.messages.length > 0 && ( - { - progress.messages.map((message, index) => ( -
- { message } -
- )) - } + + {progress.messages.map((message, index) => ( +
+ { message } +
+ ) + )}
)} @@ -311,13 +310,13 @@ const SummaryReview = ({ {msg.createVmWizardReviewError()} { progress.messages && progress.messages.length > 0 && ( - { - progress.messages.map((message, index) => ( -
- { message } -
- )) - } + + {progress.messages.map((message, index) => ( +
+ { message } +
+ ) + )}
)} diff --git a/src/components/NavigationConfirmationModal/index.js b/src/components/NavigationConfirmationModal/index.js index cc2c202..419ed3f 100644 --- a/src/components/NavigationConfirmationModal/index.js +++ b/src/components/NavigationConfirmationModal/index.js @@ -1,7 +1,6 @@ import React, { useContext } from 'react' import PropTypes from 'prop-types' -import { Modal, Button } from 'patternfly-react' -import { Alert } from '@patternfly/react-core' +import { Modal, Button, Alert } from 'patternfly-react' import { MsgContext } from '_/intl' const NavigationConfirmationModal = ({ show, onYes, onNo, additionalNote }) => { @@ -14,15 +13,8 @@ const NavigationConfirmationModal = ({ show, onYes, onNo, additionalNote }) => { {msg.unsavedChangesTitle()} - - {additionalNote} - + {msg.unsavedChangesConfirmMessage()} + {additionalNote} diff --git a/src/components/Settings/Settings.js b/src/components/Settings/Settings.js index ac61370..82a87eb 100644 --- a/src/components/Settings/Settings.js +++ b/src/components/Settings/Settings.js @@ -130,7 +130,7 @@ const Settings = ({ { partialSave.show && ( {msg.failedToSaveChangesToFields()}

} onDismiss={() => resetNotifications(setShowPartialSave, { show: false, fields: [] })} > @@ -140,7 +140,7 @@ const Settings = ({ { showCompleteFailure && ( resetNotifications(setShowCompleteFailure, false)} /> diff --git a/src/components/ToastNotifications.js b/src/components/ToastNotifications.js index 964df45..2218778 100644 --- a/src/components/ToastNotifications.js +++ b/src/components/ToastNotifications.js @@ -2,68 +2,36 @@ import React from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' -import { Alert, AlertGroup, AlertActionCloseButton } from '@patternfly/react-core' +import { TimedToastNotification, ToastNotificationList } from 'patternfly-react' import { setNotificationNotified } from '_/actions' import { withMsg } from '_/intl' -import { buildMessageFromRecord, translate } from '_/helpers' +import { buildMessageFromRecord } from '_/helpers' import style from './sharedStyle.css' function normalizeType (theType) { theType = String(theType).toLowerCase() - // PF4 statuses - if (['default', 'warning', 'success', 'info', 'danger'].includes(theType)) { - return theType - } - - // 'error' (used in PF3) was replaced by 'danger' - return theType === 'error' ? 'danger' : 'warning' -} - -function buildTitle ({ id, params } = {}, msg, type) { - if (!id) { - // no title provide - generate one based on type - return mapTypeToTitle(msg, type) - } - return translate({ id, params, msg }) -} - -function mapTypeToTitle (msg, type) { - switch (type) { - case 'warning': - return msg.warning() - case 'danger': - return msg.error() - case 'success': - return msg.success() - case 'info': - default: - return msg.info() - } + const isExpected = ['error', 'warning', 'success', 'info', 'danger'].includes(theType) + return isExpected ? theType : 'warning' } const ToastNotifications = ({ userMessages, onDismissNotification, msg }) => { return ( - - { userMessages.get('records').toJS().filter(({ notified }) => !notified).map(r => ( - + { userMessages.get('records').filter(r => !r.get('notified')).map(r => ( + onDismissNotification(r.id)} - actionClose={( - onDismissNotification(r.id)} - /> - )} - key={r.time} + type={normalizeType(r.get('type'))} + onDismiss={() => onDismissNotification(r.get('id'))} + key={r.get('time')} > - {buildMessageFromRecord(r, msg)} - + + {buildMessageFromRecord(r.toJS(), msg)} + + ) )} - + ) } diff --git a/src/components/VmDetails/cards/DetailsCard/index.js b/src/components/VmDetails/cards/DetailsCard/index.js index 0cc19fd..fb786dc 100644 --- a/src/components/VmDetails/cards/DetailsCard/index.js +++ b/src/components/VmDetails/cards/DetailsCard/index.js @@ -34,12 +34,13 @@ import { } from '_/components/utils' import { + Alert, ExpandCollapse, FormControl, Icon, } from 'patternfly-react' -import { Switch, Alert } from '@patternfly/react-core' +import { Switch } from '@patternfly/react-core' import SelectBox from '_/components/SelectBox' import BaseCard from '../../BaseCard' @@ -1093,13 +1094,9 @@ class DetailsCard extends React.Component { ) } { correlatedMessages && correlatedMessages.size > 0 && correlatedMessages.map((message, key) => ( - + + {buildMessageFromRecord(message.toJS(), msg)} + ))} ) diff --git a/src/components/VmDetails/cards/OverviewCard/index.js b/src/components/VmDetails/cards/OverviewCard/index.js index e74e2ba..a4f1b76 100644 --- a/src/components/VmDetails/cards/OverviewCard/index.js +++ b/src/components/VmDetails/cards/OverviewCard/index.js @@ -9,8 +9,7 @@ import { generateUnique, buildMessageFromRecord } from '_/helpers' import { formatUptimeDuration } from '_/utils' import { editVm } from '_/actions' -import { FormControl, FormGroup, HelpBlock, Checkbox } from 'patternfly-react' -import { Alert } from '@patternfly/react-core' +import { FormControl, FormGroup, HelpBlock, Alert, Checkbox } from 'patternfly-react' import BaseCard from '../../BaseCard' import VmIcon from '../../../VmIcon' @@ -299,14 +298,9 @@ class OverviewCard extends React.Component { { correlatedMessages && correlatedMessages.size > 0 && correlatedMessages.map((message, key) => ( - + + {buildMessageFromRecord(message.toJS(), msg)} + ) ) } diff --git a/src/components/VmDetails/cards/SnapshotsCard/NewSnapshotModal.js b/src/components/VmDetails/cards/SnapshotsCard/NewSnapshotModal.js index 1d6b953..d338293 100644 --- a/src/components/VmDetails/cards/SnapshotsCard/NewSnapshotModal.js +++ b/src/components/VmDetails/cards/SnapshotsCard/NewSnapshotModal.js @@ -5,6 +5,7 @@ import { connect } from 'react-redux' import { addVmSnapshot } from './actions' import { + Alert, Button, Col, Form, @@ -16,7 +17,6 @@ import { Modal, noop, } from 'patternfly-react' -import { Alert } from '@patternfly/react-core' import { withMsg } from '_/intl' import style from './style.css' @@ -94,13 +94,8 @@ class NewSnapshotModal extends Component {
- - {msg.snapshotInfo() } + + { msg.snapshotInfo() } diff --git a/src/components/VmDetails/index.js b/src/components/VmDetails/index.js index ae0c193..6467cb6 100644 --- a/src/components/VmDetails/index.js +++ b/src/components/VmDetails/index.js @@ -1,7 +1,6 @@ import React from 'react' import PropTypes from 'prop-types' -import { Card, CardBody } from 'patternfly-react' -import { Alert } from '@patternfly/react-core' +import { Alert, Card, CardBody } from 'patternfly-react' import { withMsg } from '_/intl' import styles from './style.css' @@ -64,7 +63,7 @@ class VmDetailsContainer extends React.Component { - + {msg.vmHasPendingConfigurationChanges()} diff --git a/src/intl/messages.js b/src/intl/messages.js index 37dc585..de30771 100644 --- a/src/intl/messages.js +++ b/src/intl/messages.js @@ -343,7 +343,6 @@ export const messages: { [messageId: string]: MessageType } = { message: 'Not responding', description: 'VM is not responding. One of states of a virtual machine. Other are e.g. Up, Down, Powering-Up', }, - error: 'Error', errorWhileCreatingNewDisk: 'Error while creating new disk:', every30Seconds: 'Every 30 seconds', everyMinute: 'Every minute', @@ -406,7 +405,6 @@ export const messages: { [messageId: string]: MessageType } = { htmlUnsupportedOvirtVersionFoundButVersionAtLeastRequired: 'Unsupported {version} {productName} version found, but at least version {requiredVersion} is required.', icon: 'Icon', ifVmIsRunningClickToAccessItsGraphicsConsole: 'If the virtual machine is running, click the protocol name to access its Graphical Console.', - info: 'Information', inPreview: 'In Preview', ieNotSupported: 'Internet Explorer is not a supported browser.', ipAddress: { message: 'IP Address', description: 'Label for IP addresses reported by VM guest agent' }, @@ -651,7 +649,6 @@ export const messages: { [messageId: string]: MessageType } = { message: '({size} {unit} free)', description: 'Show the amount of free space a storage domain has when rendered in a select list of storage domains', }, - success: 'Success', suspend: 'Suspend', suspendVm: 'Suspend the VM', suspendVmQuestion: 'Are you sure you want to Suspend the VM?', @@ -794,7 +791,6 @@ export const messages: { [messageId: string]: MessageType } = { vncOptions: 'VNC Options', vnicProfile: 'VNIC Profile', vnicProfileEmpty: '', - warning: 'Warning', yes: 'Yes', youHaveNoAllowedVnicProfiles: 'You cannot create or edit NICs because you do not have permission to use any vNIC Profiles in the VM\'s Data Center.', } diff --git a/src/reducers/userMessages.js b/src/reducers/userMessages.js index 4e724e4..cd202fb 100644 --- a/src/reducers/userMessages.js +++ b/src/reducers/userMessages.js @@ -16,14 +16,13 @@ import uniqueId from 'lodash/uniqueId' import type { FailedExternalActionType } from '_/actions/types' -function addLogEntry ({ state, message, type = 'ERROR', failedAction, messageDescriptor, titleDescriptor }: any): any { +function addLogEntry ({ state, message, type = 'ERROR', failedAction, messageDescriptor }: any): any { // TODO: use seq return state .update('records', records => records.unshift(Immutable.fromJS({ id: uniqueId(), message, messageDescriptor, - titleDescriptor, type, failedAction, time: Date.now(), @@ -43,12 +42,11 @@ const initialState = Immutable.fromJS({ const userMessages: any = actionReducer(initialState, { // Log external action failures (i.e. AJAX calls) as user messages - [FAILED_EXTERNAL_ACTION] (state: any, { payload: { message, messageDescriptor, titleDescriptor, type, failedAction } }: FailedExternalActionType): any { + [FAILED_EXTERNAL_ACTION] (state: any, { payload: { message, messageDescriptor, type, failedAction } }: FailedExternalActionType): any { return addLogEntry({ state, message, messageDescriptor, - titleDescriptor, type, failedAction, }) diff --git a/src/sagas/utils.js b/src/sagas/utils.js index 2118e46..1885b3b 100644 --- a/src/sagas/utils.js +++ b/src/sagas/utils.js @@ -77,15 +77,15 @@ export function* callExternalAction (method, action = {}, canBeMissing = false) yield put(checkTokenExpired()) } - let titleDescriptor = shortErrorMessage({ action }) + let messageDescriptor = shortErrorMessage({ action }) if (e.status === 0 && e.statusText === 'error') { // special case, mixing https and http - titleDescriptor = { id: 'apiConnectionFailed' } + messageDescriptor = { id: 'apiConnectionFailed' } e.statusText = 'Unable to connect to oVirt REST API. Please check URL and protocol (https).' } yield put(failedExternalAction({ exception: e, - titleDescriptor, + messageDescriptor, failedAction: action, })) }