From aed9d7485e5fab5ce6981b7837b3932c0811921e Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Thu, 4 Apr 2024 08:27:03 +0000
Subject: [PATCH] Include server.basepath config in the manage notifications
channel Url (#914)
* refactored code to always include the server.basepath for manager channels url
Signed-off-by: Amardeepsingh Siglani
* refactored code
Signed-off-by: Amardeepsingh Siglani
---------
Signed-off-by: Amardeepsingh Siglani
(cherry picked from commit 1ac71bc83d53b8f03f6b8bfaf2b5f5a442d13880)
Signed-off-by: github-actions[bot]
---
public/app.js | 3 ++
.../CreateTrigger/components/Action/Action.js | 6 ++--
.../ActionEmptyPrompt/ActionEmptyPrompt.js | 5 ++-
.../ConfigureActions/ConfigureActions.js | 2 --
.../TriggerNotificationsContent.js | 5 +--
public/pages/CreateTrigger/utils/constants.js | 2 --
.../EmptyDestinations/EmptyDestinations.js | 4 +--
.../FullPageNotificationsInfoCallOut.js | 33 ++++++++++---------
.../NotificationsInfoCallOut.js | 9 ++---
public/utils/helpers.js | 12 +++++++
10 files changed, 47 insertions(+), 34 deletions(-)
diff --git a/public/app.js b/public/app.js
index 7e6c91eb2..be65b6230 100644
--- a/public/app.js
+++ b/public/app.js
@@ -14,6 +14,7 @@ import './app.scss';
import Main from './pages/Main';
import { CoreContext } from './utils/CoreContext';
import { ServicesContext, NotificationService } from './services';
+import { initManageChannelsUrl } from './utils/helpers';
export function renderApp(coreStart, params) {
const isDarkMode = coreStart.uiSettings.get('theme:darkMode') || false;
@@ -29,6 +30,8 @@ export function renderApp(coreStart, params) {
require('@elastic/charts/dist/theme_only_light.css');
}
+ initManageChannelsUrl(coreStart.http);
+
// render react to DOM
ReactDOM.render(
diff --git a/public/pages/CreateTrigger/components/Action/Action.js b/public/pages/CreateTrigger/components/Action/Action.js
index 8a1d1292a..3354910a6 100644
--- a/public/pages/CreateTrigger/components/Action/Action.js
+++ b/public/pages/CreateTrigger/components/Action/Action.js
@@ -28,12 +28,12 @@ import { isInvalid, hasError, validateActionName } from '../../../../utils/valid
import { validateDestination } from './utils/validate';
import {
DEFAULT_ACTION_TYPE,
- MANAGE_CHANNELS_PATH,
webhookNotificationActionMessageComponent,
defaultNotificationActionMessageComponent,
} from '../../utils/constants';
import NotificationsCallOut from '../NotificationsCallOut';
import MinimalAccordion from '../../../../components/FeatureAnywhereContextMenu/MinimalAccordion';
+import { getManageChannelsUrl } from '../../../../utils/helpers';
const Action = ({
action,
@@ -45,7 +45,6 @@ const Action = ({
onDelete,
sendTestMessage,
setFlyout,
- httpClient,
fieldPath,
values,
hasNotificationPlugin,
@@ -72,7 +71,6 @@ const Action = ({
ActionComponent = defaultNotificationActionMessageComponent;
}
- const manageChannelsUrl = httpClient.basePath.prepend(MANAGE_CHANNELS_PATH);
const isFirstAction = index !== undefined && index === 0;
const refreshDestinations = useMemo(() => {
const refresh = async () => {
@@ -169,7 +167,7 @@ const Action = ({
disabled={!hasNotificationPlugin}
iconType="popout"
iconSide="right"
- onClick={() => window.open(manageChannelsUrl)}
+ onClick={() => window.open(getManageChannelsUrl())}
>
Manage channels
diff --git a/public/pages/CreateTrigger/components/ActionEmptyPrompt/ActionEmptyPrompt.js b/public/pages/CreateTrigger/components/ActionEmptyPrompt/ActionEmptyPrompt.js
index b376b3f2a..30087f457 100644
--- a/public/pages/CreateTrigger/components/ActionEmptyPrompt/ActionEmptyPrompt.js
+++ b/public/pages/CreateTrigger/components/ActionEmptyPrompt/ActionEmptyPrompt.js
@@ -6,7 +6,7 @@
import React from 'react';
import { EuiButton, EuiEmptyPrompt, EuiText } from '@elastic/eui';
import AddActionButton from '../AddActionButton';
-import { MANAGE_CHANNELS_PATH } from '../../utils/constants';
+import { getManageChannelsUrl } from '../../../../utils/helpers';
const actionEmptyText = 'Add an action to perform when this trigger is triggered.';
const destinationEmptyText = 'There are no existing channels. Add a channel to create an action.';
@@ -14,7 +14,6 @@ const destinationEmptyText = 'There are no existing channels. Add a channel to c
const ActionEmptyPrompt = ({
arrayHelpers,
hasDestinations,
- httpClient,
hasNotificationPlugin,
flyoutMode,
onPostAdd,
@@ -39,7 +38,7 @@ const ActionEmptyPrompt = ({
disabled={!hasNotificationPlugin}
iconType="popout"
iconSide="right"
- onClick={() => window.open(httpClient.basePath.prepend(MANAGE_CHANNELS_PATH))}
+ onClick={() => window.open(getManageChannelsUrl())}
>
Manage channels
diff --git a/public/pages/CreateTrigger/containers/ConfigureActions/ConfigureActions.js b/public/pages/CreateTrigger/containers/ConfigureActions/ConfigureActions.js
index 8b2cc9701..71952d654 100644
--- a/public/pages/CreateTrigger/containers/ConfigureActions/ConfigureActions.js
+++ b/public/pages/CreateTrigger/containers/ConfigureActions/ConfigureActions.js
@@ -338,7 +338,6 @@ class ConfigureActions extends React.Component {
}}
sendTestMessage={this.sendTestMessage}
setFlyout={setFlyout}
- httpClient={httpClient}
fieldPath={fieldPath}
values={values}
hasNotificationPlugin={hasNotificationPlugin}
@@ -356,7 +355,6 @@ class ConfigureActions extends React.Component {
this.onAccordionToggle(initialValues.id)}
diff --git a/public/pages/CreateTrigger/containers/DefineCompositeLevelTrigger/TriggerNotificationsContent.js b/public/pages/CreateTrigger/containers/DefineCompositeLevelTrigger/TriggerNotificationsContent.js
index 839bced55..afa7cfa0c 100644
--- a/public/pages/CreateTrigger/containers/DefineCompositeLevelTrigger/TriggerNotificationsContent.js
+++ b/public/pages/CreateTrigger/containers/DefineCompositeLevelTrigger/TriggerNotificationsContent.js
@@ -8,9 +8,10 @@ import { EuiPanel, EuiFlexGroup, EuiFlexItem, EuiButtonEmpty, EuiSpacer } from '
import { FormikComboBox } from '../../../../components/FormControls';
import NotificationConfigDialog from './NotificationConfigDialog';
import _ from 'lodash';
-import { FORMIK_INITIAL_ACTION_VALUES, MANAGE_CHANNELS_PATH } from '../../utils/constants';
+import { FORMIK_INITIAL_ACTION_VALUES } from '../../utils/constants';
import { NOTIFY_OPTIONS_VALUES } from '../../components/Action/actions/Message';
import { required } from '../../../../utils/validate';
+import { getManageChannelsUrl } from '../../../../utils/helpers';
const TriggerNotificationsContent = ({
action,
@@ -97,7 +98,7 @@ const TriggerNotificationsContent = ({
iconType={'popout'}
style={{ marginTop: '22px' }}
disabled={!hasNotifications}
- onClick={() => window.open(httpClient.basePath.prepend(MANAGE_CHANNELS_PATH))}
+ onClick={() => window.open(getManageChannelsUrl())}
>
Manage channels
diff --git a/public/pages/CreateTrigger/utils/constants.js b/public/pages/CreateTrigger/utils/constants.js
index 078390081..802034b5f 100644
--- a/public/pages/CreateTrigger/utils/constants.js
+++ b/public/pages/CreateTrigger/utils/constants.js
@@ -79,8 +79,6 @@ export const AND_OR_CONDITION_OPTIONS = [
export const DEFAULT_TRIGGER_NAME = 'New trigger';
export const DEFAULT_ACTION_TYPE = 'slack';
-export const MANAGE_CHANNELS_PATH = `/app/notifications-dashboards#/channels`;
-
export const webhookNotificationActionMessageComponent = (props) => (
);
diff --git a/public/pages/Destinations/components/DestinationsList/EmptyDestinations/EmptyDestinations.js b/public/pages/Destinations/components/DestinationsList/EmptyDestinations/EmptyDestinations.js
index 47d5388a4..89a3e82dc 100644
--- a/public/pages/Destinations/components/DestinationsList/EmptyDestinations/EmptyDestinations.js
+++ b/public/pages/Destinations/components/DestinationsList/EmptyDestinations/EmptyDestinations.js
@@ -6,7 +6,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { EuiButton, EuiEmptyPrompt, EuiLink, EuiText } from '@elastic/eui';
-import { MANAGE_CHANNELS_PATH } from '../../../../CreateTrigger/utils/constants';
+import { getManageChannelsUrl } from '../../../../../utils/helpers';
const filterText = (hasNotificationPlugin) =>
hasNotificationPlugin ? (
@@ -17,7 +17,7 @@ const filterText = (hasNotificationPlugin) =>
Migrated destinations can be found in
- {Notifications}
+ {Notifications}
>
) : (
diff --git a/public/pages/Destinations/components/FullPageNotificationsInfoCallOut/FullPageNotificationsInfoCallOut.js b/public/pages/Destinations/components/FullPageNotificationsInfoCallOut/FullPageNotificationsInfoCallOut.js
index c3f41f9fc..9025a3354 100644
--- a/public/pages/Destinations/components/FullPageNotificationsInfoCallOut/FullPageNotificationsInfoCallOut.js
+++ b/public/pages/Destinations/components/FullPageNotificationsInfoCallOut/FullPageNotificationsInfoCallOut.js
@@ -5,8 +5,8 @@
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';
+import { getManageChannelsUrl } from '../../../../utils/helpers';
const noNotificationsTitle = 'Destinations will become channels in Notifications';
const noNotificationsText = (
@@ -40,20 +40,23 @@ const hasNotificationsText = (
);
-const hasNotificationsButton = (
-
- View in Notifications
-
-);
-const FullPageNotificationsInfoCallOut = ({ hasNotificationPlugin }) => (
-
- {hasNotificationPlugin ? hasNotificationsTitle : noNotificationsTitle}}
- body={hasNotificationPlugin ? hasNotificationsText : noNotificationsText}
- actions={hasNotificationPlugin ? hasNotificationsButton : noNotificationsButton}
- />
-
-);
+const FullPageNotificationsInfoCallOut = ({ hasNotificationPlugin }) => {
+ const hasNotificationsButton = (
+
+ View in Notifications
+
+ );
+
+ return (
+
+ {hasNotificationPlugin ? hasNotificationsTitle : noNotificationsTitle}}
+ body={hasNotificationPlugin ? hasNotificationsText : noNotificationsText}
+ actions={hasNotificationPlugin ? hasNotificationsButton : noNotificationsButton}
+ />
+
+ );
+}
export default FullPageNotificationsInfoCallOut;
diff --git a/public/pages/Destinations/components/NotificationsInfoCallOut/NotificationsInfoCallOut.js b/public/pages/Destinations/components/NotificationsInfoCallOut/NotificationsInfoCallOut.js
index fb8dfe1a2..bfe9df8e7 100644
--- a/public/pages/Destinations/components/NotificationsInfoCallOut/NotificationsInfoCallOut.js
+++ b/public/pages/Destinations/components/NotificationsInfoCallOut/NotificationsInfoCallOut.js
@@ -5,8 +5,8 @@
import React from 'react';
import { EuiCallOut, EuiButton, EuiLink, EuiSpacer } from '@elastic/eui';
-import { MANAGE_CHANNELS_PATH } from '../../../CreateTrigger/utils/constants';
import { NOTIFICATIONS_LEARN_MORE_HREF } from '../../utils/constants';
+import { getManageChannelsUrl } from '../../../../utils/helpers';
const noNotificationsTitle = 'Unable to send notifications. Notifications plugin is required.';
const noNotificationsBodyText = (
@@ -42,11 +42,12 @@ const hasNotificationsBodyText = (
);
-const hasNotificationsButton = (
- View in Notifications
-);
const NotificationsInfoCallOut = ({ hasNotificationPlugin }) => {
+ const hasNotificationsButton = (
+ View in Notifications
+ );
+
return (
(
)}
>
);
+
+// This is updated to include the server.basepath during plugin's first render inside app.js using `initManageChannelsUrl` function
+export let MANAGE_CHANNELS_URL = '/app/notifications-dashboards#/channels';
+
+export function initManageChannelsUrl(httpClient) {
+ const manageChannelsRelativePath = `/app/notifications-dashboards#/channels`;
+ MANAGE_CHANNELS_URL = httpClient.basePath.prepend(manageChannelsRelativePath);
+}
+
+export function getManageChannelsUrl() {
+ return MANAGE_CHANNELS_URL;
+}