Skip to content

Commit 0d1741a

Browse files
ktranDevtools-frontend LUCI CQ
authored andcommitted
[GM3Restyling] Update memory inspector empty state
Before: https://i.imgur.com/KR2pbuZ.png After: https://i.imgur.com/05JUtRz.png Bug: 325443331 Change-Id: If54e8d19dc3af5509e41376cd16fa01a86e64a25 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6276130 Reviewed-by: Kateryna Prokopenko <[email protected]> Commit-Queue: Kim-Anh Tran <[email protected]>
1 parent 4e93b4f commit 0d1741a

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

front_end/panels/linear_memory_inspector/LinearMemoryInspectorPane.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,13 @@ describeWithEnvironment('LinearMemoryInspectorPane', () => {
4242
const inspector = tabbedPane.querySelector('devtools-linear-memory-inspector-inspector');
4343
assert.notInstanceOf(inspector, HTMLSpanElement);
4444
});
45+
46+
it('placeholder is as expected', () => {
47+
const instance = LinearMemoryInspector.LinearMemoryInspectorPane.LinearMemoryInspectorPane.instance();
48+
const placeholder = instance.createPlaceholder();
49+
assert.deepEqual(placeholder.querySelector('.empty-state-header')?.textContent, 'No open inspections');
50+
assert.deepEqual(
51+
placeholder.querySelector('.empty-state-description > span')?.textContent,
52+
'On this page you can inspect binary data.');
53+
});
4554
});

front_end/panels/linear_memory_inspector/LinearMemoryInspectorPane.ts

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import * as Common from '../../core/common/common.js';
66
import * as i18n from '../../core/i18n/i18n.js';
7+
import type * as Platform from '../../core/platform/platform.js';
78
import * as UI from '../../ui/legacy/legacy.js';
89
import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
910

@@ -16,23 +17,32 @@ const UIStrings = {
1617
* Inspection hereby refers to viewing, navigating and understanding the memory through this tool.
1718
*/
1819
noOpenInspections: 'No open inspections',
20+
/**
21+
*@description Label in the Linear Memory inspector tool that serves as a placeholder if no inspections are open (i.e. nothing to see here).
22+
* Inspection hereby refers to viewing, navigating and understanding the memory through this tool.
23+
*/
24+
memoryInspectorExplanation: 'On this page you can inspect binary data.',
25+
/**
26+
*@description Label in the Linear Memory inspector tool for a link.
27+
*/
28+
learnMore: 'Learn more',
1929
};
2030
const str_ = i18n.i18n.registerUIStrings('panels/linear_memory_inspector/LinearMemoryInspectorPane.ts', UIStrings);
2131
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
2232
let inspectorInstance: LinearMemoryInspectorPane;
2333

34+
const MEMORY_INSPECTOR_EXPLANATION_URL =
35+
'https://developer.chrome.com/docs/devtools/memory-inspector' as Platform.DevToolsPath.UrlString;
36+
2437
export class LinearMemoryInspectorPane extends Common.ObjectWrapper.eventMixin<EventTypes, typeof UI.Widget.VBox>(
2538
UI.Widget.VBox) {
2639
readonly #tabbedPane: UI.TabbedPane.TabbedPane;
2740

2841
constructor() {
2942
super(false);
3043
this.element.setAttribute('jslog', `${VisualLogging.panel('linear-memory-inspector').track({resize: true})}`);
31-
const placeholder = document.createElement('div');
32-
placeholder.textContent = i18nString(UIStrings.noOpenInspections);
33-
placeholder.style.display = 'flex';
3444
this.#tabbedPane = new UI.TabbedPane.TabbedPane();
35-
this.#tabbedPane.setPlaceholderElement(placeholder);
45+
this.#tabbedPane.setPlaceholderElement(this.createPlaceholder());
3646
this.#tabbedPane.setCloseableTabs(true);
3747
this.#tabbedPane.setAllowTabReorder(true, true);
3848
this.#tabbedPane.addEventListener(UI.TabbedPane.Events.TabClosed, this.#tabClosed, this);
@@ -41,6 +51,21 @@ export class LinearMemoryInspectorPane extends Common.ObjectWrapper.eventMixin<E
4151
'jslog', `${VisualLogging.toolbar().track({keydown: 'ArrowUp|ArrowLeft|ArrowDown|ArrowRight|Enter|Space'})}`);
4252
}
4353

54+
createPlaceholder(): HTMLElement {
55+
const placeholder = document.createElement('div');
56+
placeholder.classList.add('empty-state');
57+
58+
placeholder.createChild('span', 'empty-state-header').textContent = i18nString(UIStrings.noOpenInspections);
59+
60+
const description = placeholder.createChild('div', 'empty-state-description');
61+
description.createChild('span').textContent = i18nString(UIStrings.memoryInspectorExplanation);
62+
const link = UI.XLink.XLink.create(
63+
MEMORY_INSPECTOR_EXPLANATION_URL, i18nString(UIStrings.learnMore), undefined, undefined, 'learn-more');
64+
description.appendChild(link);
65+
66+
return placeholder;
67+
}
68+
4469
static instance(): LinearMemoryInspectorPane {
4570
if (!inspectorInstance) {
4671
inspectorInstance = new LinearMemoryInspectorPane();

0 commit comments

Comments
 (0)