|
| 1 | +// Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 | +// Copyright 2024 The Chromium Authors. All rights reserved. |
| 3 | +// Use of this source code is governed by a BSD-style license that can be |
| 4 | +// found in the LICENSE file. |
| 5 | + |
| 6 | +import * as i18n from '../../core/i18n/i18n.js'; |
| 7 | +import * as UI from '../../ui/legacy/legacy.js'; |
| 8 | + |
| 9 | +const UIStrings = { |
| 10 | + /** |
| 11 | + * @description Text for an option to learn more about something |
| 12 | + */ |
| 13 | + learnmore: 'Learn more', |
| 14 | + /** |
| 15 | + * @description Text in Timeline Panel of the Performance panel |
| 16 | + */ |
| 17 | + wasd: 'WASD', |
| 18 | + /** |
| 19 | + * @description Text in Timeline Panel of the Performance panel |
| 20 | + * @example {record} PH1 |
| 21 | + * @example {Ctrl + R} PH2 |
| 22 | + */ |
| 23 | + clickTheRecordButtonSOrHitSTo: 'Click the record button {PH1} or hit {PH2} to start a new recording.', |
| 24 | + /** |
| 25 | + * @description Text in Timeline Panel of the Performance panel |
| 26 | + * @example {Ctrl + U} PH1 |
| 27 | + * @example {Learn more} PH2 |
| 28 | + */ |
| 29 | + afterRecordingSelectAnAreaOf: |
| 30 | + 'After recording, select an area of interest in the overview by dragging. Then, zoom and pan the timeline with the mousewheel or {PH1} keys. {PH2}', |
| 31 | +} as const; |
| 32 | + |
| 33 | +const str_ = i18n.i18n.registerUIStrings('panels/timeline/ReactNativeTimelineLandingPage.ts', UIStrings); |
| 34 | +const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_); |
| 35 | + |
| 36 | +export class ReactNativeTimelineLandingPage extends UI.Widget.VBox { |
| 37 | + private readonly toggleRecordAction: UI.ActionRegistration.Action; |
| 38 | + |
| 39 | + constructor(toggleRecordAction: UI.ActionRegistration.Action) { |
| 40 | + super(); |
| 41 | + |
| 42 | + this.toggleRecordAction = toggleRecordAction; |
| 43 | + |
| 44 | + this.contentElement.classList.add('timeline-landing-page', 'fill'); |
| 45 | + this.renderLegacyLandingPage(); |
| 46 | + } |
| 47 | + |
| 48 | + private renderLegacyLandingPage(): void { |
| 49 | + function encloseWithTag(tagName: string, contents: string): HTMLElement { |
| 50 | + const e = document.createElement(tagName); |
| 51 | + e.textContent = contents; |
| 52 | + return e; |
| 53 | + } |
| 54 | + |
| 55 | + const learnMoreNode = UI.XLink.XLink.create( |
| 56 | + 'https://developer.chrome.com/docs/devtools/evaluate-performance/', i18nString(UIStrings.learnmore), undefined, |
| 57 | + undefined, 'learn-more'); |
| 58 | + |
| 59 | + const recordKey = encloseWithTag( |
| 60 | + 'b', |
| 61 | + UI.ShortcutRegistry.ShortcutRegistry.instance().shortcutsForAction('timeline.toggle-recording')[0].title()); |
| 62 | + const navigateNode = encloseWithTag('b', i18nString(UIStrings.wasd)); |
| 63 | + |
| 64 | + this.contentElement.classList.add('legacy'); |
| 65 | + const centered = this.contentElement.createChild('div'); |
| 66 | + |
| 67 | + const recordButton = UI.UIUtils.createInlineButton(UI.Toolbar.Toolbar.createActionButton(this.toggleRecordAction)); |
| 68 | + |
| 69 | + centered.createChild('p').appendChild(i18n.i18n.getFormatLocalizedString( |
| 70 | + str_, UIStrings.clickTheRecordButtonSOrHitSTo, {PH1: recordButton, PH2: recordKey})); |
| 71 | + |
| 72 | + centered.createChild('p').appendChild(i18n.i18n.getFormatLocalizedString( |
| 73 | + str_, UIStrings.afterRecordingSelectAnAreaOf, {PH1: navigateNode, PH2: learnMoreNode})); |
| 74 | + } |
| 75 | +} |
| 76 | + |
0 commit comments