File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -107,4 +107,24 @@ describeWithMockConnection('MediaMainView', () => {
107107 mainView . detach ( ) ;
108108 } ) ;
109109
110+ it ( 'shows a placeholder if all players are hidden after already selecting a player and showing its details' , ( ) => {
111+ const model = target . model ( Media . MediaModel . MediaModel ) ;
112+ assert . exists ( model ) ;
113+
114+ // Show main view, which will register event listeners on the model.
115+ const mainView = new Media . MainView . MainView ( ) ;
116+ mainView . markAsRoot ( ) ;
117+ mainView . show ( document . body ) ;
118+
119+ model . dispatchEventToListeners ( Media . MediaModel . Events . PLAYERS_CREATED , [ PLAYER_ID ] ) ;
120+ mainView . renderMainPanel ( PLAYER_ID ) ;
121+ assert . isNull ( mainView . contentElement . querySelector ( '.empty-state' ) ) ;
122+ mainView . markPlayerForDeletion ( PLAYER_ID ) ;
123+
124+ assert . deepEqual ( mainView . contentElement . querySelector ( '.empty-state-header' ) ?. textContent , 'No media player' ) ;
125+ assert . deepEqual (
126+ mainView . contentElement . querySelector ( '.empty-state-description span' ) ?. textContent ,
127+ 'On this page you can view and export media player details.' ) ;
128+ mainView . detach ( ) ;
129+ } ) ;
110130} ) ;
Original file line number Diff line number Diff line change @@ -177,6 +177,7 @@ export class MainView extends UI.Panel.PanelWithSidebar implements SDK.TargetMan
177177
178178 this . sidebar = new PlayerListView ( this ) ;
179179 this . sidebar . show ( this . panelSidebarElement ( ) ) ;
180+ this . splitWidget ( ) . hideSidebar ( ) ;
180181
181182 this . #placeholder =
182183 new UI . EmptyWidget . EmptyWidget ( i18nString ( UIStrings . noMediaPlayer ) , UIStrings . mediaPlayerDescription ) ;
@@ -317,6 +318,9 @@ export class MainView extends UI.Panel.PanelWithSidebar implements SDK.TargetMan
317318 }
318319
319320 private playersCreated ( event : Common . EventTarget . EventTargetEvent < Protocol . Media . PlayerId [ ] > ) : void {
321+ if ( event . data . length > 0 && this . splitWidget ( ) . showMode ( ) !== UI . SplitWidget . ShowMode . BOTH ) {
322+ this . splitWidget ( ) . showBoth ( ) ;
323+ }
320324 for ( const playerID of event . data ) {
321325 this . onPlayerCreated ( playerID ) ;
322326 }
@@ -331,6 +335,12 @@ export class MainView extends UI.Panel.PanelWithSidebar implements SDK.TargetMan
331335 if ( this . detailPanels . size === 0 ) {
332336 this . #placeholder. header = i18nString ( UIStrings . noMediaPlayer ) ;
333337 this . #placeholder. text = i18nString ( UIStrings . mediaPlayerDescription ) ;
338+ this . splitWidget ( ) . hideSidebar ( ) ;
339+ const mainWidget = this . splitWidget ( ) . mainWidget ( ) ;
340+ if ( mainWidget ) {
341+ mainWidget . detachChildWidgets ( ) ;
342+ }
343+ this . #placeholder. show ( this . mainElement ( ) ) ;
334344 }
335345 }
336346
You can’t perform that action at this time.
0 commit comments