mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-07 16:41:48 -05:00
update content loading and error handling
unwind error handling use auth cookie as source of truth, fetch config only when authenticated
This commit is contained in:
@@ -26,6 +26,36 @@ const NotificationsMixin = (parent) => class extends parent {
|
||||
disassociateNotificationTemplatesError (resourceId, notificationId) {
|
||||
return this.http.post(`${this.baseUrl}${resourceId}/notification_templates_error/`, { id: notificationId, disassociate: true });
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a helper method meant to simplify setting the "on" or "off" status of
|
||||
* a related notification.
|
||||
*
|
||||
* @param[resourceId] - id of the base resource
|
||||
* @param[notificationId] - id of the notification
|
||||
* @param[notificationType] - the type of notification, options are "success" and "error"
|
||||
* @param[associationState] - Boolean for associating or disassociating, options are true or false
|
||||
*/
|
||||
// eslint-disable-next-line max-len
|
||||
updateNotificationTemplateAssociation (resourceId, notificationId, notificationType, associationState) {
|
||||
if (notificationType === 'success' && associationState === true) {
|
||||
return this.associateNotificationTemplatesSuccess(resourceId, notificationId);
|
||||
}
|
||||
|
||||
if (notificationType === 'success' && associationState === false) {
|
||||
return this.disassociateNotificationTemplatesSuccess(resourceId, notificationId);
|
||||
}
|
||||
|
||||
if (notificationType === 'error' && associationState === true) {
|
||||
return this.associateNotificationTemplatesError(resourceId, notificationId);
|
||||
}
|
||||
|
||||
if (notificationType === 'error' && associationState === false) {
|
||||
return this.disassociateNotificationTemplatesSuccess(resourceId, notificationId);
|
||||
}
|
||||
|
||||
throw new Error(`Unsupported notificationType, associationState combination: ${notificationType}, ${associationState}`);
|
||||
}
|
||||
};
|
||||
|
||||
export default NotificationsMixin;
|
||||
|
||||
Reference in New Issue
Block a user