From 58dee8375d317080102d8ef009c94cdea7883245 Mon Sep 17 00:00:00 2001 From: AWSHurneyt Date: Mon, 9 Jan 2023 16:33:53 -0800 Subject: [PATCH] Refactored the help text elements displayed when users access the destinations list page after destinations deprecation. (#413) * Refactored the help text elements displayed when users access the destinations list page after destinations deprecation. Signed-off-by: AWSHurneyt * Refactored the help text elements displayed when users access the destinations list page after destinations deprecation. Signed-off-by: AWSHurneyt * Updated snapshot. Signed-off-by: AWSHurneyt * Updated button text. Signed-off-by: AWSHurneyt * Updated snapshot files. Signed-off-by: AWSHurneyt * Refactored landing page logic. Signed-off-by: AWSHurneyt Signed-off-by: AWSHurneyt --- .../EmptyDestinations/EmptyDestinations.js | 34 +- .../FullPageNotificationsInfoCallOut.js | 59 + .../FullPageNotificationsInfoCallOut.test.js | 20 + ...lPageNotificationsInfoCallOut.test.js.snap | 138 + .../FullPageNotificationsInfoCallOut/index.js | 8 + .../NotificationsInfoCallOut.js | 60 +- .../NotificationsInfoCallOut.test.js.snap | 66 +- .../DestinationsList/DestinationsList.js | 180 +- .../DestinationsList.test.js.snap | 4243 ++--------------- public/pages/Destinations/utils/constants.js | 3 + 10 files changed, 802 insertions(+), 4009 deletions(-) create mode 100644 public/pages/Destinations/components/FullPageNotificationsInfoCallOut/FullPageNotificationsInfoCallOut.js create mode 100644 public/pages/Destinations/components/FullPageNotificationsInfoCallOut/FullPageNotificationsInfoCallOut.test.js create mode 100644 public/pages/Destinations/components/FullPageNotificationsInfoCallOut/__snapshots__/FullPageNotificationsInfoCallOut.test.js.snap create mode 100644 public/pages/Destinations/components/FullPageNotificationsInfoCallOut/index.js diff --git a/public/pages/Destinations/components/DestinationsList/EmptyDestinations/EmptyDestinations.js b/public/pages/Destinations/components/DestinationsList/EmptyDestinations/EmptyDestinations.js index 0b6b4de9a..47d5388a4 100644 --- a/public/pages/Destinations/components/DestinationsList/EmptyDestinations/EmptyDestinations.js +++ b/public/pages/Destinations/components/DestinationsList/EmptyDestinations/EmptyDestinations.js @@ -5,11 +5,29 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { EuiButton, EuiEmptyPrompt, EuiText } from '@elastic/eui'; +import { EuiButton, EuiEmptyPrompt, EuiLink, EuiText } from '@elastic/eui'; +import { MANAGE_CHANNELS_PATH } from '../../../../CreateTrigger/utils/constants'; -const filterText = - 'There are no destinations matching your applied filters. Reset your filters to view all destinations.'; -const emptyText = 'There are no existing destinations.'; +const filterText = (hasNotificationPlugin) => + hasNotificationPlugin ? ( + <> +

+ There are no destinations matching your applied filters. Reset your filters to view all + destinations. +

+

+ Migrated destinations can be found in  + {Notifications} +

+ + ) : ( +

+ There are no destinations matching your applied filters. Reset your filters to view all + destinations. +

+ ); + +const emptyText =

There are no existing destinations.

; const resetFiltersButton = (resetFilters) => ( @@ -22,14 +40,10 @@ const propTypes = { onResetFilters: PropTypes.func.isRequired, }; -const EmptyDestinations = ({ isFilterApplied, onResetFilters }) => ( +const EmptyDestinations = ({ hasNotificationPlugin, isFilterApplied, onResetFilters }) => ( -

{isFilterApplied ? filterText : emptyText}

- - } + body={{isFilterApplied ? filterText(hasNotificationPlugin) : emptyText}} actions={isFilterApplied ? resetFiltersButton(onResetFilters) : undefined} /> ); diff --git a/public/pages/Destinations/components/FullPageNotificationsInfoCallOut/FullPageNotificationsInfoCallOut.js b/public/pages/Destinations/components/FullPageNotificationsInfoCallOut/FullPageNotificationsInfoCallOut.js new file mode 100644 index 000000000..c3f41f9fc --- /dev/null +++ b/public/pages/Destinations/components/FullPageNotificationsInfoCallOut/FullPageNotificationsInfoCallOut.js @@ -0,0 +1,59 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import React from 'react'; +import { EuiButton, EuiEmptyPrompt, EuiLink, EuiPanel, EuiText } from '@elastic/eui'; +import { MANAGE_CHANNELS_PATH } from '../../../CreateTrigger/utils/constants'; +import { NOTIFICATIONS_LEARN_MORE_HREF } from '../../utils/constants'; + +const noNotificationsTitle = 'Destinations will become channels in Notifications'; +const noNotificationsText = ( + + Destinations will be deprecated going forward. Install the Notifications plugin for a new + centralized place to manage your notification channels. + +); +const noNotificationsButton = ( + + View install instructions + +); + +const hasNotificationsTitle = 'Destinations have become channels in Notifications'; +const hasNotificationsText = ( + +

+ Your destinations have been migrated as channels in Notifications, a new centralized place to + manage your notification channels. Destinations will be deprecated going forward.  + + Learn more + +

+
+); +const hasNotificationsButton = ( + + View in Notifications + +); + +const FullPageNotificationsInfoCallOut = ({ hasNotificationPlugin }) => ( + + {hasNotificationPlugin ? hasNotificationsTitle : noNotificationsTitle}} + body={hasNotificationPlugin ? hasNotificationsText : noNotificationsText} + actions={hasNotificationPlugin ? hasNotificationsButton : noNotificationsButton} + /> + +); + +export default FullPageNotificationsInfoCallOut; diff --git a/public/pages/Destinations/components/FullPageNotificationsInfoCallOut/FullPageNotificationsInfoCallOut.test.js b/public/pages/Destinations/components/FullPageNotificationsInfoCallOut/FullPageNotificationsInfoCallOut.test.js new file mode 100644 index 000000000..9b4562d50 --- /dev/null +++ b/public/pages/Destinations/components/FullPageNotificationsInfoCallOut/FullPageNotificationsInfoCallOut.test.js @@ -0,0 +1,20 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import React from 'react'; +import { render } from 'enzyme'; + +import FullPageNotificationsInfoCallOut from './FullPageNotificationsInfoCallOut'; + +describe('FullPageNotificationsInfoCallOut', () => { + test('renders when Notifications plugin is installed', () => { + const component = ; + expect(render(component)).toMatchSnapshot(); + }); + test('renders when Notifications plugin is not installed', () => { + const component = ; + expect(render(component)).toMatchSnapshot(); + }); +}); diff --git a/public/pages/Destinations/components/FullPageNotificationsInfoCallOut/__snapshots__/FullPageNotificationsInfoCallOut.test.js.snap b/public/pages/Destinations/components/FullPageNotificationsInfoCallOut/__snapshots__/FullPageNotificationsInfoCallOut.test.js.snap new file mode 100644 index 000000000..188b52294 --- /dev/null +++ b/public/pages/Destinations/components/FullPageNotificationsInfoCallOut/__snapshots__/FullPageNotificationsInfoCallOut.test.js.snap @@ -0,0 +1,138 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`FullPageNotificationsInfoCallOut renders when Notifications plugin is installed 1`] = ` +
+
+

+ Destinations have become channels in Notifications +

+ +
+
+
+

+ Your destinations have been migrated as channels in Notifications, a new centralized place to manage your notification channels. Destinations will be deprecated going forward.  + + Learn more + +

+ + + + (opens in a new tab or window) + + +

+

+
+ + +
+`; + +exports[`FullPageNotificationsInfoCallOut renders when Notifications plugin is not installed 1`] = ` +
+
+

+ Destinations will become channels in Notifications +

+ +
+
+
+ Destinations will be deprecated going forward. Install the Notifications plugin for a new centralized place to manage your notification channels. +
+
+ + +
+`; diff --git a/public/pages/Destinations/components/FullPageNotificationsInfoCallOut/index.js b/public/pages/Destinations/components/FullPageNotificationsInfoCallOut/index.js new file mode 100644 index 000000000..fb7c78790 --- /dev/null +++ b/public/pages/Destinations/components/FullPageNotificationsInfoCallOut/index.js @@ -0,0 +1,8 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import FullPageNotificationsInfoCallOut from './FullPageNotificationsInfoCallOut'; + +export default FullPageNotificationsInfoCallOut; diff --git a/public/pages/Destinations/components/NotificationsInfoCallOut/NotificationsInfoCallOut.js b/public/pages/Destinations/components/NotificationsInfoCallOut/NotificationsInfoCallOut.js index 0a186fd61..fb8dfe1a2 100644 --- a/public/pages/Destinations/components/NotificationsInfoCallOut/NotificationsInfoCallOut.js +++ b/public/pages/Destinations/components/NotificationsInfoCallOut/NotificationsInfoCallOut.js @@ -4,23 +4,61 @@ */ import React from 'react'; -import { EuiCallOut, EuiButton, EuiSpacer } from '@elastic/eui'; +import { EuiCallOut, EuiButton, EuiLink, EuiSpacer } from '@elastic/eui'; import { MANAGE_CHANNELS_PATH } from '../../../CreateTrigger/utils/constants'; +import { NOTIFICATIONS_LEARN_MORE_HREF } from '../../utils/constants'; + +const noNotificationsTitle = 'Unable to send notifications. Notifications plugin is required.'; +const noNotificationsBodyText = ( + <> +

+ Destinations will be deprecated going forward. Install the Notifications plugin for a new + centralized place to manage your notification channels. +

+

+ Existing destinations will be automatically migrated once Notifications plugin is installed. +

+ +); +const noNotificationsButton = ( + + View install instructions + +); + +const hasNotificationsTitle = 'Destinations have become channels in Notifications.'; +const hasNotificationsBodyText = ( +

+ Your destinations have been migrated to Notifications, a new centralized place to manage your + notification channels. Destinations will be deprecated going forward.  + + Learn more + +

+); +const hasNotificationsButton = ( + View in Notifications +); const NotificationsInfoCallOut = ({ hasNotificationPlugin }) => { return (
- -

- Your destinations have been migrated to Notifications, a new centralized place to manage - your notification channels. Destinations will be deprecated going forward. -

- - {hasNotificationPlugin && ( - View Notifications - )} + + {hasNotificationPlugin ? hasNotificationsBodyText : noNotificationsBodyText} + + {hasNotificationPlugin ? hasNotificationsButton : noNotificationsButton} - +
); }; diff --git a/public/pages/Destinations/components/NotificationsInfoCallOut/__snapshots__/NotificationsInfoCallOut.test.js.snap b/public/pages/Destinations/components/NotificationsInfoCallOut/__snapshots__/NotificationsInfoCallOut.test.js.snap index 750bb13c6..c4f250a0f 100644 --- a/public/pages/Destinations/components/NotificationsInfoCallOut/__snapshots__/NotificationsInfoCallOut.test.js.snap +++ b/public/pages/Destinations/components/NotificationsInfoCallOut/__snapshots__/NotificationsInfoCallOut.test.js.snap @@ -21,8 +21,39 @@ exports[`NotificationsInfoCallOut renders when Notifications plugin is installed class="euiTextColor euiTextColor--default" >

- Your destinations have been migrated to Notifications, a new centralized place to manage your notification channels. Destinations will be deprecated going forward. + Your destinations have been migrated to Notifications, a new centralized place to manage your notification channels. Destinations will be deprecated going forward.  + + Learn more +

+ + + + (opens in a new tab or window) + + +

@@ -37,7 +68,7 @@ exports[`NotificationsInfoCallOut renders when Notifications plugin is installed - View Notifications + View in Notifications @@ -53,15 +84,18 @@ exports[`NotificationsInfoCallOut renders when Notifications plugin is installed exports[`NotificationsInfoCallOut renders when Notifications plugin is not installed 1`] = `
+
+ EuiIconMock +
- Destinations have become channels in Notifications. + Unable to send notifications. Notifications plugin is required.

- Your destinations have been migrated to Notifications, a new centralized place to manage your notification channels. Destinations will be deprecated going forward. + Destinations will be deprecated going forward. Install the Notifications plugin for a new centralized place to manage your notification channels. +

+

+ Existing destinations will be automatically migrated once Notifications plugin is installed.

diff --git a/public/pages/Destinations/containers/DestinationsList/DestinationsList.js b/public/pages/Destinations/containers/DestinationsList/DestinationsList.js index 63452970b..abdde9279 100644 --- a/public/pages/Destinations/containers/DestinationsList/DestinationsList.js +++ b/public/pages/Destinations/containers/DestinationsList/DestinationsList.js @@ -5,7 +5,14 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { EuiBasicTable, EuiHorizontalRule, EuiCallOut } from '@elastic/eui'; +import { + EuiBasicTable, + EuiCallOut, + EuiHorizontalRule, + EuiSpacer, + EuiText, + EuiTitle, +} from '@elastic/eui'; import queryString from 'query-string'; import _ from 'lodash'; import ContentPanel from '../../../../components/ContentPanel'; @@ -26,7 +33,7 @@ import { getAllowList } from '../../utils/helpers'; import { DESTINATION_TYPE } from '../../utils/constants'; import { backendErrorNotification } from '../../../../utils/helpers'; import NotificationsInfoCallOut from '../../components/NotificationsInfoCallOut'; -import NotificationsCallOut from '../../../CreateTrigger/components/NotificationsCallOut'; +import FullPageNotificationsInfoCallOut from '../../components/FullPageNotificationsInfoCallOut'; class DestinationsList extends React.Component { constructor(props) { @@ -279,6 +286,7 @@ class DestinationsList extends React.Component { render() { const { httpClient, notifications } = this.props; const { + destinations, destinationToDelete, page, queryParams: { size, search, type, sortDirection, sortField }, @@ -310,80 +318,106 @@ class DestinationsList extends React.Component { color="danger" /> ) : null} - - {!hasNotificationPlugin && } - { - this.setState({ showManageSenders: true }); - }} - onClickManageEmailGroups={() => { - this.setState({ showManageEmailGroups: true }); - }} - /> - } - > - { - this.setState({ showDeleteConfirmation: false }); - }} - onConfirm={this.handleDeleteDestination} - /> - + {isDestinationLoading || totalDestinations > 0 || isFilterApplied ? ( +
+ +

Destinations (deprecated)

+
+ + + + +

Destinations pending for migration

+
+ {hasNotificationPlugin ? ( + + Destinations that are pending migration will continue to work. + + ) : null} +
+ } + actions={ + { + this.setState({ showManageSenders: true }); + }} + onClickManageEmailGroups={() => { + this.setState({ showManageEmailGroups: true }); + }} + /> + } + > + { + this.setState({ showDeleteConfirmation: false }); + }} + onConfirm={this.handleDeleteDestination} + /> - + - - - - ) - } - onChange={this.handlePageChange} - sorting={sorting} - /> -
+ + + + + + ) + } + onChange={this.handlePageChange} + sorting={sorting} + /> + +
+ ) : ( + + )} ); } diff --git a/public/pages/Destinations/containers/DestinationsList/__snapshots__/DestinationsList.test.js.snap b/public/pages/Destinations/containers/DestinationsList/__snapshots__/DestinationsList.test.js.snap index 60098e69b..57f722ef9 100644 --- a/public/pages/Destinations/containers/DestinationsList/__snapshots__/DestinationsList.test.js.snap +++ b/public/pages/Destinations/containers/DestinationsList/__snapshots__/DestinationsList.test.js.snap @@ -47,1430 +47,155 @@ exports[`DestinationsList renders when Notification plugin is installed 1`] = ` } } > - -
- -
-
- - Destinations have become channels in Notifications. - -
- -
- -
-

- Your destinations have been migrated to Notifications, a new centralized place to manage your notification channels. Destinations will be deprecated going forward. -

- -
- -
- -
- -
- - -
- -
- - -
- -
-
- - - Notifications plugin is not installed - -
- -
- -
-

- Install the notifications plugin in order to create and select channels to send out notifications. - - - - Learn more - -

- - - - . -

-
-
-
-
-
-
- -
- -
- - - } - bodyStyles={ - Object { - "padding": "initial", - } - } - title="Destinations (deprecated)" - > - +
- + View install instructions + + } + body={ + + Destinations will be deprecated going forward. Install the Notifications plugin for a new centralized place to manage your notification channels. + + } + title={ +

+ Destinations will become channels in Notifications +

} >
- -
+

- -

- Destinations (deprecated) -

-
-

-
- + + -
-
+ + +
- +
- - -
- -
- - Actions - - } - closePopover={[Function]} - display="inlineBlock" - hasArrow={true} - id="destinationActionsPopover" - isOpen={false} - ownFocus={true} - panelPaddingSize="none" - > -
-
- - - - - -
-
-
-
-
-
-
-
+ Destinations will be deprecated going forward. Install the Notifications plugin for a new centralized place to manage your notification channels.
-
+
- -
- -
- - -
- + + +
- -
- - -
-
-
- - - - - + -
- -
- - -
-
- - - - -
- - - - - -
-
-
-
-
-
-
-
- -
- - -
-
- - - - -
- - - - - -
-
-
-
-
-
-
-
- -
- - - -
-
-
-
-
- -
-
- - } - onChange={[Function]} - pagination={ - Object { - "pageIndex": 0, - "pageSize": 20, - "pageSizeOptions": Array [ - 5, - 10, - 20, - 50, - ], - "totalItemCount": 0, - } - } - responsive={true} - sorting={ - Object { - "sort": Object { - "direction": "desc", - "field": "name", - }, - } - } - tableLayout="fixed" - > -
-
- -
- -
- -
- - -
- -
- - - - } - closePopover={[Function]} - display="inlineBlock" - hasArrow={true} - isOpen={false} - ownFocus={true} - panelPaddingSize="none" - > -
-
- - - -
-
-
-
-
-
-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ EuiIconMock + + + - -
- - - - - - - - - - - - Actions - - - - - -
-
- - - -

- There are no existing destinations. -

- - } - style={ - Object { - "maxWidth": "45em", - } - } - > -
- - - -
- -
-

- There are no existing destinations. -

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
+ View install instructions + + + + + + +
+
- + `; @@ -1521,1288 +246,155 @@ exports[`DestinationsList renders when Notification plugin is not installed 1`] } } > - -
- -
-
- - Destinations have become channels in Notifications. - -
- -
- -
-

- Your destinations have been migrated to Notifications, a new centralized place to manage your notification channels. Destinations will be deprecated going forward. -

- -
- -
- -
- -
- - -
- -
- - -
- -
-
- - - Notifications plugin is not installed - -
- -
- -
-

- Install the notifications plugin in order to create and select channels to send out notifications. - - - - Learn more - -

- - - - . -

-
-
-
-
-
-
- -
- -
- - - } - bodyStyles={ - Object { - "padding": "initial", - } - } - title="Destinations (deprecated)" - > - +
- + View install instructions + + } + body={ + + Destinations will be deprecated going forward. Install the Notifications plugin for a new centralized place to manage your notification channels. + + } + title={ +

+ Destinations will become channels in Notifications +

} >
- -
+

- -

- Destinations (deprecated) -

-
-

-
- + + -
-
+ + +
- +
- - -
- - + Destinations will be deprecated going forward. Install the Notifications plugin for a new centralized place to manage your notification channels.
- +
- -
- -
-
- -
- + + +
- -
- - -
-
-
- - - - - + -
- -
- - -
-
- - - - -
- - - - - -
-
-
-
-
-
-
-
- -
- - -
-
- - - - -
- - - - - -
-
-
-
-
-
-
-
- -
- - - -
-
-
-
-
- -
-
- - } - onChange={[Function]} - pagination={ - Object { - "pageIndex": 0, - "pageSize": 20, - "pageSizeOptions": Array [ - 5, - 10, - 20, - 50, - ], - "totalItemCount": 0, - } - } - responsive={true} - sorting={ - Object { - "sort": Object { - "direction": "desc", - "field": "name", - }, - } - } - tableLayout="fixed" - > -
-
- -
- -
- -
- - -
- -
- - - - } - closePopover={[Function]} - display="inlineBlock" - hasArrow={true} - isOpen={false} - ownFocus={true} - panelPaddingSize="none" - > -
-
- - - -
-
-
-
-
-
-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ EuiIconMock + + + - -
- - - - - - - - - - - - Actions - - - - - -
-
- - - -

- There are no existing destinations. -

- - } - style={ - Object { - "maxWidth": "45em", - } - } - > -
- - - -
- -
-

- There are no existing destinations. -

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
+ View install instructions + + + + + + +
+
- + `; @@ -2853,1323 +445,154 @@ exports[`DestinationsList renders when email is disallowed 1`] = ` } } > - -
- -
-
- - Destinations have become channels in Notifications. - -
- -
- -
-

- Your destinations have been migrated to Notifications, a new centralized place to manage your notification channels. Destinations will be deprecated going forward. -

- -
- -
- -
- -
- - -
- -
- - -
- -
-
- - - Notifications plugin is not installed - -
- -
- -
-

- Install the notifications plugin in order to create and select channels to send out notifications. - - - - Learn more - -

- - - - . -

-
-
-
-
-
-
- -
- -
- - - } - bodyStyles={ - Object { - "padding": "initial", - } - } - title="Destinations (deprecated)" - > - +
- + View install instructions + + } + body={ + + Destinations will be deprecated going forward. Install the Notifications plugin for a new centralized place to manage your notification channels. + + } + title={ +

+ Destinations will become channels in Notifications +

} >
- -
+

- -

- Destinations (deprecated) -

-
-

-
- + + -
-
+ + +
- +
- - -
- - + Destinations will be deprecated going forward. Install the Notifications plugin for a new centralized place to manage your notification channels.
- +
- -
- -
-
- -
- + + +
- -
- - -
-
-
- - - - - + -
- -
- - -
-
- - - - -
- - - - - -
-
-
-
-
-
-
-
- -
- - -
-
- - - - -
- - - - - -
-
-
-
-
-
-
-
- -
- - - -
-
-
-
-
- -
-
- - } - onChange={[Function]} - pagination={ - Object { - "pageIndex": 0, - "pageSize": 20, - "pageSizeOptions": Array [ - 5, - 10, - 20, - 50, - ], - "totalItemCount": 0, - } - } - responsive={true} - sorting={ - Object { - "sort": Object { - "direction": "desc", - "field": "name", - }, - } - } - tableLayout="fixed" - > -
-
- -
- -
- -
- - -
- -
- - - - } - closePopover={[Function]} - display="inlineBlock" - hasArrow={true} - isOpen={false} - ownFocus={true} - panelPaddingSize="none" - > -
-
- - - -
-
-
-
-
-
-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ EuiIconMock + + + - -
- - - - - - - - - - - - Actions - - - - - -
-
- - - -

- There are no existing destinations. -

- - } - style={ - Object { - "maxWidth": "45em", - } - } - > -
- - - -
- -
-

- There are no existing destinations. -

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
+ View install instructions + + + + + + +
+
- + `; diff --git a/public/pages/Destinations/utils/constants.js b/public/pages/Destinations/utils/constants.js index 16d497c49..adef6a9bc 100644 --- a/public/pages/Destinations/utils/constants.js +++ b/public/pages/Destinations/utils/constants.js @@ -18,3 +18,6 @@ export const DESTINATION_OPTIONS = [ ]; export const ALLOW_LIST_SETTING_PATH = 'plugins.alerting.destination.allow_list'; + +export const NOTIFICATIONS_LEARN_MORE_HREF = + 'https://opensearch.org/docs/monitoring-plugins/alerting/monitors/#questions-about-destinations';