fix(app): extensions status retrieval (#2910)

* fix(rbac): extensions status retrieval not interrupted anymore

* refactor(extensions): change endpoint used to retrieve extension activation status
pull/2877/head
baron_l 2019-05-29 02:39:30 +02:00 committed by Anthony Lapenna
parent 086d4f1d1c
commit 5388585ef1
4 changed files with 21 additions and 11 deletions

View File

@ -60,8 +60,9 @@ angular.module('portainer.app')
if (extensionId === service.EXTENSIONS.RBAC) {
return StateManager.getExtension(extensionId) ? true : false;
} else {
const extension = await Extension.get({id: extensionId}).$promise;
return extension.Enabled;
const extensions = await service.extensions(false);
const extension = _.find(extensions, (ext) => ext.Id === extensionId);
return extension ? extension.Enabled : false;
}
};

View File

@ -14,9 +14,9 @@ function($q, $scope, $state, $stateParams, $sanitize, Authentication, UserServic
OAuthProvider: ''
};
function retrieveAndSaveEnabledExtensions() {
async function retrieveAndSaveEnabledExtensions() {
try {
ExtensionService.retrieveAndSaveEnabledExtensions();
await ExtensionService.retrieveAndSaveEnabledExtensions();
} catch (err) {
Notifications.error('Failure', err, 'Unable to retrieve enabled extensions');
}
@ -28,7 +28,9 @@ function($q, $scope, $state, $stateParams, $sanitize, Authentication, UserServic
Authentication.login(username, password)
.then(function success() {
retrieveAndSaveEnabledExtensions();
return retrieveAndSaveEnabledExtensions();
})
.then(function () {
checkForEndpoints();
})
.catch(function error() {
@ -40,7 +42,9 @@ function($q, $scope, $state, $stateParams, $sanitize, Authentication, UserServic
return $q.reject();
})
.then(function success() {
retrieveAndSaveEnabledExtensions();
return retrieveAndSaveEnabledExtensions();
})
.then(function() {
$state.go('portainer.updatePassword');
})
.catch(function error() {
@ -141,7 +145,9 @@ function($q, $scope, $state, $stateParams, $sanitize, Authentication, UserServic
function oAuthLogin(code) {
return Authentication.OAuthLogin(code)
.then(function success() {
retrieveAndSaveEnabledExtensions();
return retrieveAndSaveEnabledExtensions();
})
.then(function() {
URLHelper.cleanParameters();
})
.catch(function error() {

View File

@ -30,7 +30,8 @@ angular.module('portainer.app')
$scope.state.actionInProgress = true;
ExtensionService.enable(license)
.then(function onSuccess() {
ExtensionService.retrieveAndSaveEnabledExtensions();
return ExtensionService.retrieveAndSaveEnabledExtensions();
}).then(function () {
Notifications.success('Extension successfully enabled');
$state.reload();
})

View File

@ -14,9 +14,9 @@ function ($scope, $state, Notifications, Authentication, StateManager, UserServi
actionInProgress: false
};
function retrieveAndSaveEnabledExtensions() {
async function retrieveAndSaveEnabledExtensions() {
try {
ExtensionService.retrieveAndSaveEnabledExtensions();
await ExtensionService.retrieveAndSaveEnabledExtensions();
} catch (err) {
Notifications.error('Failure', err, 'Unable to retrieve enabled extensions');
}
@ -32,7 +32,9 @@ function ($scope, $state, Notifications, Authentication, StateManager, UserServi
return Authentication.login(username, password);
})
.then(function success() {
retrieveAndSaveEnabledExtensions();
return retrieveAndSaveEnabledExtensions();
})
.then(function () {
return EndpointService.endpoints();
})
.then(function success(data) {