1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-08 07:15:23 +02:00

feat(app): clear env when log out [EE-4791] (#8218)

This commit is contained in:
Chaim Lev-Ari 2022-12-19 08:56:39 +02:00 committed by GitHub
parent 123754cee7
commit 701410d259
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 19 deletions

View file

@ -1,4 +1,5 @@
import { ping } from '@/docker/services/ping';
import { environmentStore } from '@/react/hooks/current-environment-store';
import {
Environment,
EnvironmentType,
@ -9,6 +10,8 @@ interface State {
pingInterval: NodeJS.Timer | null;
}
const DEFAULT_TITLE = 'Portainer';
/* @ngInject */
export function EndpointProvider() {
const state: State = {
@ -16,6 +19,12 @@ export function EndpointProvider() {
pingInterval: null,
};
environmentStore.subscribe((state) => {
if (!state.environmentId) {
setCurrentEndpoint(null);
}
});
return { endpointID, setCurrentEndpoint, currentEndpoint, clean };
function endpointID() {
@ -40,6 +49,10 @@ export function EndpointProvider() {
JSON.stringify(undefined)
);
}
document.title = endpoint
? `${DEFAULT_TITLE} | ${endpoint.Name}`
: `${DEFAULT_TITLE}`;
}
function currentEndpoint() {
@ -48,6 +61,7 @@ export function EndpointProvider() {
function clean() {
setCurrentEndpoint(null);
environmentStore.getState().clear();
}
}