mirror of https://github.com/portainer/portainer
fix(environment): update page title when no environment selected. (#7606)
* fix(environment): update page title when no environment selected. * fix(environment): update page title when clearing environment from side bar. * fix(environment): update page title when clearing environment from a non-environment page.pull/7623/head
parent
2b2580fb61
commit
77c3f9131b
|
@ -10,9 +10,7 @@ export function onStartupAngular($rootScope, $state, $interval, LocalStorage, En
|
||||||
|
|
||||||
$transitions.onEnter({}, () => {
|
$transitions.onEnter({}, () => {
|
||||||
const endpoint = EndpointProvider.currentEndpoint();
|
const endpoint = EndpointProvider.currentEndpoint();
|
||||||
if (endpoint) {
|
document.title = endpoint ? `${defaultTitle} | ${endpoint.Name}` : `${defaultTitle}`;
|
||||||
document.title = `${defaultTitle} | ${endpoint.Name}`;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Workaround to prevent the loading bar from going backward
|
// Workaround to prevent the loading bar from going backward
|
||||||
|
|
|
@ -50,6 +50,7 @@ angular.module('portainer.app').factory('Authentication', [
|
||||||
clearSessionStorage();
|
clearSessionStorage();
|
||||||
StateManager.clean();
|
StateManager.clean();
|
||||||
EndpointProvider.clean();
|
EndpointProvider.clean();
|
||||||
|
EndpointProvider.setCurrentEndpoint(null);
|
||||||
LocalStorage.cleanAuthData();
|
LocalStorage.cleanAuthData();
|
||||||
LocalStorage.storeLoginStateUUID('');
|
LocalStorage.storeLoginStateUUID('');
|
||||||
tryAutoLoginExtension();
|
tryAutoLoginExtension();
|
||||||
|
|
|
@ -4,6 +4,7 @@ export interface EndpointProvider {
|
||||||
setEndpointID(id: Environment['Id']): void;
|
setEndpointID(id: Environment['Id']): void;
|
||||||
setEndpointPublicURL(url?: string): void;
|
setEndpointPublicURL(url?: string): void;
|
||||||
setOfflineModeFromStatus(status: Environment['Status']): void;
|
setOfflineModeFromStatus(status: Environment['Status']): void;
|
||||||
|
setCurrentEndpoint(endpoint: Environment | undefined): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface StateManager {
|
export interface StateManager {
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { useCurrentStateAndParams, useRouter } from '@uirouter/react';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { X, Slash } from 'react-feather';
|
import { X, Slash } from 'react-feather';
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
|
import angular from 'angular';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
PlatformType,
|
PlatformType,
|
||||||
|
@ -11,6 +12,7 @@ import {
|
||||||
import { getPlatformType } from '@/portainer/environments/utils';
|
import { getPlatformType } from '@/portainer/environments/utils';
|
||||||
import { useEnvironment } from '@/portainer/environments/queries/useEnvironment';
|
import { useEnvironment } from '@/portainer/environments/queries/useEnvironment';
|
||||||
import { useLocalStorage } from '@/portainer/hooks/useLocalStorage';
|
import { useLocalStorage } from '@/portainer/hooks/useLocalStorage';
|
||||||
|
import { EndpointProvider } from '@/portainer/services/types';
|
||||||
|
|
||||||
import { getPlatformIcon } from '../portainer/environments/utils/get-platform-icon';
|
import { getPlatformIcon } from '../portainer/environments/utils/get-platform-icon';
|
||||||
|
|
||||||
|
@ -108,6 +110,16 @@ function useCurrentEnvironment() {
|
||||||
return { query: useEnvironment(environmentId), clearEnvironment };
|
return { query: useEnvironment(environmentId), clearEnvironment };
|
||||||
|
|
||||||
function clearEnvironment() {
|
function clearEnvironment() {
|
||||||
|
const $injector = angular.element(document).injector();
|
||||||
|
$injector.invoke(
|
||||||
|
/* @ngInject */ (EndpointProvider: EndpointProvider) => {
|
||||||
|
EndpointProvider.setCurrentEndpoint(undefined);
|
||||||
|
if (!params.endpointId) {
|
||||||
|
document.title = 'Portainer';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
if (params.endpointId) {
|
if (params.endpointId) {
|
||||||
router.stateService.go('portainer.home');
|
router.stateService.go('portainer.home');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue