55import * as Common from '../../core/common/common.js' ;
66import * as i18n from '../../core/i18n/i18n.js' ;
77import * as Platform from '../../core/platform/platform.js' ;
8- import * as CrUXManager from '../../models/crux-manager/crux-manager.js' ;
98import type * as Trace from '../../models/trace/trace.js' ;
109import * as IconButton from '../../ui/components/icon_button/icon_button.js' ;
1110import * as UI from '../../ui/legacy/legacy.js' ;
@@ -39,6 +38,10 @@ const UIStrings = {
3938 *@description the title shown when the user is viewing the landing page which is showing live performance metrics that are updated automatically.
4039 */
4140 landingPageTitle : 'Live metrics' ,
41+ /**
42+ * @description the title shown when the user is viewing the landing page which can be used to make a new performance recording.
43+ */
44+ nodeLandingPageTitle : 'New recording' ,
4245 /**
4346 *@description Text in Timeline History Manager of the Performance panel
4447 *@example {example.com} PH1
@@ -112,13 +115,18 @@ export class TimelineHistoryManager {
112115 private enabled : boolean ;
113116 private lastActiveTrace : RecordingData | null = null ;
114117 #minimapComponent?: TimelineMiniMap ;
115- constructor ( minimapComponent ?: TimelineMiniMap ) {
118+ #landingPageTitle: Common . UIString . LocalizedString ;
119+
120+ constructor ( minimapComponent ?: TimelineMiniMap , isNode ?: boolean ) {
116121 this . recordings = [ ] ;
117122 this . #minimapComponent = minimapComponent ;
118123 this . action = UI . ActionRegistry . ActionRegistry . instance ( ) . getAction ( 'timeline.show-history' ) ;
119124 this . nextNumberByDomain = new Map ( ) ;
120125 this . buttonInternal = new ToolbarButton ( this . action ) ;
121126
127+ this . #landingPageTitle =
128+ isNode ? i18nString ( UIStrings . nodeLandingPageTitle ) : i18nString ( UIStrings . landingPageTitle ) ;
129+
122130 UI . ARIAUtils . markAsMenuButton ( this . buttonInternal . element ) ;
123131 this . clear ( ) ;
124132
@@ -160,25 +168,6 @@ export class TimelineHistoryManager {
160168 ] ;
161169 this . totalHeight = this . allOverviews . reduce ( ( acc , entry ) => acc + entry . height , 0 ) ;
162170 this . enabled = true ;
163-
164- CrUXManager . CrUXManager . instance ( ) . addEventListener ( CrUXManager . Events . FIELD_DATA_CHANGED , ( ) => {
165- this . #updateLandingPageTitleIfActive( ) ;
166- } ) ;
167- }
168-
169- /**
170- * If the user changes the CrUX consent status, the title shown in the
171- * dropdown could be outdated, as we show "Local" or "Local and field"
172- * depending on if the user has consented.
173- * This method will be called whenever the CrUXManager detects a change, and
174- * we use it as a chance to re-evaluate if the title needs changing or not.
175- */
176- #updateLandingPageTitleIfActive( ) : void {
177- if ( this . lastActiveTrace ?. type === 'LANDING_PAGE' ) {
178- const title = this . title ( this . lastActiveTrace ) ;
179- this . buttonInternal . setTitle ( title ) ;
180- this . buttonInternal . setText ( title ) ;
181- }
182171 }
183172
184173 addRecording ( newInput : NewHistoryRecordingData ) : void {
@@ -225,7 +214,7 @@ export class TimelineHistoryManager {
225214 this . recordings = [ ] ;
226215 this . lastActiveTrace = null ;
227216 this . updateState ( ) ;
228- this . buttonInternal . setText ( i18nString ( UIStrings . landingPageTitle ) ) ;
217+ this . buttonInternal . setText ( this . # landingPageTitle) ;
229218 this . nextNumberByDomain . clear ( ) ;
230219 }
231220
@@ -247,7 +236,7 @@ export class TimelineHistoryManager {
247236 // DropDown.show() function finishes when the dropdown menu is closed via selection or losing focus
248237 const activeTraceIndex = await DropDown . show (
249238 this . recordings . map ( recording => recording . parsedTraceIndex ) , this . #getActiveTraceIndexForListControl( ) ,
250- this . buttonInternal . element ) ;
239+ this . buttonInternal . element , this . #landingPageTitle ) ;
251240
252241 if ( activeTraceIndex === null ) {
253242 return null ;
@@ -336,7 +325,7 @@ export class TimelineHistoryManager {
336325
337326 private title ( item : RecordingData ) : string {
338327 if ( item . type === 'LANDING_PAGE' ) {
339- return i18nString ( UIStrings . landingPageTitle ) ;
328+ return this . # landingPageTitle;
340329 }
341330
342331 const data = TimelineHistoryManager . dataForTraceIndex ( item . parsedTraceIndex ) ;
@@ -463,8 +452,11 @@ export class DropDown implements UI.ListControl.ListDelegate<number> {
463452 private readonly listControl : UI . ListControl . ListControl < number > ;
464453 private readonly focusRestorer : UI . UIUtils . ElementFocusRestorer ;
465454 private selectionDone : ( ( arg0 : number | null ) => void ) | null ;
455+ #landingPageTitle: Common . UIString . LocalizedString ;
456+
457+ constructor ( availableparsedTraceIndexes : number [ ] , landingPageTitle : Common . UIString . LocalizedString ) {
458+ this . #landingPageTitle = landingPageTitle ;
466459
467- constructor ( availableparsedTraceIndexes : number [ ] ) {
468460 this . glassPane = new UI . GlassPane . GlassPane ( ) ;
469461 this . glassPane . setSizeBehavior ( UI . GlassPane . SizeBehavior . MEASURE_CONTENT ) ;
470462 this . glassPane . setOutsideClickCallback ( ( ) => this . close ( null ) ) ;
@@ -493,14 +485,16 @@ export class DropDown implements UI.ListControl.ListDelegate<number> {
493485 this . selectionDone = null ;
494486 }
495487
496- static show ( availableparsedTraceIndexes : number [ ] , activeparsedTraceIndex : number , anchor : Element ) :
488+ static show (
489+ availableparsedTraceIndexes : number [ ] , activeparsedTraceIndex : number , anchor : Element ,
490+ landingPageTitle : Common . UIString . LocalizedString = i18nString ( UIStrings . landingPageTitle ) ) :
497491 Promise < number | null > {
498492 if ( DropDown . instance ) {
499493 return Promise . resolve ( null ) ;
500494 }
501495 const availableDropdownChoices = [ ...availableparsedTraceIndexes ] ;
502496 availableDropdownChoices . unshift ( LANDING_PAGE_INDEX_DROPDOWN_CHOICE ) ;
503- const instance = new DropDown ( availableDropdownChoices ) ;
497+ const instance = new DropDown ( availableDropdownChoices , landingPageTitle ) ;
504498 return instance . show ( anchor , activeparsedTraceIndex ) ;
505499 }
506500
@@ -588,7 +582,7 @@ export class DropDown implements UI.ListControl.ListDelegate<number> {
588582 div . appendChild ( icon ) ;
589583
590584 const text = document . createElement ( 'span' ) ;
591- text . innerText = i18nString ( UIStrings . landingPageTitle ) ;
585+ text . innerText = this . # landingPageTitle;
592586 div . appendChild ( text ) ;
593587 return div ;
594588 }
0 commit comments