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-90569 || Notifications Tab Fixes #3809

Merged
merged 5 commits into from
Apr 26, 2024
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 @@ -102,6 +102,7 @@ export const Notifications = () => {
<RuleGroup
key={`rule-section-${item.name}`}
pluginName={item.name}
isPluginEnabled={item.enabled}
typedRules={notificationRulesByTypes[item.name]}
notifications={notifications}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const RuleItemDisabledTooltip = withTooltip({
},
})(({ children }) => children);

export const RuleGroup = ({ pluginName, typedRules, notifications }) => {
export const RuleGroup = ({ pluginName, typedRules, notifications, isPluginEnabled }) => {
const { trackEvent } = useTracking();
const { formatMessage } = useIntl();

Expand All @@ -93,7 +93,8 @@ export const RuleGroup = ({ pluginName, typedRules, notifications }) => {
projectPluginNotificationsStateSelector(pluginName),
);

const isAvailable = () => isEmailIntegrationAvailable && canUpdateSettings(userRole, projectRole);
const isUpdateSettingAvailable = canUpdateSettings(userRole, projectRole);
const isReadOnly = !isUpdateSettingAvailable || !isPluginEnabled;

const onToggleHandler = (isEnabled, notification) => {
trackEvent(PROJECT_SETTINGS_NOTIFICATIONS_EVENTS.SWITCH_NOTIFICATION_RULE(isEnabled));
Expand All @@ -105,8 +106,6 @@ export const RuleGroup = ({ pluginName, typedRules, notifications }) => {
);
};

const isReadOnly = !isAvailable();

const handleRuleItemClick = (isShown) => {
if (isShown) {
trackEvent(PROJECT_SETTINGS_NOTIFICATIONS_EVENTS.CLICK_TO_EXPAND_NOTIFICATIONS_DETAILS);
Expand Down Expand Up @@ -165,6 +164,7 @@ export const RuleGroup = ({ pluginName, typedRules, notifications }) => {
showModalAction({
id: 'addEditNotificationModal',
data: {
type: pluginName,
actionType: MODAL_ACTION_TYPE_EDIT,
onSave: confirmEdit,
notification,
Expand Down Expand Up @@ -246,41 +246,41 @@ export const RuleGroup = ({ pluginName, typedRules, notifications }) => {
</Toggle>
</div>
</FieldElement>

{!isAvailable() ? (
<div className={cx('disabled-plugin')}>
<p>
<span className={cx('capitalized')}>{pluginName}</span>{' '}
{formatMessage(messages.disabledPlugin, { pluginName })}
</p>
<RuleItemDisabledTooltip
className={cx('info-tooltip')}
tooltipContent={formatMessage(messages.disabledContactInfo)}
>
<i className={cx('icon', 'about-icon')}>{Parser(AboutIcon)}</i>
</RuleItemDisabledTooltip>
</div>
) : (
pluginName === EMAIL &&
!isEmailIntegrationAvailable && (
<div className={cx('integrate-configurations')}>
<p>{formatMessage(messages.notConfiguredIntegration)}</p>
<LinkComponent
to={{
type: PROJECT_SETTINGS_TAB_PAGE,
payload: {
projectId: activeProject,
settingsTab: INTEGRATIONS,
subTab: 'email',
},
}}
icon={arrowRightIcon}
{isUpdateSettingAvailable &&
(!isPluginEnabled ? (
<div className={cx('disabled-plugin')}>
<p>
<span className={cx('capitalized')}>{pluginName}</span>{' '}
{formatMessage(messages.disabledPlugin, { pluginName })}
</p>
<RuleItemDisabledTooltip
className={cx('info-tooltip')}
tooltipContent={formatMessage(messages.disabledContactInfo)}
>
{formatMessage(messages.configureIntegration)}
</LinkComponent>
<i className={cx('icon', 'about-icon')}>{Parser(AboutIcon)}</i>
</RuleItemDisabledTooltip>
</div>
)
)}
) : (
pluginName === EMAIL &&
!isEmailIntegrationAvailable && (
<div className={cx('integrate-configurations')}>
<p>{formatMessage(messages.notConfiguredIntegration)}</p>
<LinkComponent
to={{
type: PROJECT_SETTINGS_TAB_PAGE,
payload: {
projectId: activeProject,
settingsTab: INTEGRATIONS,
subTab: 'email',
},
}}
icon={arrowRightIcon}
>
{formatMessage(messages.configureIntegration)}
</LinkComponent>
</div>
)
))}
</div>

<div className={cx('notifications-container')}>
Expand All @@ -299,17 +299,21 @@ export const RuleGroup = ({ pluginName, typedRules, notifications }) => {
dataAutomationId="notificationsRulesList"
className={cx('rule-group-list')}
/>
<Button
customClassName={cx('add-rule')}
onClick={onAdd}
variant={'text'}
startIcon={addIcon}
>
{formatMessage(messages.addRule)}
</Button>
{isUpdateSettingAvailable && (
<Button
customClassName={cx('add-rule')}
onClick={onAdd}
variant={'text'}
startIcon={addIcon}
>
{formatMessage(messages.addRule)}
</Button>
)}
</div>
) : (
<EmptyRuleState ruleName={pluginName} onCreateClick={onAdd} />
isUpdateSettingAvailable && (
<EmptyRuleState ruleName={pluginName} onCreateClick={onAdd} />
)
)}
</div>
</Layout>
Expand All @@ -333,4 +337,5 @@ RuleGroup.propTypes = {
pluginName: PropTypes.string.isRequired,
typedRules: PropTypes.arrayOf(ruleShape),
notifications: PropTypes.arrayOf(ruleShape).isRequired,
isPluginEnabled: PropTypes.bool.isRequired,
};
Loading