// Copyright 2023 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import '../../../ui/kit/kit.js'; import * as i18n from '../../../core/i18n/i18n.js'; import * as Buttons from '../../../ui/components/buttons/buttons.js'; import * as UI from '../../../ui/legacy/legacy.js'; import * as Lit from '../../../ui/lit/lit.js'; import * as VisualLogging from '../../../ui/visual_logging/visual_logging.js'; import * as Models from '../models/models.js'; import * as Actions from '../recorder-actions/recorder-actions.js'; import recordingListViewStyles from './recordingListView.css.js'; const {html} = Lit; const UIStrings = { /** * @description The title of the page that contains a list of saved recordings that the user has.. */ savedRecordings: 'Saved recordings', /** * @description The title of the button that leads to create a new recording page. */ createRecording: 'Create a new recording', /** * @description The title of the button that is shown next to each of the recordings and that triggers playing of the recording. */ playRecording: 'Play recording', /** * @description The title of the button that is shown next to each of the recordings and that triggers deletion of the recording. */ deleteRecording: 'Delete recording', /** * @description The title of the row corresponding to a recording. By clicking on the row, the user open the recording for editing. */ openRecording: 'Open recording', } as const; const str_ = i18n.i18n.registerUIStrings( 'panels/recorder/components/RecordingListView.ts', UIStrings, ); const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_); declare global { interface HTMLElementTagNameMap { 'devtools-recording-list-view': RecordingListView; } interface HTMLElementEventMap { openrecording: OpenRecordingEvent; deleterecording: DeleteRecordingEvent; } } export class CreateRecordingEvent extends Event { static readonly eventName = 'createrecording'; constructor() { super(CreateRecordingEvent.eventName, {composed: true, bubbles: true}); } } export class DeleteRecordingEvent extends Event { static readonly eventName = 'deleterecording'; constructor(public storageName: string) { super(DeleteRecordingEvent.eventName, {composed: true, bubbles: true}); } } export class OpenRecordingEvent extends Event { static readonly eventName = 'openrecording'; constructor(public storageName: string) { super(OpenRecordingEvent.eventName, {composed: true, bubbles: true}); } } export class PlayRecordingEvent extends Event { static readonly eventName = 'playrecording'; constructor(public storageName: string) { super(PlayRecordingEvent.eventName, {composed: true, bubbles: true}); } } interface Recording { storageName: string; name: string; } interface ViewInput { recordings: readonly Recording[]; replayAllowed: boolean; onCreateClick: () => void; onDeleteClick: (storageName: string, event: Event) => void; onOpenClick: (storageName: string, event: Event) => void; onPlayRecordingClick: (storageName: string, event: Event) => void; onKeyDown: (storageName: string, event: Event) => void; } export type ViewOutput = object; export const DEFAULT_VIEW = (input: ViewInput, _output: ViewOutput, target: HTMLElement): void => { const { recordings, replayAllowed, onCreateClick, onDeleteClick, onOpenClick, onPlayRecordingClick, onKeyDown, } = input; // clang-format off Lit.render( html`