/* 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 } from "chrome://global/content/vendor/lit.all.mjs"; import { MozLitElement } from "chrome://global/content/lit-utils.mjs"; /** * The widget for showing available options when users want to turn on * scheduled backups. */ export default class TurnOnScheduledBackups extends MozLitElement { static properties = { backupFilePath: { type: String }, showPasswordOptions: { type: Boolean, reflect: true }, }; static get queries() { return { cancelButtonEl: "#backup-turn-on-scheduled-cancel-button", confirmButtonEl: "#backup-turn-on-scheduled-confirm-button", passwordOptionsCheckboxEl: "#sensitive-data-checkbox-input", passwordOptionsExpandedEl: "#passwords", recommendedFolderInputEl: "#backup-location-filepicker-input", }; } constructor() { super(); this.backupFilePath = null; this.showPasswordOptions = false; } /** * Dispatches the BackupUI:InitWidget custom event upon being attached to the * DOM, which registers with BackupUIChild for BackupService state updates. */ connectedCallback() { super.connectedCallback(); this.dispatchEvent( new CustomEvent("BackupUI:InitWidget", { bubbles: true }) ); } handleChooseLocation() { // TODO: show file picker (bug 1895943) } handleCancel() { this.dispatchEvent( new CustomEvent("scheduledBackupsCancel", { bubbles: true, composed: true, }) ); this.showPasswordOptions = false; this.passwordOptionsCheckboxEl.checked = false; } handleConfirm() { /** * TODO: * We should pass save location to BackupUIParent here (bug 1895943). * If encryption is enabled via this dialog, ensure a password is set and pass it to BackupUIParent (bug 1895981). * Before confirmation, verify passwords match and FxA format rules (bug 1896772). */ this.dispatchEvent( new CustomEvent("scheduledBackupsConfirm", { bubbles: true, composed: true, }) ); this.showPasswordOptions = false; this.passwordOptionsCheckboxEl.checked = false; } handleTogglePasswordOptions() { this.showPasswordOptions = this.passwordOptionsCheckboxEl?.checked; } allOptionsTemplate() { return html`
`; } passwordOptionsTemplate() { return html`