/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import { html, ifDefined, when, } from "chrome://global/content/vendor/lit.all.mjs"; import { FxviewTabListBase, FxviewTabRowBase, } from "chrome://browser/content/firefoxview/fxview-tab-list.mjs"; // eslint-disable-next-line import/no-unassigned-import import "chrome://global/content/elements/moz-button.mjs"; const lazy = {}; let XPCOMUtils; XPCOMUtils = ChromeUtils.importESModule( "resource://gre/modules/XPCOMUtils.sys.mjs" ).XPCOMUtils; XPCOMUtils.defineLazyPreferenceGetter( lazy, "virtualListEnabledPref", "browser.firefox-view.virtual-list.enabled" ); /** * A list of synced tabs that are clickable and able to be remotely closed */ export class SyncedTabsTabList extends FxviewTabListBase { constructor() { super(); } static queries = { ...FxviewTabListBase.queries, rowEls: { all: "syncedtabs-tab-row", }, }; itemTemplate = (tabItem, i) => { return html` `; }; stylesheets() { return [ super.stylesheets(), html``, ]; } render() { if (this.searchQuery && !this.tabItems.length) { return this.emptySearchResultsTemplate(); } return html` ${this.stylesheets()}
${when( lazy.virtualListEnabledPref, () => html` `, () => html`${this.tabItems.map((tabItem, i) => this.itemTemplate(tabItem, i) )}` )}
`; } } customElements.define("syncedtabs-tab-list", SyncedTabsTabList); /** * A tab item that displays favicon, title, url, and time of last access * * @property {boolean} canClose - Whether the tab item has the ability to be closed remotely * @property {boolean} closeRequested - Whether the tab has been requested closed but not removed from the list * @property {string} fxaDeviceId - The device Id the tab item belongs to, for closing tabs remotely */ export class SyncedTabsTabRow extends FxviewTabRowBase { constructor() { super(); } static properties = { ...FxviewTabRowBase.properties, canClose: { type: Boolean }, closeRequested: { type: Boolean }, fxaDeviceId: { type: String }, }; secondaryButtonTemplate() { return html`${when( this.secondaryL10nId && this.secondaryActionHandler, () => html`` )}`; } render() { return html` ${this.stylesheets()} ${this.faviconTemplate()} ${this.titleTemplate()} ${when( !this.compact, () => html`${this.urlTemplate()} ${this.dateTemplate()} ${this.timeTemplate()}` )} ${this.secondaryButtonTemplate()} ${this.tertiaryButtonTemplate()} `; } } customElements.define("syncedtabs-tab-row", SyncedTabsTabRow);