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:
parent
2b2580fb61
commit
77c3f9131b
4 changed files with 15 additions and 3 deletions
|
@ -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');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue