Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] do not create Message component on every text change #855

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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} />;
Loading