From 7dbdff2aa78bf4f4f30e70cbf2a0b312c6a5a74d Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Fri, 13 Jul 2018 13:54:00 -0700 Subject: [PATCH] Adds error catch block to credentials resolve Catches the case where a user doesn't have permission to a credential --- awx/ui/client/features/credentials/index.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/awx/ui/client/features/credentials/index.js b/awx/ui/client/features/credentials/index.js index e3a1ea7734..38e291ef8e 100644 --- a/awx/ui/client/features/credentials/index.js +++ b/awx/ui/client/features/credentials/index.js @@ -7,7 +7,16 @@ const MODULE_NAME = 'at.features.credentials'; const addEditTemplate = require('~features/credentials/add-edit-credentials.view.html'); -function CredentialsResolve ($q, $stateParams, Me, Credential, CredentialType, Organization) { +function CredentialsResolve ( + $q, + $stateParams, + Me, + Credential, + CredentialType, + Organization, + ProcessErrors, + strings +) { const id = $stateParams.credential_id; const promises = { @@ -43,6 +52,12 @@ function CredentialsResolve ($q, $stateParams, Me, Credential, CredentialType, O return models; }); + }).catch(({ data, status, config }) => { + ProcessErrors(null, data, status, null, { + hdr: strings.get('error.HEADER'), + msg: strings.get('error.CALL', { path: `${config.url}`, status }) + }); + return $q.reject(); }); } @@ -52,7 +67,9 @@ CredentialsResolve.$inject = [ 'MeModel', 'CredentialModel', 'CredentialTypeModel', - 'OrganizationModel' + 'OrganizationModel', + 'ProcessErrors', + 'CredentialsStrings' ]; function CredentialsRun ($stateExtender, legacy, strings) {