55import * as Host from '../../core/host/host.js' ;
66import * as i18n from '../../core/i18n/i18n.js' ;
77import type * as Platform from '../../core/platform/platform.js' ;
8+ import * as LitHtml from '../../ui/lit-html/lit-html.js' ;
89
910import { Dialog } from './Dialog.js' ;
1011import { SizeBehavior } from './GlassPane.js' ;
11- import remoteDebuggingTerminatedScreenStyles from './remoteDebuggingTerminatedScreen.css.legacy. js' ;
12+ import remoteDebuggingTerminatedScreenStyles from './remoteDebuggingTerminatedScreen.css.js' ;
1213import { createTextButton } from './UIUtils.js' ;
1314import { VBox } from './Widget.js' ;
1415
1516const UIStrings = {
17+ /**
18+ * @description Title of a dialog box that appears when remote debugging has been terminated.
19+ */
20+ title : 'DevTools is disconnected' ,
1621 /**
1722 * @description Text in a dialog box in DevTools stating why remote debugging has been terminated.
1823 * "Remote debugging" here means that DevTools on a PC is inspecting a website running on an actual mobile device
@@ -26,63 +31,69 @@ const UIStrings = {
2631 * "Reconnect when ready", refers to the state of the mobile device. The developer first has to put the mobile
2732 * device back in a state where it can be inspected, before DevTools can reconnect to it.
2833 */
29- reconnectWhenReadyByReopening : 'Reconnect when ready (will reload DevTools).' ,
30- /**
31- * @description Text in a dialog box to explain `DevTools` can still be used while disconnected.
32- */
33- perserveState : 'Dismiss this dialog and continue using `DevTools` while disconnected.' ,
34- /**
35- * @description Text on a button to dismiss the dialog
36- */
37- closeDialog : 'Dismiss dialog' ,
34+ reconnectWhenReadyByReopening : 'Reconnect when ready (will reload DevTools)' ,
3835 /**
3936 * @description Text on a button to reconnect Devtools when remote debugging terminated.
4037 * "Remote debugging" here means that DevTools on a PC is inspecting a website running on an actual mobile device
4138 * (see https://developer.chrome.com/docs/devtools/remote-debugging/).
4239 */
4340 reconnectDevtools : 'Reconnect `DevTools`' ,
41+ /**
42+ * @description Text on a button to dismiss the dialog.
43+ */
44+ closeDialog : 'Dismiss' ,
45+ /**
46+ * @description Text in a dialog box to explain `DevTools` can still be used while disconnected.
47+ */
48+ closeDialogDetail : 'Dismiss this dialog and continue using `DevTools` while disconnected' ,
4449 /**
4550 * @description Text in a dialog box to prompt for feedback if the disconnection is unexpected.
4651 */
4752 sendFeedbackMessage : '[FB-only] Please send feedback if this disconnection is unexpected.' ,
4853 /**
4954 * @description Label of the FB-only 'send feedback' button.
5055 */
51- sendFeedback : '[FB-only] Send feedback' ,
56+ sendFeedback : 'Send feedback' ,
5257} ;
58+
5359const str_ = i18n . i18n . registerUIStrings ( 'ui/legacy/RemoteDebuggingTerminatedScreen.ts' , UIStrings ) ;
5460const i18nString = i18n . i18n . getLocalizedString . bind ( undefined , str_ ) ;
61+
62+ const { render, html} = LitHtml ;
63+
5564export class RemoteDebuggingTerminatedScreen extends VBox {
5665 constructor ( reason : string , onClose ?: ( ) => void ) {
5766 super ( true ) ;
58- this . registerRequiredCSS ( remoteDebuggingTerminatedScreenStyles ) ;
59- const message = this . contentElement . createChild ( 'div' , 'message' ) ;
60- const span = message . createChild ( 'span' ) ;
61- span . append ( i18nString ( UIStrings . debuggingConnectionWasClosed ) ) ;
62- const reasonElement = span . createChild ( 'span' , 'reason' ) ;
63- reasonElement . textContent = reason ;
64- this . contentElement . createChild ( 'div' , 'message' ) . textContent = i18nString ( UIStrings . reconnectWhenReadyByReopening ) ;
65-
66- const reconnectButton = createTextButton (
67- i18nString ( UIStrings . reconnectDevtools ) , ( ) => window . location . reload ( ) , { jslogContext : 'reconnect' } ) ;
68- this . contentElement . createChild ( 'div' , 'button' ) . appendChild ( reconnectButton ) ;
67+ this . registerCSSFiles ( [ remoteDebuggingTerminatedScreenStyles ] ) ;
6968
70- if ( onClose ) {
71- this . contentElement . createChild ( 'div' , 'message' ) . textContent = i18nString ( UIStrings . perserveState ) ;
69+ const handleReconnect = ( ) => {
70+ window . location . reload ( ) ;
71+ } ;
72+ const feedbackLink = globalThis . FB_ONLY__reactNativeFeedbackLink ;
7273
73- const closeButton = createTextButton ( i18nString ( UIStrings . closeDialog ) , onClose , { jslogContext : 'dismiss' } ) ;
74- this . contentElement . createChild ( 'div' , 'button' ) . appendChild ( closeButton ) ;
75- }
76-
77- if ( globalThis . FB_ONLY__reactNativeFeedbackLink ) {
78- this . contentElement . createChild ( 'div' , 'message' ) . textContent = i18nString ( UIStrings . sendFeedbackMessage ) ;
79-
80- const feedbackLink = globalThis . FB_ONLY__reactNativeFeedbackLink as Platform . DevToolsPath . UrlString ;
81- const feedbackButton = createTextButton ( i18nString ( UIStrings . sendFeedback ) , ( ) => {
82- Host . InspectorFrontendHost . InspectorFrontendHostInstance . openInNewTab ( feedbackLink ) ;
83- } , { className : 'primary-button' , jslogContext : 'sendFeedback' } ) ;
84- this . contentElement . createChild ( 'div' , 'button' ) . appendChild ( feedbackButton ) ;
85- }
74+ render (
75+ html `
76+ < h1 class ="remote-debugging-terminated-title "> ${ i18nString ( UIStrings . title ) } </ h1 >
77+ < span class ="remote-debugging-terminated-message "> ${ i18nString ( UIStrings . debuggingConnectionWasClosed ) } < span class ="remote-debugging-terminated-reason "> ${ reason } </ span > </ span >
78+ < div class ="remote-debugging-terminated-options ">
79+ < div class ="remote-debugging-terminated-label ">
80+ ${ i18nString ( UIStrings . reconnectWhenReadyByReopening ) }
81+ </ div >
82+ ${ createTextButton (
83+ i18nString ( UIStrings . reconnectDevtools ) ,
84+ handleReconnect ,
85+ { className : "primary-button" , jslogContext : "reconnect" }
86+ ) }
87+ < div class ="remote-debugging-terminated-label "> ${ i18nString ( UIStrings . closeDialogDetail ) } </ div >
88+ ${ createTextButton ( i18nString ( UIStrings . closeDialog ) , onClose , {
89+ jslogContext : "dismiss" ,
90+ } ) }
91+ </ div >
92+ ${ feedbackLink !== null && feedbackLink !== undefined
93+ ? this . #createFeedbackSection( feedbackLink ! ) : null }
94+ ` ,
95+ this . contentElement
96+ ) ;
8697 }
8798
8899 static show ( reason : string ) : void {
@@ -93,4 +104,23 @@ export class RemoteDebuggingTerminatedScreen extends VBox {
93104 dialog . show ( ) ;
94105 Host . rnPerfMetrics . remoteDebuggingTerminated ( reason ) ;
95106 }
107+
108+ #createFeedbackSection( feedbackLink : string ) : LitHtml . TemplateResult {
109+ const handleSendFeedback = ( ) => {
110+ Host . InspectorFrontendHost . InspectorFrontendHostInstance . openInNewTab (
111+ feedbackLink as Platform . DevToolsPath . UrlString
112+ ) ;
113+ } ;
114+
115+ return html `
116+ < div class ="remote-debugging-terminated-feedback-container ">
117+ < div class ="remote-debugging-terminated-feedback-label "> ${ i18nString ( UIStrings . sendFeedbackMessage ) } </ div >
118+ ${ createTextButton (
119+ i18nString ( UIStrings . sendFeedback ) ,
120+ handleSendFeedback ,
121+ { jslogContext : "sendFeedback" }
122+ ) }
123+ </ div >
124+ ` ;
125+ }
96126}
0 commit comments