mirror of https://github.com/portainer/portainer
fix(sidebar): clear current endpoint if deleted [EE-873] (#6052)
parent
b596d0febd
commit
17a20cb2c6
|
@ -11,7 +11,20 @@ angular.module('portainer.app').factory('StateManager', [
|
|||
'APPLICATION_CACHE_VALIDITY',
|
||||
'AgentPingService',
|
||||
'$analytics',
|
||||
function StateManagerFactory($q, $async, SystemService, InfoHelper, LocalStorage, SettingsService, StatusService, APPLICATION_CACHE_VALIDITY, AgentPingService, $analytics) {
|
||||
'EndpointProvider',
|
||||
function StateManagerFactory(
|
||||
$q,
|
||||
$async,
|
||||
SystemService,
|
||||
InfoHelper,
|
||||
LocalStorage,
|
||||
SettingsService,
|
||||
StatusService,
|
||||
APPLICATION_CACHE_VALIDITY,
|
||||
AgentPingService,
|
||||
$analytics,
|
||||
EndpointProvider
|
||||
) {
|
||||
var manager = {};
|
||||
|
||||
var state = {
|
||||
|
@ -49,6 +62,11 @@ angular.module('portainer.app').factory('StateManager', [
|
|||
state.application = {};
|
||||
};
|
||||
|
||||
manager.cleanEndpoint = function () {
|
||||
state.endpoint = {};
|
||||
EndpointProvider.clean();
|
||||
};
|
||||
|
||||
manager.updateLogo = function (logoURL) {
|
||||
state.application.logo = logoURL;
|
||||
LocalStorage.storeApplicationState(state.application);
|
||||
|
|
|
@ -3,7 +3,7 @@ import EndpointHelper from 'Portainer/helpers/endpointHelper';
|
|||
|
||||
angular.module('portainer.app').controller('EndpointsController', EndpointsController);
|
||||
|
||||
function EndpointsController($q, $scope, $state, $async, EndpointService, GroupService, ModalService, Notifications) {
|
||||
function EndpointsController($q, $scope, $state, $async, EndpointService, GroupService, ModalService, Notifications, EndpointProvider, StateManager) {
|
||||
$scope.removeAction = removeAction;
|
||||
|
||||
function removeAction(endpoints) {
|
||||
|
@ -26,6 +26,14 @@ function EndpointsController($q, $scope, $state, $async, EndpointService, GroupS
|
|||
}
|
||||
}
|
||||
|
||||
const endpointId = EndpointProvider.endpointID();
|
||||
// If the current endpoint was deleted, then clean endpoint store
|
||||
if (endpoints.some((item) => item.Id === endpointId)) {
|
||||
StateManager.cleanEndpoint();
|
||||
// trigger sidebar rerender
|
||||
$scope.applicationState.endpoint = {};
|
||||
}
|
||||
|
||||
$state.reload();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue