1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-05 13:55:21 +02:00

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.
This commit is contained in:
fhanportainer 2022-09-07 11:08:45 +12:00 committed by GitHub
parent 2b2580fb61
commit 77c3f9131b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 3 deletions

View file

@ -2,6 +2,7 @@ import { useCurrentStateAndParams, useRouter } from '@uirouter/react';
import { useEffect } from 'react';
import { X, Slash } from 'react-feather';
import clsx from 'clsx';
import angular from 'angular';
import {
PlatformType,
@ -11,6 +12,7 @@ import {
import { getPlatformType } from '@/portainer/environments/utils';
import { useEnvironment } from '@/portainer/environments/queries/useEnvironment';
import { useLocalStorage } from '@/portainer/hooks/useLocalStorage';
import { EndpointProvider } from '@/portainer/services/types';
import { getPlatformIcon } from '../portainer/environments/utils/get-platform-icon';
@ -108,6 +110,16 @@ function useCurrentEnvironment() {
return { query: useEnvironment(environmentId), 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) {
router.stateService.go('portainer.home');
}