Skip to content

Commit d88a0b2

Browse files
do not create Message component on every text change (#854)
Signed-off-by: Amardeepsingh Siglani <[email protected]> (cherry picked from commit 7cef11c) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 59ea0e3 commit d88a0b2

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

public/pages/CreateTrigger/components/Action/Action.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ import {
2626
import { FormikFieldText, FormikComboBox } from '../../../../components/FormControls';
2727
import { isInvalid, hasError, validateActionName } from '../../../../utils/validate';
2828
import { validateDestination } from './utils/validate';
29-
import { DEFAULT_ACTION_TYPE, MANAGE_CHANNELS_PATH } from '../../utils/constants';
29+
import {
30+
DEFAULT_ACTION_TYPE,
31+
MANAGE_CHANNELS_PATH,
32+
webhookNotificationActionMessageComponent,
33+
defaultNotificationActionMessageComponent,
34+
} from '../../utils/constants';
3035
import NotificationsCallOut from '../NotificationsCallOut';
3136
import MinimalAccordion from '../../../../components/FeatureAnywhereContextMenu/MinimalAccordion';
32-
import Message from './actions';
3337

3438
const Action = ({
3539
action,
@@ -63,9 +67,9 @@ const Action = ({
6367
let ActionComponent;
6468
const actionLabel = 'Notification';
6569
if (type === 'webhook') {
66-
ActionComponent = (props) => <Message isSubjectDisabled {...props} />;
70+
ActionComponent = webhookNotificationActionMessageComponent;
6771
} else {
68-
ActionComponent = (props) => <Message {...props} />;
72+
ActionComponent = defaultNotificationActionMessageComponent;
6973
}
7074

7175
const manageChannelsUrl = httpClient.basePath.prepend(MANAGE_CHANNELS_PATH);

public/pages/CreateTrigger/utils/constants.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6+
import React from 'react';
7+
import Message from '../components/Action/actions';
8+
69
export const DEFAULT_MESSAGE_SOURCE = {
710
BUCKET_LEVEL_MONITOR: `
811
Monitor {{ctx.monitor.name}} just entered alert status. Please investigate the issue.
@@ -77,3 +80,8 @@ export const DEFAULT_TRIGGER_NAME = 'New trigger';
7780
export const DEFAULT_ACTION_TYPE = 'slack';
7881

7982
export const MANAGE_CHANNELS_PATH = `/app/notifications-dashboards#/channels`;
83+
84+
export const webhookNotificationActionMessageComponent = (props) => (
85+
<Message isSubjectDisabled {...props} />
86+
);
87+
export const defaultNotificationActionMessageComponent = (props) => <Message {...props} />;

0 commit comments

Comments
 (0)