From 7cef11ce5e9dd3848925cf26e9b1d0ac8ff64969 Mon Sep 17 00:00:00 2001 From: Amardeepsingh Siglani Date: Thu, 14 Dec 2023 18:51:42 -0800 Subject: [PATCH] do not create Message component on every text change (#854) Signed-off-by: Amardeepsingh Siglani --- .../pages/CreateTrigger/components/Action/Action.js | 12 ++++++++---- public/pages/CreateTrigger/utils/constants.js | 8 ++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/public/pages/CreateTrigger/components/Action/Action.js b/public/pages/CreateTrigger/components/Action/Action.js index 2d91e607d..8a1d1292a 100644 --- a/public/pages/CreateTrigger/components/Action/Action.js +++ b/public/pages/CreateTrigger/components/Action/Action.js @@ -26,10 +26,14 @@ import { import { FormikFieldText, FormikComboBox } from '../../../../components/FormControls'; import { isInvalid, hasError, validateActionName } from '../../../../utils/validate'; import { validateDestination } from './utils/validate'; -import { DEFAULT_ACTION_TYPE, MANAGE_CHANNELS_PATH } from '../../utils/constants'; +import { + DEFAULT_ACTION_TYPE, + MANAGE_CHANNELS_PATH, + webhookNotificationActionMessageComponent, + defaultNotificationActionMessageComponent, +} from '../../utils/constants'; import NotificationsCallOut from '../NotificationsCallOut'; import MinimalAccordion from '../../../../components/FeatureAnywhereContextMenu/MinimalAccordion'; -import Message from './actions'; const Action = ({ action, @@ -63,9 +67,9 @@ const Action = ({ let ActionComponent; const actionLabel = 'Notification'; if (type === 'webhook') { - ActionComponent = (props) => ; + ActionComponent = webhookNotificationActionMessageComponent; } else { - ActionComponent = (props) => ; + ActionComponent = defaultNotificationActionMessageComponent; } const manageChannelsUrl = httpClient.basePath.prepend(MANAGE_CHANNELS_PATH); diff --git a/public/pages/CreateTrigger/utils/constants.js b/public/pages/CreateTrigger/utils/constants.js index c4ead7335..078390081 100644 --- a/public/pages/CreateTrigger/utils/constants.js +++ b/public/pages/CreateTrigger/utils/constants.js @@ -3,6 +3,9 @@ * SPDX-License-Identifier: Apache-2.0 */ +import React from 'react'; +import Message from '../components/Action/actions'; + export const DEFAULT_MESSAGE_SOURCE = { BUCKET_LEVEL_MONITOR: ` Monitor {{ctx.monitor.name}} just entered alert status. Please investigate the issue. @@ -77,3 +80,8 @@ 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) => ( + +); +export const defaultNotificationActionMessageComponent = (props) => ;