Skip to content

Commit 35d4957

Browse files
authored
Update disconnected dialog styling (#123)
1 parent 16dcac5 commit 35d4957

File tree

4 files changed

+115
-48
lines changed

4 files changed

+115
-48
lines changed

config/gni/devtools_grd_files.gni

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2169,7 +2169,7 @@ grd_files_debug_sources = [
21692169
"front_end/ui/legacy/popover.css.legacy.js",
21702170
"front_end/ui/legacy/progressIndicator.css.legacy.js",
21712171
"front_end/ui/legacy/radioButton.css.legacy.js",
2172-
"front_end/ui/legacy/remoteDebuggingTerminatedScreen.css.legacy.js",
2172+
"front_end/ui/legacy/remoteDebuggingTerminatedScreen.css.js",
21732173
"front_end/ui/legacy/reportView.css.legacy.js",
21742174
"front_end/ui/legacy/rootView.css.legacy.js",
21752175
"front_end/ui/legacy/searchableView.css.legacy.js",

front_end/ui/legacy/BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ generate_css("css_files") {
1212
sources = [
1313
"emptyWidget.css",
1414
"inspectorCommon.css",
15+
"remoteDebuggingTerminatedScreen.css",
1516
]
1617
}
1718

@@ -35,7 +36,6 @@ generate_css("legacy_css_files") {
3536
"popover.css",
3637
"progressIndicator.css",
3738
"radioButton.css",
38-
"remoteDebuggingTerminatedScreen.css",
3939
"reportView.css",
4040
"rootView.css",
4141
"searchableView.css",

front_end/ui/legacy/RemoteDebuggingTerminatedScreen.ts

Lines changed: 67 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@
55
import * as Host from '../../core/host/host.js';
66
import * as i18n from '../../core/i18n/i18n.js';
77
import type * as Platform from '../../core/platform/platform.js';
8+
import * as LitHtml from '../../ui/lit-html/lit-html.js';
89

910
import {Dialog} from './Dialog.js';
1011
import {SizeBehavior} from './GlassPane.js';
11-
import remoteDebuggingTerminatedScreenStyles from './remoteDebuggingTerminatedScreen.css.legacy.js';
12+
import remoteDebuggingTerminatedScreenStyles from './remoteDebuggingTerminatedScreen.css.js';
1213
import {createTextButton} from './UIUtils.js';
1314
import {VBox} from './Widget.js';
1415

1516
const 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+
5359
const str_ = i18n.i18n.registerUIStrings('ui/legacy/RemoteDebuggingTerminatedScreen.ts', UIStrings);
5460
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
61+
62+
const {render, html} = LitHtml;
63+
5564
export 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
}

front_end/ui/legacy/remoteDebuggingTerminatedScreen.css

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,62 @@
88
padding: 20px;
99
}
1010

11-
.message,
12-
.button {
13-
font-size: larger;
11+
.remote-debugging-terminated-title {
12+
font-size: 17px;
13+
font-weight: normal;
14+
margin: 6px 0;
15+
}
16+
17+
.remote-debugging-terminated-message {
18+
font-size: 14px;
1419
white-space: pre;
15-
margin: 5px;
20+
margin: 5px 0;
21+
margin-bottom: 24px;
22+
}
23+
24+
.remote-debugging-terminated-options {
25+
display: grid;
26+
grid-template-columns: 1fr auto;
27+
grid-gap: 8px;
28+
align-items: center;
29+
padding-top: 12px;
30+
border-top: 1px solid var(--color-details-hairline-light);
31+
}
32+
33+
.remote-debugging-terminated-label {
34+
grid-column: 1;
35+
margin: 8px 0;
36+
max-width: 300px;
37+
font-size: larger;
38+
line-height: 1.4;
39+
}
40+
41+
.remote-debugging-terminated-options .text-button {
42+
grid-column: 2;
43+
}
44+
45+
.remote-debugging-terminated-feedback-container {
46+
display: flex;
47+
flex-direction: column;
48+
align-items: center;
49+
margin-top: 16px;
50+
padding: 12px 16px;
51+
background-color: var(--color-background-elevation-1);
52+
border-radius: 6px;
1653
}
1754

18-
.button {
19-
text-align: center;
20-
margin-top: 10px;
55+
.remote-debugging-terminated-feedback-label {
56+
font-size: 14px;
57+
margin-bottom: 8px;
2158
}
2259

23-
.reason {
60+
.remote-debugging-terminated-reason {
2461
--override-reason-color: #8b0000;
2562

2663
color: var(--override-reason-color);
2764
}
2865

29-
.-theme-with-dark-background .reason,
66+
.-theme-with-dark-background .remote-debugging-terminated-reason,
3067
:host-context(.-theme-with-dark-background) .reason {
3168
--override-reason-color: rgb(255 116 116);
3269
}

0 commit comments

Comments
 (0)