From daeb5a8de8b42d22b23fbe5ea646fdeed495568c Mon Sep 17 00:00:00 2001 From: mabashian Date: Thu, 20 Aug 2020 14:24:05 -0400 Subject: [PATCH] Only disable single notification row when toggling, not all rows --- .../NotificationList/NotificationList.jsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/awx/ui_next/src/components/NotificationList/NotificationList.jsx b/awx/ui_next/src/components/NotificationList/NotificationList.jsx index f274e4cca3..b11e27f9e5 100644 --- a/awx/ui_next/src/components/NotificationList/NotificationList.jsx +++ b/awx/ui_next/src/components/NotificationList/NotificationList.jsx @@ -25,7 +25,7 @@ function NotificationList({ showApprovalsToggle, }) { const location = useLocation(); - const [isToggleLoading, setIsToggleLoading] = useState(false); + const [loadingToggleIds, setLoadingToggleIds] = useState([]); const [toggleError, setToggleError] = useState(null); const { @@ -123,7 +123,7 @@ function NotificationList({ isCurrentlyOn, status ) => { - setIsToggleLoading(true); + setLoadingToggleIds(loadingToggleIds.concat([notificationId])); try { if (isCurrentlyOn) { await apiModel.disassociateNotificationTemplate( @@ -153,7 +153,9 @@ function NotificationList({ } catch (err) { setToggleError(err); } finally { - setIsToggleLoading(false); + setLoadingToggleIds( + loadingToggleIds.filter(item => item !== notificationId) + ); } }; @@ -208,7 +210,10 @@ function NotificationList({ key={notification.id} notification={notification} detailUrl={`/notifications/${notification.id}`} - canToggleNotifications={canToggleNotifications && !isToggleLoading} + canToggleNotifications={ + canToggleNotifications && + !loadingToggleIds.includes(notification.id) + } toggleNotification={handleNotificationToggle} approvalsTurnedOn={approvalsTemplateIds.includes(notification.id)} errorTurnedOn={errorTemplateIds.includes(notification.id)} @@ -223,7 +228,7 @@ function NotificationList({ setToggleError(null)} > {i18n._(t`Failed to toggle notification.`)}