From d568566336231db6ff702d3d44dbcec1edb5a23c Mon Sep 17 00:00:00 2001 From: Nizamudeen A Date: Tue, 18 Jun 2024 13:14:02 +0530 Subject: [PATCH] mgr/dashboard: fix (multi) cluster switcher disappearance after carbon UI Fixes: https://tracker.ceph.com/issues/66538 Signed-off-by: Nizamudeen A --- .../navigation/navigation.component.html | 15 +++++++++++++++ .../navigation/navigation.component.scss | 8 ++++++++ .../navigation/navigation.component.spec.ts | 7 ++++++- .../navigation/navigation/navigation.component.ts | 13 ++++++++++++- 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.html b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.html index 085733c20dbcb..ff16553a03689 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.html @@ -12,6 +12,21 @@ + + + + + + + + {{ cluster.value.name }} - {{ cluster.value?.cluster_alias }} - {{ cluster.value?.user }} + + + + + diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.scss b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.scss index 0dcecd98442be..56dc7e749a3ed 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.scss +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.scss @@ -24,6 +24,14 @@ height: 25px; } +cds-header-item { + width: 500px; +} + +.cluster-switcher { + margin-left: 6rem; +} + ::ng-deep cd-navigation .cd-navbar-top { .cd-navbar-brand { background: vv.$secondary; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.spec.ts index c674cfdcf5c07..9bf0bde51e222 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.spec.ts @@ -24,6 +24,7 @@ import { AdministrationComponent } from '../administration/administration.compon import { IdentityComponent } from '../identity/identity.component'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { DashboardHelpComponent } from '../dashboard-help/dashboard-help.component'; +import { DialogModule, GridModule, ThemeModule, UIShellModule } from 'carbon-components-angular'; function everythingPermittedExcept(disabledPermissions: string[] = []): any { const permissions: Permissions = new Permissions({}); @@ -71,7 +72,11 @@ describe('NavigationComponent', () => { ToastrModule.forRoot(), RouterTestingModule, SimplebarAngularModule, - NgbModule + NgbModule, + UIShellModule, + ThemeModule, + DialogModule, + GridModule ], providers: [AuthStorageService, SummaryService, FeatureTogglesService, PrometheusAlertService] }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.ts index fefe1d8dab5bc..55c9ab7e88dcc 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.ts @@ -40,7 +40,13 @@ export class NavigationComponent implements OnInit, OnDestroy { private subs = new Subscription(); clustersMap: Map = new Map(); - selectedCluster: object; + selectedCluster: { + name: string; + cluster_alias: string; + user: string; + cluster_connection_status?: number; + }; + currentClusterName: string; constructor( private authStorageService: AuthStorageService, @@ -74,6 +80,7 @@ export class NavigationComponent implements OnInit, OnDestroy { }); this.selectedCluster = this.clustersMap.get(`${resp['current_url']}-${resp['current_user']}`) || {}; + this.currentClusterName = `${this.selectedCluster?.name} - ${this.selectedCluster?.cluster_alias} - ${this.selectedCluster?.user}`; } }) ); @@ -182,4 +189,8 @@ export class NavigationComponent implements OnInit, OnDestroy { } ); } + + trackByFn(item: any) { + return item; + } } -- 2.39.5