From 085e43b2f4984beb721fbb1ee30b3dc4d62245dd Mon Sep 17 00:00:00 2001 From: maria-hambardzumian Date: Wed, 8 May 2024 19:12:15 +0400 Subject: [PATCH 1/4] EPMRPP-90888 || Possible to create 2 Slack notification rules --- .../content/notifications/utils.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/app/src/pages/inside/projectSettingsPageContainer/content/notifications/utils.js b/app/src/pages/inside/projectSettingsPageContainer/content/notifications/utils.js index dfe96f4912..af6d66f207 100644 --- a/app/src/pages/inside/projectSettingsPageContainer/content/notifications/utils.js +++ b/app/src/pages/inside/projectSettingsPageContainer/content/notifications/utils.js @@ -17,6 +17,15 @@ import { OWNER } from 'common/constants/permissions'; import { EMAIL } from 'common/constants/pluginNames'; +function getUpdatedProperties(base, updated) { + return Object.keys(base).reduce((acc, key) => { + if (updated[key] && base[key] !== updated[key]) { + acc[key] = updated[key]; + } + return acc; + }, base); +} + export const convertNotificationCaseForSubmission = (obj) => { const { id, @@ -29,12 +38,17 @@ export const convertNotificationCaseForSubmission = (obj) => { enabled = true, attributesOperator, type, - ...ruleDetails + ruleDetails, + ...addedRuleDetails } = obj; const dynamicField = type === EMAIL ? { recipients: informOwner ? [...recipients, OWNER] : recipients } - : { ruleDetails }; + : { + ruleDetails: ruleDetails + ? getUpdatedProperties(ruleDetails, addedRuleDetails) + : addedRuleDetails, + }; return { id, ruleName, From 3243c3fb0c24724b51bd53ea81ead43c881c2186 Mon Sep 17 00:00:00 2001 From: maria-hambardzumian Date: Wed, 8 May 2024 19:12:15 +0400 Subject: [PATCH 2/4] EPMRPP-90888 || Possible to create 2 Slack notification rules --- .../content/notifications/utils.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/app/src/pages/inside/projectSettingsPageContainer/content/notifications/utils.js b/app/src/pages/inside/projectSettingsPageContainer/content/notifications/utils.js index dfe96f4912..af6d66f207 100644 --- a/app/src/pages/inside/projectSettingsPageContainer/content/notifications/utils.js +++ b/app/src/pages/inside/projectSettingsPageContainer/content/notifications/utils.js @@ -17,6 +17,15 @@ import { OWNER } from 'common/constants/permissions'; import { EMAIL } from 'common/constants/pluginNames'; +function getUpdatedProperties(base, updated) { + return Object.keys(base).reduce((acc, key) => { + if (updated[key] && base[key] !== updated[key]) { + acc[key] = updated[key]; + } + return acc; + }, base); +} + export const convertNotificationCaseForSubmission = (obj) => { const { id, @@ -29,12 +38,17 @@ export const convertNotificationCaseForSubmission = (obj) => { enabled = true, attributesOperator, type, - ...ruleDetails + ruleDetails, + ...addedRuleDetails } = obj; const dynamicField = type === EMAIL ? { recipients: informOwner ? [...recipients, OWNER] : recipients } - : { ruleDetails }; + : { + ruleDetails: ruleDetails + ? getUpdatedProperties(ruleDetails, addedRuleDetails) + : addedRuleDetails, + }; return { id, ruleName, From cb6242c664cb851ce4d1b136de755a5db2f017b7 Mon Sep 17 00:00:00 2001 From: maria-hambardzumian Date: Sun, 12 May 2024 00:03:43 +0400 Subject: [PATCH 3/4] EPMRPP-90888 || Code Review fix - 1 --- .../notificationRuleContent.jsx | 6 +++--- .../content/elements/ruleList/propTypes.js | 3 +++ .../content/elements/ruleList/ruleList.jsx | 5 ++++- .../content/notifications/constants.js | 1 + .../addEditNotificationModal.jsx | 3 ++- .../notifications/ruleGroup/ruleGroup.jsx | 2 +- .../content/notifications/utils.js | 16 +--------------- 7 files changed, 15 insertions(+), 21 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..fcb0f0fe66 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, }, + ruleItemContentProps, }) => { const { formatMessage } = useIntl(); @@ -132,7 +132,7 @@ export const NotificationRuleContent = ({ else { return ( ruleDetails && - ruleFields.reduce((acc, field) => { + ruleItemContentProps.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, + ruleItemContentProps: 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..a1160d6ed7 100644 --- a/app/src/pages/inside/projectSettingsPageContainer/content/elements/ruleList/propTypes.js +++ b/app/src/pages/inside/projectSettingsPageContainer/content/elements/ruleList/propTypes.js @@ -1,4 +1,5 @@ import PropTypes from 'prop-types'; +import { ruleField } from 'pages/inside/projectSettingsPageContainer/content/notifications/propTypes'; export const ruleListPropTypes = { items: PropTypes.array, @@ -6,6 +7,7 @@ export const ruleListPropTypes = { onToggle: PropTypes.func, disabled: PropTypes.bool, ruleItemContent: PropTypes.elementType, + ruleItemContentProps: PropTypes.arrayOf(ruleField), handleRuleItemClick: PropTypes.func, onRuleNameClick: PropTypes.oneOfType([PropTypes.func, PropTypes.instanceOf(null)]), }; @@ -14,6 +16,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..8744fe5107 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,9 @@ 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 af6d66f207..4df70b3c11 100644 --- a/app/src/pages/inside/projectSettingsPageContainer/content/notifications/utils.js +++ b/app/src/pages/inside/projectSettingsPageContainer/content/notifications/utils.js @@ -17,15 +17,6 @@ import { OWNER } from 'common/constants/permissions'; import { EMAIL } from 'common/constants/pluginNames'; -function getUpdatedProperties(base, updated) { - return Object.keys(base).reduce((acc, key) => { - if (updated[key] && base[key] !== updated[key]) { - acc[key] = updated[key]; - } - return acc; - }, base); -} - export const convertNotificationCaseForSubmission = (obj) => { const { id, @@ -39,16 +30,11 @@ export const convertNotificationCaseForSubmission = (obj) => { attributesOperator, type, ruleDetails, - ...addedRuleDetails } = obj; const dynamicField = type === EMAIL ? { recipients: informOwner ? [...recipients, OWNER] : recipients } - : { - ruleDetails: ruleDetails - ? getUpdatedProperties(ruleDetails, addedRuleDetails) - : addedRuleDetails, - }; + : { ruleDetails }; return { id, ruleName, From eabd16aabc6398f6659b57d670ce44483eb18597 Mon Sep 17 00:00:00 2001 From: maria-hambardzumian Date: Mon, 13 May 2024 14:24:20 +0400 Subject: [PATCH 4/4] EPMRPP-90888 || Code Review fix - 2 --- .../notificationRuleContent/notificationRuleContent.jsx | 6 +++--- .../content/elements/ruleList/propTypes.js | 3 +-- .../content/elements/ruleList/ruleList.jsx | 4 +--- .../content/notifications/ruleGroup/ruleGroup.jsx | 2 +- 4 files changed, 6 insertions(+), 9 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 fcb0f0fe66..e3b03270da 100644 --- a/app/src/pages/inside/projectSettingsPageContainer/content/elements/notificationRuleContent/notificationRuleContent.jsx +++ b/app/src/pages/inside/projectSettingsPageContainer/content/elements/notificationRuleContent/notificationRuleContent.jsx @@ -93,7 +93,7 @@ export const NotificationRuleContent = ({ sendCase, ruleDetails, }, - ruleItemContentProps, + ruleFields, }) => { const { formatMessage } = useIntl(); @@ -132,7 +132,7 @@ export const NotificationRuleContent = ({ else { return ( ruleDetails && - ruleItemContentProps.reduce((acc, field) => { + ruleFields?.reduce((acc, field) => { if (ruleDetails[field.name]) { acc.push( @@ -181,5 +181,5 @@ NotificationRuleContent.propTypes = { ruleDetails: PropTypes.object, attributesOperator: PropTypes.oneOf([ATTRIBUTES_OPERATORS.AND, ATTRIBUTES_OPERATORS.OR]), }).isRequired, - ruleItemContentProps: PropTypes.arrayOf(ruleField), + 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 a1160d6ed7..7fc20c6380 100644 --- a/app/src/pages/inside/projectSettingsPageContainer/content/elements/ruleList/propTypes.js +++ b/app/src/pages/inside/projectSettingsPageContainer/content/elements/ruleList/propTypes.js @@ -1,5 +1,4 @@ import PropTypes from 'prop-types'; -import { ruleField } from 'pages/inside/projectSettingsPageContainer/content/notifications/propTypes'; export const ruleListPropTypes = { items: PropTypes.array, @@ -7,7 +6,7 @@ export const ruleListPropTypes = { onToggle: PropTypes.func, disabled: PropTypes.bool, ruleItemContent: PropTypes.elementType, - ruleItemContentProps: PropTypes.arrayOf(ruleField), + ruleItemContentProps: PropTypes.object, handleRuleItemClick: PropTypes.func, onRuleNameClick: PropTypes.oneOfType([PropTypes.func, PropTypes.instanceOf(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 8744fe5107..747d94a846 100644 --- a/app/src/pages/inside/projectSettingsPageContainer/content/elements/ruleList/ruleList.jsx +++ b/app/src/pages/inside/projectSettingsPageContainer/content/elements/ruleList/ruleList.jsx @@ -45,9 +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/ruleGroup/ruleGroup.jsx b/app/src/pages/inside/projectSettingsPageContainer/content/notifications/ruleGroup/ruleGroup.jsx index 2689cd0ef5..ee36fc9214 100644 --- a/app/src/pages/inside/projectSettingsPageContainer/content/notifications/ruleGroup/ruleGroup.jsx +++ b/app/src/pages/inside/projectSettingsPageContainer/content/notifications/ruleGroup/ruleGroup.jsx @@ -308,7 +308,7 @@ export const RuleGroup = ({ pluginName, ruleDescription, rules, isPluginEnabled, actions={actions} onToggle={onToggleHandler} ruleItemContent={NotificationRuleContent} - ruleItemContentProps={ruleFields} + ruleItemContentProps={{ ruleFields }} handleRuleItemClick={handleRuleItemClick} dataAutomationId="notificationsRulesList" className={cx('rule-group-list')}