Skip to content

Commit

Permalink
EPMRPP-90888 || Possible to create 2 Slack notification rules (#3828)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
maria-hambardzumian authored May 13, 2024
1 parent f284ca2 commit 0634b8d
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ export const NotificationRuleContent = ({
launchNames,
sendCase,
ruleDetails,
ruleFields,
},
ruleFields,
}) => {
const { formatMessage } = useIntl();

Expand Down Expand Up @@ -132,7 +132,7 @@ export const NotificationRuleContent = ({
else {
return (
ruleDetails &&
ruleFields.reduce((acc, field) => {
ruleFields?.reduce((acc, field) => {
if (ruleDetails[field.name]) {
acc.push(
<Fragment key={field.name}>
Expand Down Expand Up @@ -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),
};
Original file line number Diff line number Diff line change
Expand Up @@ -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)]),
};
Expand All @@ -14,6 +15,7 @@ export const ruleListDefaultProps = {
onToggle: () => {},
disabled: true,
ruleItemContent: null,
ruleItemContentProps: [],
handleRuleItemClick: () => {},
onRuleNameClick: null,
};
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const PlainRuleList = ({
handleRuleItemClick,
onRuleNameClick,
className,
ruleItemContentProps,
}) => {
const Content = ruleItemContent;
return (
Expand All @@ -44,7 +45,7 @@ const PlainRuleList = ({
actions={actions}
onToggle={onToggle}
disabled={disabled}
content={ruleItemContent && <Content item={item} />}
content={ruleItemContent && <Content item={item} {...ruleItemContentProps} />}
onClick={handleRuleItemClick}
onRuleNameClick={onRuleNameClick}
className={className}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -369,7 +370,7 @@ const AddEditNotificationModal = ({
const TypedComponent = fieldByType[field.type];
return (
<FieldElement
name={field.name}
name={`${RULE_DETAILS_FIELD_KEY}.${field.name}`}
key={field.name}
type={field.type}
className={cx('dynamicField')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,11 @@ export const RuleGroup = ({ pluginName, ruleDescription, rules, isPluginEnabled,
data={rules.map((rule) => ({
name: rule.ruleName,
...rule,
ruleFields,
}))}
actions={actions}
onToggle={onToggleHandler}
ruleItemContent={NotificationRuleContent}
ruleItemContentProps={{ ruleFields }}
handleRuleItemClick={handleRuleItemClick}
dataAutomationId="notificationsRulesList"
className={cx('rule-group-list')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const convertNotificationCaseForSubmission = (obj) => {
enabled = true,
attributesOperator,
type,
...ruleDetails
ruleDetails,
} = obj;
const dynamicField =
type === EMAIL
Expand Down

0 comments on commit 0634b8d

Please sign in to comment.