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

EPMRPP-90888 || Possible to create 2 Slack notification rules #3828

Merged
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
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
Loading