mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
Merge pull request #6458 from jakemcdermott/6435-fix-notification-toggle-disable
Limit disable-on-load to single notifications Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
commit
5f62426684
@ -25,7 +25,7 @@ class NotificationList extends Component {
|
||||
contentError: null,
|
||||
hasContentLoading: true,
|
||||
toggleError: false,
|
||||
toggleLoading: false,
|
||||
loadingToggleIds: [],
|
||||
itemCount: 0,
|
||||
notifications: [],
|
||||
startedTemplateIds: [],
|
||||
@ -147,7 +147,9 @@ class NotificationList extends Component {
|
||||
});
|
||||
}
|
||||
|
||||
this.setState({ toggleLoading: true });
|
||||
this.setState(({ loadingToggleIds }) => ({
|
||||
loadingToggleIds: loadingToggleIds.concat([notificationId]),
|
||||
}));
|
||||
try {
|
||||
if (isCurrentlyOn) {
|
||||
await apiModel.disassociateNotificationTemplate(
|
||||
@ -166,7 +168,11 @@ class NotificationList extends Component {
|
||||
} catch (err) {
|
||||
this.setState({ toggleError: err });
|
||||
} finally {
|
||||
this.setState({ toggleLoading: false });
|
||||
this.setState(({ loadingToggleIds }) => ({
|
||||
loadingToggleIds: loadingToggleIds.filter(
|
||||
item => item !== notificationId
|
||||
),
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,7 +186,7 @@ class NotificationList extends Component {
|
||||
contentError,
|
||||
hasContentLoading,
|
||||
toggleError,
|
||||
toggleLoading,
|
||||
loadingToggleIds,
|
||||
itemCount,
|
||||
notifications,
|
||||
startedTemplateIds,
|
||||
@ -240,7 +246,10 @@ class NotificationList extends Component {
|
||||
key={notification.id}
|
||||
notification={notification}
|
||||
detailUrl={`/notifications/${notification.id}`}
|
||||
canToggleNotifications={canToggleNotifications && !toggleLoading}
|
||||
canToggleNotifications={
|
||||
canToggleNotifications &&
|
||||
!loadingToggleIds.includes(notification.id)
|
||||
}
|
||||
toggleNotification={this.handleNotificationToggle}
|
||||
errorTurnedOn={errorTemplateIds.includes(notification.id)}
|
||||
startedTurnedOn={startedTemplateIds.includes(notification.id)}
|
||||
@ -252,7 +261,7 @@ class NotificationList extends Component {
|
||||
<AlertModal
|
||||
variant="error"
|
||||
title={i18n._(t`Error!`)}
|
||||
isOpen={toggleError && !toggleLoading}
|
||||
isOpen={toggleError && loadingToggleIds.length === 0}
|
||||
onClose={this.handleNotificationErrorClose}
|
||||
>
|
||||
{i18n._(t`Failed to toggle notification.`)}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user