@@ -20,6 +20,7 @@ import type {
20
20
NavigationItem ,
21
21
ServerConfig ,
22
22
TabData ,
23
+ TabPage ,
23
24
} from "../../common/types.js" ;
24
25
import defaultIcon from "../img/icon.png" ;
25
26
@@ -81,7 +82,7 @@ export class ServerManagerView {
81
82
loading : Set < string > ;
82
83
activeTabIndex : number ;
83
84
tabs : ServerOrFunctionalTab [ ] ;
84
- functionalTabs : Map < string , number > ;
85
+ functionalTabs : Map < TabPage , number > ;
85
86
tabIndex : number ;
86
87
presetOrgs : string [ ] ;
87
88
preferenceView ?: PreferenceView ;
@@ -333,7 +334,7 @@ export class ServerManagerView {
333
334
server . url ,
334
335
i ,
335
336
) ;
336
- tab . setName ( serverConfig . alias ) ;
337
+ tab . setLabel ( serverConfig . alias ) ;
337
338
tab . setIcon ( DomainUtil . iconAsUrl ( serverConfig . icon ) ) ;
338
339
( await tab . webview ) . setUnsupportedMessage (
339
340
DomainUtil . getUnsupportedMessage ( serverConfig ) ,
@@ -376,7 +377,7 @@ export class ServerManagerView {
376
377
const tab = new ServerTab ( {
377
378
role : "server" ,
378
379
icon : DomainUtil . iconAsUrl ( server . icon ) ,
379
- name : server . alias ,
380
+ label : server . alias ,
380
381
$root : this . $tabsContainer ,
381
382
onClick : this . activateLastTab . bind ( this , index ) ,
382
383
index,
@@ -558,18 +559,19 @@ export class ServerManagerView {
558
559
}
559
560
560
561
async openFunctionalTab ( tabProperties : {
561
- name : string ;
562
+ label : string ;
563
+ page : TabPage ;
562
564
materialIcon : string ;
563
565
makeView : ( ) => Promise < Element > ;
564
566
destroyView : ( ) => void ;
565
567
} ) : Promise < void > {
566
- if ( this . functionalTabs . has ( tabProperties . name ) ) {
567
- await this . activateTab ( this . functionalTabs . get ( tabProperties . name ) ! ) ;
568
+ if ( this . functionalTabs . has ( tabProperties . page ) ) {
569
+ await this . activateTab ( this . functionalTabs . get ( tabProperties . page ) ! ) ;
568
570
return ;
569
571
}
570
572
571
573
const index = this . tabs . length ;
572
- this . functionalTabs . set ( tabProperties . name , index ) ;
574
+ this . functionalTabs . set ( tabProperties . page , index ) ;
573
575
574
576
const tabIndex = this . getTabIndex ( ) ;
575
577
const $view = await tabProperties . makeView ( ) ;
@@ -579,13 +581,14 @@ export class ServerManagerView {
579
581
new FunctionalTab ( {
580
582
role : "function" ,
581
583
materialIcon : tabProperties . materialIcon ,
582
- name : tabProperties . name ,
584
+ label : tabProperties . label ,
585
+ page : tabProperties . page ,
583
586
$root : this . $tabsContainer ,
584
587
index,
585
588
tabIndex,
586
589
onClick : this . activateTab . bind ( this , index ) ,
587
590
onDestroy : async ( ) => {
588
- await this . destroyTab ( tabProperties . name , index ) ;
591
+ await this . destroyFunctionalTab ( tabProperties . page , index ) ;
589
592
tabProperties . destroyView ( ) ;
590
593
} ,
591
594
$view,
@@ -596,14 +599,15 @@ export class ServerManagerView {
596
599
// closed when the functional tab DOM is ready, handled in webview.js
597
600
this . $webviewsContainer . classList . remove ( "loaded" ) ;
598
601
599
- await this . activateTab ( this . functionalTabs . get ( tabProperties . name ) ! ) ;
602
+ await this . activateTab ( this . functionalTabs . get ( tabProperties . page ) ! ) ;
600
603
}
601
604
602
605
async openSettings (
603
606
navigationItem : NavigationItem = "General" ,
604
607
) : Promise < void > {
605
608
await this . openFunctionalTab ( {
606
- name : "Settings" ,
609
+ page : "Settings" ,
610
+ label : "Settings" ,
607
611
materialIcon : "settings" ,
608
612
makeView : async ( ) => {
609
613
this . preferenceView = await PreferenceView . create ( ) ;
@@ -622,7 +626,8 @@ export class ServerManagerView {
622
626
async openAbout ( ) : Promise < void > {
623
627
let aboutView : AboutView ;
624
628
await this . openFunctionalTab ( {
625
- name : "About" ,
629
+ page : "About" ,
630
+ label : "About" ,
626
631
materialIcon : "sentiment_very_satisfied" ,
627
632
async makeView ( ) {
628
633
aboutView = await AboutView . create ( ) ;
@@ -660,7 +665,8 @@ export class ServerManagerView {
660
665
get tabsForIpc ( ) : TabData [ ] {
661
666
return this . tabs . map ( ( tab ) => ( {
662
667
role : tab . properties . role ,
663
- name : tab . properties . name ,
668
+ page : tab . properties . page ,
669
+ label : tab . properties . label ,
664
670
index : tab . properties . index ,
665
671
} ) ) ;
666
672
}
@@ -680,7 +686,7 @@ export class ServerManagerView {
680
686
// If old tab is functional tab Settings, remove focus from the settings icon at sidebar bottom
681
687
if (
682
688
this . tabs [ this . activeTabIndex ] . properties . role === "function" &&
683
- this . tabs [ this . activeTabIndex ] . properties . name === "Settings"
689
+ this . tabs [ this . activeTabIndex ] . properties . page === "Settings"
684
690
) {
685
691
this . $settingsButton . classList . remove ( "active" ) ;
686
692
}
@@ -722,7 +728,7 @@ export class ServerManagerView {
722
728
this . $loadingIndicator . classList . toggle ( "hidden" , ! loading ) ;
723
729
}
724
730
725
- async destroyTab ( name : string , index : number ) : Promise < void > {
731
+ async destroyFunctionalTab ( page : TabPage , index : number ) : Promise < void > {
726
732
const tab = this . tabs [ index ] ;
727
733
if ( tab instanceof ServerTab && ( await tab . webview ) . loading ) {
728
734
return ;
@@ -731,7 +737,7 @@ export class ServerManagerView {
731
737
await tab . destroy ( ) ;
732
738
733
739
delete this . tabs [ index ] ; // eslint-disable-line @typescript-eslint/no-array-delete
734
- this . functionalTabs . delete ( name ) ;
740
+ this . functionalTabs . delete ( page ) ;
735
741
736
742
// Issue #188: If the functional tab was not focused, do not activate another tab.
737
743
if ( this . activeTabIndex === index ) {
@@ -1053,7 +1059,7 @@ export class ServerManagerView {
1053
1059
for ( const [ index , domain ] of DomainUtil . getDomains ( ) . entries ( ) ) {
1054
1060
if ( domain . url === serverURL ) {
1055
1061
const tab = this . tabs [ index ] ;
1056
- if ( tab instanceof ServerTab ) tab . setName ( realmName ) ;
1062
+ if ( tab instanceof ServerTab ) tab . setLabel ( realmName ) ;
1057
1063
domain . alias = realmName ;
1058
1064
DomainUtil . updateDomain ( index , domain ) ;
1059
1065
// Update the realm name also on the Window menu
0 commit comments