Skip to content

Commit

Permalink
do not create Message component on every text change (opensearch-proj…
Browse files Browse the repository at this point in the history
…ect#854)

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>
  • Loading branch information
amsiglan authored Dec 15, 2023
1 parent 9abddfa commit 7cef11c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
12 changes: 8 additions & 4 deletions public/pages/CreateTrigger/components/Action/Action.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -63,9 +67,9 @@ const Action = ({
let ActionComponent;
const actionLabel = 'Notification';
if (type === 'webhook') {
ActionComponent = (props) => <Message isSubjectDisabled {...props} />;
ActionComponent = webhookNotificationActionMessageComponent;
} else {
ActionComponent = (props) => <Message {...props} />;
ActionComponent = defaultNotificationActionMessageComponent;
}

const manageChannelsUrl = httpClient.basePath.prepend(MANAGE_CHANNELS_PATH);
Expand Down
8 changes: 8 additions & 0 deletions public/pages/CreateTrigger/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) => (
<Message isSubjectDisabled {...props} />
);
export const defaultNotificationActionMessageComponent = (props) => <Message {...props} />;

0 comments on commit 7cef11c

Please sign in to comment.