From 0634b8d73f8dfb5c91f58fc4b5115fadde8c2163 Mon Sep 17 00:00:00 2001 From: maria-hambardzumian <164881199+maria-hambardzumian@users.noreply.github.com> Date: Mon, 13 May 2024 14:43:30 +0400 Subject: [PATCH] EPMRPP-90888 || Possible to create 2 Slack notification rules (#3828) * EPMRPP-90888 || Possible to create 2 Slack notification rules * EPMRPP-90888 || Possible to create 2 Slack notification rules * EPMRPP-90888 || Code Review fix - 1 * EPMRPP-90888 || Code Review fix - 2 --- .../notificationRuleContent/notificationRuleContent.jsx | 6 +++--- .../content/elements/ruleList/propTypes.js | 2 ++ .../content/elements/ruleList/ruleList.jsx | 3 ++- .../content/notifications/constants.js | 1 + .../addEditNotificationModal/addEditNotificationModal.jsx | 3 ++- .../content/notifications/ruleGroup/ruleGroup.jsx | 2 +- .../content/notifications/utils.js | 2 +- 7 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/src/pages/inside/projectSettingsPageContainer/content/elements/notificationRuleContent/notificationRuleContent.jsx b/app/src/pages/inside/projectSettingsPageContainer/content/elements/notificationRuleContent/notificationRuleContent.jsx index 1c9a061660..e3b03270da 100644 --- a/app/src/pages/inside/projectSettingsPageContainer/content/elements/notificationRuleContent/notificationRuleContent.jsx +++ b/app/src/pages/inside/projectSettingsPageContainer/content/elements/notificationRuleContent/notificationRuleContent.jsx @@ -92,8 +92,8 @@ export const NotificationRuleContent = ({ launchNames, sendCase, ruleDetails, - ruleFields, }, + ruleFields, }) => { const { formatMessage } = useIntl(); @@ -132,7 +132,7 @@ export const NotificationRuleContent = ({ else { return ( ruleDetails && - ruleFields.reduce((acc, field) => { + ruleFields?.reduce((acc, field) => { if (ruleDetails[field.name]) { acc.push( @@ -179,7 +179,7 @@ NotificationRuleContent.propTypes = { attributes: PropTypes.array, informOwner: PropTypes.bool, ruleDetails: PropTypes.object, - ruleFields: PropTypes.arrayOf(ruleField), attributesOperator: PropTypes.oneOf([ATTRIBUTES_OPERATORS.AND, ATTRIBUTES_OPERATORS.OR]), }).isRequired, + ruleFields: PropTypes.arrayOf(ruleField), }; diff --git a/app/src/pages/inside/projectSettingsPageContainer/content/elements/ruleList/propTypes.js b/app/src/pages/inside/projectSettingsPageContainer/content/elements/ruleList/propTypes.js index 5db27f30fd..7fc20c6380 100644 --- a/app/src/pages/inside/projectSettingsPageContainer/content/elements/ruleList/propTypes.js +++ b/app/src/pages/inside/projectSettingsPageContainer/content/elements/ruleList/propTypes.js @@ -6,6 +6,7 @@ export const ruleListPropTypes = { onToggle: PropTypes.func, disabled: PropTypes.bool, ruleItemContent: PropTypes.elementType, + ruleItemContentProps: PropTypes.object, handleRuleItemClick: PropTypes.func, onRuleNameClick: PropTypes.oneOfType([PropTypes.func, PropTypes.instanceOf(null)]), }; @@ -14,6 +15,7 @@ export const ruleListDefaultProps = { onToggle: () => {}, disabled: true, ruleItemContent: null, + ruleItemContentProps: [], handleRuleItemClick: () => {}, onRuleNameClick: null, }; diff --git a/app/src/pages/inside/projectSettingsPageContainer/content/elements/ruleList/ruleList.jsx b/app/src/pages/inside/projectSettingsPageContainer/content/elements/ruleList/ruleList.jsx index 1d0633cdfd..747d94a846 100644 --- a/app/src/pages/inside/projectSettingsPageContainer/content/elements/ruleList/ruleList.jsx +++ b/app/src/pages/inside/projectSettingsPageContainer/content/elements/ruleList/ruleList.jsx @@ -33,6 +33,7 @@ const PlainRuleList = ({ handleRuleItemClick, onRuleNameClick, className, + ruleItemContentProps, }) => { const Content = ruleItemContent; return ( @@ -44,7 +45,7 @@ const PlainRuleList = ({ actions={actions} onToggle={onToggle} disabled={disabled} - content={ruleItemContent && } + content={ruleItemContent && } onClick={handleRuleItemClick} onRuleNameClick={onRuleNameClick} className={className} diff --git a/app/src/pages/inside/projectSettingsPageContainer/content/notifications/constants.js b/app/src/pages/inside/projectSettingsPageContainer/content/notifications/constants.js index 5946ff094a..fd4851651d 100644 --- a/app/src/pages/inside/projectSettingsPageContainer/content/notifications/constants.js +++ b/app/src/pages/inside/projectSettingsPageContainer/content/notifications/constants.js @@ -17,6 +17,7 @@ export const LABEL_WIDTH = 140; export const RULE_NAME_FIELD_KEY = 'ruleName'; +export const RULE_DETAILS_FIELD_KEY = 'ruleDetails'; export const RECIPIENTS_FIELD_KEY = 'recipients'; export const INFORM_OWNER_FIELD_KEY = 'informOwner'; export const SEND_CASE_FIELD_KEY = 'sendCase'; diff --git a/app/src/pages/inside/projectSettingsPageContainer/content/notifications/modals/addEditNotificationModal/addEditNotificationModal.jsx b/app/src/pages/inside/projectSettingsPageContainer/content/notifications/modals/addEditNotificationModal/addEditNotificationModal.jsx index 4f2447ff6c..0d0d9bfd4b 100644 --- a/app/src/pages/inside/projectSettingsPageContainer/content/notifications/modals/addEditNotificationModal/addEditNotificationModal.jsx +++ b/app/src/pages/inside/projectSettingsPageContainer/content/notifications/modals/addEditNotificationModal/addEditNotificationModal.jsx @@ -61,6 +61,7 @@ import { SEND_CASE_FIELD_KEY, FIELD_TYPE_TEXT, FIELD_TYPE_MULTILINE_TEXT, + RULE_DETAILS_FIELD_KEY, } from '../../constants'; import styles from './addEditNotificationModal.scss'; @@ -369,7 +370,7 @@ const AddEditNotificationModal = ({ const TypedComponent = fieldByType[field.type]; return ( ({ name: rule.ruleName, ...rule, - ruleFields, }))} actions={actions} onToggle={onToggleHandler} ruleItemContent={NotificationRuleContent} + ruleItemContentProps={{ ruleFields }} handleRuleItemClick={handleRuleItemClick} dataAutomationId="notificationsRulesList" className={cx('rule-group-list')} diff --git a/app/src/pages/inside/projectSettingsPageContainer/content/notifications/utils.js b/app/src/pages/inside/projectSettingsPageContainer/content/notifications/utils.js index dfe96f4912..4df70b3c11 100644 --- a/app/src/pages/inside/projectSettingsPageContainer/content/notifications/utils.js +++ b/app/src/pages/inside/projectSettingsPageContainer/content/notifications/utils.js @@ -29,7 +29,7 @@ export const convertNotificationCaseForSubmission = (obj) => { enabled = true, attributesOperator, type, - ...ruleDetails + ruleDetails, } = obj; const dynamicField = type === EMAIL