@@ -49,6 +49,7 @@ import * as TextUtils from '../../models/text_utils/text_utils.js';
4949import * as NetworkForward from '../../panels/network/forward/forward.js' ;
5050import * as Sources from '../../panels/sources/sources.js' ;
5151import * as Adorners from '../../ui/components/adorners/adorners.js' ;
52+ import * as Buttons from '../../ui/components/buttons/buttons.js' ;
5253import * as RenderCoordinator from '../../ui/components/render_coordinator/render_coordinator.js' ;
5354import * as DataGrid from '../../ui/legacy/components/data_grid/data_grid.js' ;
5455import * as PerfUI from '../../ui/legacy/components/perf_ui/perf_ui.js' ;
@@ -135,25 +136,40 @@ const UIStrings = {
135136 */
136137 dropHarFilesHere : 'Drop HAR files here' ,
137138 /**
138- *@description Recording text text content in Network Log View of the Network panel
139+ *@description Recording text content in Network Log View of the Network panel
139140 */
140- recordingNetworkActivity : 'Recording network activity… ' ,
141+ recordingNetworkActivity : 'Currently recording network activity' ,
141142 /**
142- *@description Text in Network Log View of the Network panel
143- *@example {Ctrl + R} PH1
143+ *@description Shown in the Network Log View of the Network panel when the user has not yet
144+ * recorded any network activity. This is an instruction to the user to reload the page in order to
145+ * show network activity in the current UI.
146+ *@example {Reload page} PH1
147+ *@example {Ctrl + R} PH2
144148 */
145- performARequestOrHitSToRecordThe : 'Perform a request or hit {PH1} to record the reload.' ,
149+ performARequestOrHitSToRecordThe :
150+ 'Perform a request or reload the page by using the "{PH1}" button or by hitting {PH2}.' ,
146151 /**
147152 *@description Shown in the Network Log View of the Network panel when the user has not yet
148153 * recorded any network activity. This is an instruction to the user to start recording in order to
149154 * show network activity in the current UI.
150- *@example {Ctrl + E} PH1
155+ * @example {Start recording} PH1
156+ * @example {Ctrl + E} PH2
157+ */
158+ recordToDisplayNetworkActivity :
159+ 'Record network log to display network activity by using the "{PH1}" button or by hitting {PH2}.' ,
160+ /**
161+ *@description Label of a button in the Network Log View of the Network panel.
151162 */
152- recordToDisplayNetworkActivity : 'Record network log ({PH1}) to display network activity. ' ,
163+ reloadPage : 'Reload page ' ,
153164 /**
154- *@description Text that is usually a hyperlink to more documentation
165+ *@description Label of a button in the Network Log View of the Network panel.
155166 */
156- learnMore : 'Learn more' ,
167+ startRecording : 'Start recording' ,
168+ /**
169+ *@description Shown in the Network Log View of the Network panel when the user has not yet
170+ * recorded any network activity.
171+ */
172+ noNetworkActivityRecorded : 'No network activity recorded' ,
157173 /**
158174 *@description Text to announce to screen readers that network data is available.
159175 */
@@ -482,7 +498,7 @@ export class NetworkLogView extends Common.ObjectWrapper.eventMixin<EventTypes,
482498 private filters : Filter [ ] ;
483499 private timeFilter : Filter | null ;
484500 private hoveredNodeInternal : NetworkNode | null ;
485- private recordingHint : Element | null ;
501+ private recordingHint : UI . EmptyWidget . EmptyWidget | null ;
486502 private highlightedNode : NetworkRequestNode | null ;
487503 private readonly linkifierInternal : Components . Linkifier . Linkifier ;
488504 private recording : boolean ;
@@ -1078,47 +1094,43 @@ export class NetworkLogView extends Common.ObjectWrapper.eventMixin<EventTypes,
10781094
10791095 private showRecordingHint ( ) : void {
10801096 this . hideRecordingHint ( ) ;
1081- this . recordingHint = this . element . createChild ( 'div' , 'network-status-pane fill' ) ;
1082- const hintText = this . recordingHint . createChild ( 'div' , 'recording-hint' ) ;
1083-
1084- if ( this . recording ) {
1085- let reloadShortcutNode : Element | null = null ;
1086- const reloadShortcut =
1087- UI . ShortcutRegistry . ShortcutRegistry . instance ( ) . shortcutsForAction ( 'inspector-main.reload' ) [ 0 ] ;
1088- if ( reloadShortcut ) {
1089- reloadShortcutNode = this . recordingHint . createChild ( 'b' ) ;
1090- reloadShortcutNode . textContent = reloadShortcut . title ( ) ;
1091- }
10921097
1093- const recordingText = hintText . createChild ( 'span' ) ;
1094- recordingText . textContent = i18nString ( UIStrings . recordingNetworkActivity ) ;
1095- if ( reloadShortcutNode ) {
1096- hintText . createChild ( 'br' ) ;
1097- hintText . appendChild ( i18n . i18n . getFormatLocalizedString (
1098- str_ , UIStrings . performARequestOrHitSToRecordThe , { PH1 : reloadShortcutNode } ) ) ;
1099- }
1100- } else {
1101- const recordNode = hintText . createChild ( 'b' ) ;
1102- recordNode . textContent =
1103- UI . ShortcutRegistry . ShortcutRegistry . instance ( ) . shortcutTitleForAction ( 'network.toggle-recording' ) || '' ;
1104- hintText . appendChild (
1105- i18n . i18n . getFormatLocalizedString ( str_ , UIStrings . recordToDisplayNetworkActivity , { PH1 : recordNode } ) ) ;
1106- }
1107- hintText . createChild ( 'br' ) ;
1108- hintText . appendChild ( UI . XLink . XLink . create (
1109- 'https://developer.chrome.com/docs/devtools/network/?utm_source=devtools&utm_campaign=2019Q1' ,
1110- i18nString ( UIStrings . learnMore ) , undefined , undefined , 'learn-more' ) ) ;
1098+ const actionName = this . recording ? 'inspector-main.reload' : 'network.toggle-recording' ;
1099+ const action = UI . ActionRegistry . ActionRegistry . instance ( ) . getAction ( actionName ) ;
1100+ const shortcutTitle = UI . ShortcutRegistry . ShortcutRegistry . instance ( ) . shortcutTitleForAction ( actionName ) ?? '' ;
1101+
1102+ const header = this . recording ? i18nString ( UIStrings . recordingNetworkActivity ) :
1103+ i18nString ( UIStrings . noNetworkActivityRecorded ) ;
1104+ const instruction =
1105+ this . recording ? UIStrings . performARequestOrHitSToRecordThe : UIStrings . recordToDisplayNetworkActivity ;
1106+ const buttonText = this . recording ? i18nString ( UIStrings . reloadPage ) : i18nString ( UIStrings . startRecording ) ;
1107+ // eslint-disable-next-line rulesdir/l10n-i18nString-call-only-with-uistrings
1108+ const description = i18nString ( instruction , {
1109+ PH1 : buttonText ,
1110+ PH2 : shortcutTitle ,
1111+ } ) ;
11111112
1113+ this . recordingHint = new UI . EmptyWidget . EmptyWidget ( header , shortcutTitle ? description : '' ) ;
1114+ this . recordingHint . element . classList . add ( 'network-status-pane' ) ;
1115+ this . recordingHint . appendLink (
1116+ 'https://developer.chrome.com/docs/devtools/network/' as Platform . DevToolsPath . UrlString ) ;
1117+ const button = UI . UIUtils . createTextButton ( buttonText , ( ) => action . execute ( ) , {
1118+ jslogContext : actionName ,
1119+ variant : Buttons . Button . Variant . TONAL ,
1120+ } ) ;
1121+ this . recordingHint . contentElement . appendChild ( button ) ;
1122+
1123+ this . recordingHint . show ( this . element ) ;
11121124 this . setHidden ( true ) ;
11131125 }
11141126
11151127 private hideRecordingHint ( ) : void {
11161128 this . setHidden ( false ) ;
11171129 if ( this . recordingHint ) {
1118- this . recordingHint . remove ( ) ;
1130+ this . recordingHint . detach ( ) ;
1131+ this . recordingHint = null ;
11191132 }
11201133 UI . ARIAUtils . alert ( i18nString ( UIStrings . networkDataAvailable ) ) ;
1121- this . recordingHint = null ;
11221134 }
11231135
11241136 private setHidden ( value : boolean ) : void {
0 commit comments