diff --git a/devtools_grd_files.gni b/devtools_grd_files.gni index 2afbdd580e..46c54e0e87 100644 --- a/devtools_grd_files.gni +++ b/devtools_grd_files.gni @@ -238,6 +238,7 @@ grd_files_release_sources = [ "front_end/heap_snapshot_worker/heap_snapshot_worker-legacy.js", "front_end/heap_snapshot_worker/heap_snapshot_worker.js", "front_end/help/help-legacy.js", + "front_end/help/help-meta.js", "front_end/help/help.js", "front_end/help/help_module.js", "front_end/host/host-legacy.js", diff --git a/devtools_module_entrypoints.gni b/devtools_module_entrypoints.gni index 55b76f4ecc..fa5533f46e 100644 --- a/devtools_module_entrypoints.gni +++ b/devtools_module_entrypoints.gni @@ -74,6 +74,7 @@ devtools_module_entrypoint_sources = [ "heap_snapshot_worker/heap_snapshot_worker-legacy.js", "heap_snapshot_worker/heap_snapshot_worker.js", "help/help-legacy.js", + "help/help-meta.js", "help/help.js", "host/host-legacy.js", "host/host.js", diff --git a/front_end/BUILD.gn b/front_end/BUILD.gn index 0d88c3de1c..2cfe9acf2d 100644 --- a/front_end/BUILD.gn +++ b/front_end/BUILD.gn @@ -54,6 +54,7 @@ group("front_end") { "heap_snapshot_model:bundle", "heap_snapshot_worker:worker_entrypoint", "help:bundle", + "help:meta", "i18n:bundle", "inline_editor:bundle", "input:bundle", diff --git a/front_end/devtools_app.js b/front_end/devtools_app.js index 2b67b6bdcb..a7fa7fc64a 100644 --- a/front_end/devtools_app.js +++ b/front_end/devtools_app.js @@ -14,6 +14,7 @@ import './developer_resources/developer_resources-meta.js'; import './inspector_main/inspector_main-meta.js'; import './resources/resources-meta.js'; import './issues/issues-meta.js'; +import './help/help-meta.js'; import * as Startup from './startup/startup.js'; Startup.RuntimeInstantiator.startApplication('devtools_app'); diff --git a/front_end/help/BUILD.gn b/front_end/help/BUILD.gn index dc3570c6b6..45807cbb46 100644 --- a/front_end/help/BUILD.gn +++ b/front_end/help/BUILD.gn @@ -36,3 +36,9 @@ devtools_entrypoint("legacy") { deps = [ ":bundle" ] } + +devtools_entrypoint("meta") { + entrypoint = "help-meta.ts" + + deps = [ ":bundle" ] +} diff --git a/front_end/help/ModuleUIStrings.ts b/front_end/help/ModuleUIStrings.ts index e44dd61e48..458f71c776 100644 --- a/front_end/help/ModuleUIStrings.ts +++ b/front_end/help/ModuleUIStrings.ts @@ -6,10 +6,6 @@ import * as i18n from '../i18n/i18n.js'; export const UIStrings = { - /** - *@description Title of the 'What's New' tool in the bottom drawer - */ - whatsNew: 'What\'s New', /** *@description Text for DevTools appearance */ diff --git a/front_end/help/ReleaseNoteView.ts b/front_end/help/ReleaseNoteView.ts index df6e64e70b..8f47cd0420 100644 --- a/front_end/help/ReleaseNoteView.ts +++ b/front_end/help/ReleaseNoteView.ts @@ -27,6 +27,7 @@ export const UIStrings = { }; const str_ = i18n.i18n.registerUIStrings('help/ReleaseNoteView.ts', UIStrings); const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_); +let releaseNoteViewInstance: ReleaseNoteView; export class ReleaseNoteView extends UI.Widget.VBox { _releaseNoteElement: Element; @@ -39,6 +40,14 @@ export class ReleaseNoteView extends UI.Widget.VBox { this.contentElement.appendChild(this._releaseNoteElement); } + static instance(opts: {forceNew: boolean|null;} = {forceNew: null}): ReleaseNoteView { + const {forceNew} = opts; + if (!releaseNoteViewInstance || forceNew) { + releaseNoteViewInstance = new ReleaseNoteView(); + } + return releaseNoteViewInstance; + } + elementsToRestoreScrollPositionsFor(): Element[] { return [this._releaseNoteElement]; } diff --git a/front_end/help/help-meta.ts b/front_end/help/help-meta.ts new file mode 100644 index 0000000000..2e88847f4e --- /dev/null +++ b/front_end/help/help-meta.ts @@ -0,0 +1,43 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import * as i18n from '../i18n/i18n.js'; +import * as Root from '../root/root.js'; +import * as UI from '../ui/ui.js'; + +// eslint-disable-next-line rulesdir/es_modules_import +import type * as Help from './help.js'; + +export const UIStrings = { + /** + *@description Title of the 'What's New' tool in the bottom drawer + */ + whatsNew: 'What\'s New', +}; +const str_ = i18n.i18n.registerUIStrings('help/help-meta.ts', UIStrings); +const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_); + +let loadedHelpModule: (typeof Help|undefined); + +async function loadHelpModule(): Promise { + if (!loadedHelpModule) { + // Side-effect import resources in module.json + await Root.Runtime.Runtime.instance().loadModulePromise('help'); + loadedHelpModule = await import('./help.js'); + } + return loadedHelpModule; +} + +UI.ViewManager.registerViewExtension({ + location: UI.ViewManager.ViewLocationValues.DRAWER_VIEW, + id: 'release-note', + title: () => i18nString(UIStrings.whatsNew), + commandPrompt: 'Show What\'s New', + persistence: UI.ViewManager.ViewPersistence.CLOSEABLE, + order: 1, + async loadView() { + const Help = await loadHelpModule(); + return Help.ReleaseNoteView.ReleaseNoteView.instance(); + }, +}); diff --git a/front_end/help/module.json b/front_end/help/module.json index 42e5c1e1e5..945f62f3ff 100644 --- a/front_end/help/module.json +++ b/front_end/help/module.json @@ -1,14 +1,5 @@ { "extensions": [ - { - "type": "view", - "location": "drawer-view", - "id": "release-note", - "title": "What's New", - "persistence": "closeable", - "order": 1, - "className": "Help.ReleaseNoteView" - }, { "type": "setting", "category": "Appearance", diff --git a/front_end/i18n/locales/en-US.json b/front_end/i18n/locales/en-US.json index 1accd7380b..748db85a85 100644 --- a/front_end/i18n/locales/en-US.json +++ b/front_end/i18n/locales/en-US.json @@ -398,6 +398,9 @@ "event_listeners/EventListenersView.ts | toggleWhetherEventListenerIs": { "message": "Toggle whether event listener is passive or blocking" }, + "help/help-meta.ts | whatsNew": { + "message": "What's New" + }, "help/ModuleUIStrings.ts | appearance": { "message": "Appearance" }, @@ -419,9 +422,6 @@ "help/ModuleUIStrings.ts | showWhatsNewAfterEachUpdate": { "message": "Show What's New after each update" }, - "help/ModuleUIStrings.ts | whatsNew": { - "message": "What's New" - }, "help/ReleaseNoteView.ts | close": { "message": "Close" },