* @see VALID_TYPES */ type: { type: String, reflect: true }, // managed by BackupUIChild enableEncryptionErrorCode: { type: Number }, }; static get queries() { return { cancelButtonEl: "#backup-enable-encryption-cancel-button", confirmButtonEl: "#backup-enable-encryption-confirm-button", contentEl: "#backup-enable-encryption-content", textHeaderEl: "#backup-enable-encryption-header", textDescriptionEl: "#backup-enable-encryption-description", passwordInputsEl: "#backup-enable-encryption-password-inputs", errorEl: "#enable-backup-encryption-error", }; } constructor() { super(); this.supportBaseLink = ""; this.type = VALID_TYPES.SET_PASSWORD; this._inputPassValue = ""; this._passwordsMatch = false; this.enableEncryptionErrorCode = 0; } connectedCallback() { super.connectedCallback(); // Listening to events from child this.addEventListener("ValidPasswordsDetected", this); this.addEventListener("InvalidPasswordsDetected", this); } handleEvent(event) { if (event.type == "ValidPasswordsDetected") { let { password } = event.detail; this._passwordsMatch = true; this._inputPassValue = password; } else if (event.type == "InvalidPasswordsDetected") { this._passwordsMatch = false; this._inputPassValue = ""; } } close() { this.dispatchEvent( new CustomEvent("dialogCancel", { bubbles: true, composed: true, }) ); } reset() { this._inputPassValue = ""; this._passwordsMatch = false; this.passwordInputsEl.reset(); this.enableEncryptionErrorCode = 0; } handleConfirm() { this.dispatchEvent( new CustomEvent("BackupUI:EnableEncryption", { bubbles: true, detail: { password: this._inputPassValue, }, }) ); } descriptionTemplate() { return html`
`; } buttonGroupTemplate() { return html` `; } errorTemplate() { let messageId = getErrorL10nId(this.enableEncryptionErrorCode); return html` `; } contentTemplate() { return html`

${this.type === VALID_TYPES.SET_PASSWORD ? this.descriptionTemplate() : null} ${this.enableEncryptionErrorCode ? this.errorTemplate() : null}
${this.buttonGroupTemplate()}
`; } render() { return html` ${this.contentTemplate()} `; } } customElements.define("enable-backup-encryption", EnableBackupEncryption); PK