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 {