disable-backup-encryption.mjs (3594B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 import { html } from "chrome://global/content/vendor/lit.all.mjs"; 6 import { MozLitElement } from "chrome://global/content/lit-utils.mjs"; 7 8 // eslint-disable-next-line import/no-unassigned-import 9 import "chrome://global/content/elements/moz-message-bar.mjs"; 10 11 const ERROR_L10N_ID = "backup-error-retry"; 12 13 /** 14 * The widget for disabling password protection if the backup is already 15 * encrypted. 16 */ 17 export default class DisableBackupEncryption extends MozLitElement { 18 static properties = { 19 // managed by BackupUIChild 20 disableEncryptionErrorCode: { type: Number }, 21 }; 22 23 static get queries() { 24 return { 25 cancelButtonEl: "#backup-disable-encryption-cancel-button", 26 confirmButtonEl: "#backup-disable-encryption-confirm-button", 27 errorEl: "#disable-backup-encryption-error", 28 }; 29 } 30 31 constructor() { 32 super(); 33 this.disableEncryptionErrorCode = 0; 34 } 35 36 close() { 37 this.dispatchEvent( 38 new CustomEvent("dialogCancel", { 39 bubbles: true, 40 composed: true, 41 }) 42 ); 43 this.reset(); 44 } 45 46 reset() { 47 this.disableEncryptionErrorCode = 0; 48 } 49 50 handleConfirm() { 51 this.dispatchEvent( 52 new CustomEvent("BackupUI:DisableEncryption", { 53 bubbles: true, 54 }) 55 ); 56 } 57 58 errorTemplate() { 59 return html` 60 <moz-message-bar 61 id="disable-backup-encryption-error" 62 type="error" 63 .messageL10nId=${ERROR_L10N_ID} 64 ></moz-message-bar> 65 `; 66 } 67 68 contentTemplate() { 69 return html` 70 <div 71 id="backup-disable-encryption-wrapper" 72 aria-labelledby="backup-disable-encryption-header" 73 aria-describedby="backup-disable-encryption-description" 74 > 75 <h1 76 id="backup-disable-encryption-header" 77 class="heading-medium" 78 data-l10n-id="disable-backup-encryption-header" 79 ></h1> 80 <main id="backup-disable-encryption-content"> 81 <div id="backup-disable-encryption-description"> 82 <span 83 id="backup-disable-encryption-description-span" 84 data-l10n-id="disable-backup-encryption-description2" 85 > 86 </span> 87 <a 88 id="backup-disable-encryption-learn-more-link" 89 is="moz-support-link" 90 support-page="firefox-backup" 91 data-l10n-id="disable-backup-encryption-support-link" 92 utm-content="remove-password" 93 ></a> 94 </div> 95 ${this.disableEncryptionErrorCode ? this.errorTemplate() : null} 96 </main> 97 98 <moz-button-group id="backup-disable-encryption-button-group"> 99 <moz-button 100 id="backup-disable-encryption-cancel-button" 101 @click=${this.close} 102 data-l10n-id="disable-backup-encryption-cancel-button" 103 ></moz-button> 104 <moz-button 105 id="backup-disable-encryption-confirm-button" 106 @click=${this.handleConfirm} 107 type="primary" 108 data-l10n-id="disable-backup-encryption-confirm-button" 109 ></moz-button> 110 </moz-button-group> 111 </div> 112 `; 113 } 114 115 render() { 116 return html` 117 <link 118 rel="stylesheet" 119 href="chrome://browser/content/backup/disable-backup-encryption.css" 120 /> 121 ${this.contentTemplate()} 122 `; 123 } 124 } 125 126 customElements.define("disable-backup-encryption", DisableBackupEncryption);