Skip to content

Commit 23234c7

Browse files
authored
Merge pull request ceph#58110 from rhcs-dashboard/bring-back-cluster-swticher
mgr/dashboard: fix (multi) cluster switcher disappearance after carbon UI shell Reviewed-by: Aashish Sharma <[email protected]> Reviewed-by: Ankush Behl <[email protected]> Reviewed-by: ivoalmeida <NOT@FOUND>
2 parents 2856be9 + d568566 commit 23234c7

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed

src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@
1212
<cds-hamburger [active]="showMenuSidebar"
1313
data-testid="main-menu-toggler"
1414
(selected)="showMenuSidebar = !showMenuSidebar"></cds-hamburger>
15+
<!-- ************************* -->
16+
<!-- CLUSTER SWITCHER TEMPLATE -->
17+
<!-- ************************* -->
18+
<cds-header-navigation class="cluster-switcher"
19+
*ngIf="clustersMap?.size > 1">
20+
<cds-header-menu [title]="currentClusterName">
21+
<ng-container *ngFor="let cluster of clustersMap | keyvalue; trackBy:trackByFn ">
22+
<cds-header-item (click)="onClusterSelection(cluster.value)"
23+
[class.disabled]="cluster.value.cluster_connection_status === 1">
24+
{{ cluster.value.name }} - {{ cluster.value?.cluster_alias }} - {{ cluster.value?.user }}
25+
</cds-header-item>
26+
</ng-container>
27+
</cds-header-menu>
28+
</cds-header-navigation>
29+
1530
<cds-header-global>
1631
<cds-header-navigation>
1732
<cd-language-selector class="d-flex"></cd-language-selector>

src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@
2424
height: 25px;
2525
}
2626

27+
cds-header-item {
28+
width: 500px;
29+
}
30+
31+
.cluster-switcher {
32+
margin-left: 6rem;
33+
}
34+
2735
::ng-deep cd-navigation .cd-navbar-top {
2836
.cd-navbar-brand {
2937
background: vv.$secondary;

src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { AdministrationComponent } from '../administration/administration.compon
2424
import { IdentityComponent } from '../identity/identity.component';
2525
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
2626
import { DashboardHelpComponent } from '../dashboard-help/dashboard-help.component';
27+
import { DialogModule, GridModule, ThemeModule, UIShellModule } from 'carbon-components-angular';
2728

2829
function everythingPermittedExcept(disabledPermissions: string[] = []): any {
2930
const permissions: Permissions = new Permissions({});
@@ -71,7 +72,11 @@ describe('NavigationComponent', () => {
7172
ToastrModule.forRoot(),
7273
RouterTestingModule,
7374
SimplebarAngularModule,
74-
NgbModule
75+
NgbModule,
76+
UIShellModule,
77+
ThemeModule,
78+
DialogModule,
79+
GridModule
7580
],
7681
providers: [AuthStorageService, SummaryService, FeatureTogglesService, PrometheusAlertService]
7782
});

src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ export class NavigationComponent implements OnInit, OnDestroy {
4040
private subs = new Subscription();
4141

4242
clustersMap: Map<string, any> = new Map<string, any>();
43-
selectedCluster: object;
43+
selectedCluster: {
44+
name: string;
45+
cluster_alias: string;
46+
user: string;
47+
cluster_connection_status?: number;
48+
};
49+
currentClusterName: string;
4450

4551
constructor(
4652
private authStorageService: AuthStorageService,
@@ -74,6 +80,7 @@ export class NavigationComponent implements OnInit, OnDestroy {
7480
});
7581
this.selectedCluster =
7682
this.clustersMap.get(`${resp['current_url']}-${resp['current_user']}`) || {};
83+
this.currentClusterName = `${this.selectedCluster?.name} - ${this.selectedCluster?.cluster_alias} - ${this.selectedCluster?.user}`;
7784
}
7885
})
7986
);
@@ -182,4 +189,8 @@ export class NavigationComponent implements OnInit, OnDestroy {
182189
}
183190
);
184191
}
192+
193+
trackByFn(item: any) {
194+
return item;
195+
}
185196
}

0 commit comments

Comments
 (0)