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