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

Fixed adding an extra space character on selecting alert variable in action text fields #70028

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const EmailParamsFields = ({
const onSelectMessageVariable = (paramsProperty: string, variable: string) => {
editAction(
paramsProperty,
((actionParams as any)[paramsProperty] ?? '').concat(` {{${variable}}}`),
!(actionParams as any)[paramsProperty] ? `{{${variable}}}` : ` {{${variable}}}`,
YulNaumenko marked this conversation as resolved.
Show resolved Hide resolved
index
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const IndexParamsFields = ({
documents && documents.length > 0 ? documents[0] : null
);
const onSelectMessageVariable = (variable: string) => {
const value = (xJson ?? '').concat(` {{${variable}}}`);
const value = !xJson ? `{{${variable}}}` : ` {{${variable}}}`;
setXJson(value);
// Keep the documents in sync with the editor content
onDocumentsChange(convertToJson(value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const PagerDutyParamsFields: React.FunctionComponent<ActionParamsProps<PagerDuty
const onSelectMessageVariable = (paramsProperty: string, variable: string) => {
editAction(
paramsProperty,
((actionParams as any)[paramsProperty] ?? '').concat(` {{${variable}}}`),
!(actionParams as any)[paramsProperty] ? `{{${variable}}}` : ` {{${variable}}}`,
index
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const ServerLogParamsFields: React.FunctionComponent<ActionParamsProps<
}, []);

const onSelectMessageVariable = (paramsProperty: string, variable: string) => {
editAction(paramsProperty, (message ?? '').concat(` {{${variable}}}`), index);
editAction(paramsProperty, !message ? `{{${variable}}}` : ` {{${variable}}}`, index);
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const SlackParamsFields: React.FunctionComponent<ActionParamsProps<SlackActionPa
}, []);

const onSelectMessageVariable = (paramsProperty: string, variable: string) => {
editAction(paramsProperty, (message ?? '').concat(` {{${variable}}}`), index);
editAction(paramsProperty, !message ? `{{${variable}}}` : ` {{${variable}}}`, index);
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const WebhookParamsFields: React.FunctionComponent<ActionParamsProps<WebhookActi
}) => {
const { body } = actionParams;
const onSelectMessageVariable = (paramsProperty: string, variable: string) => {
editAction(paramsProperty, (body ?? '').concat(` {{${variable}}}`), index);
editAction(paramsProperty, !body ? `{{${variable}}}` : ` {{${variable}}}`, index);
};
return (
<Fragment>
Expand Down