gecko-dev/browser/components/backup/content/turn-off-scheduled-backups.mjs
Stephen Thompson 6c1381ca4b Bug 1901308 - Show profile backup errors and keep modals open r=backup-reviewers,fluent-reviewers,firefox-desktop-core-reviewers ,mconley,bolsson
Currently, clicking "confirm" buttons on modals in the profile backup settings menu will always close the modals regardless of whether the operation succeeded or failed. In the case of errors, users don't know that something went wrong. It's better to keep the modals open and display an error so that the user knows what to do next and can try to fix the issue, if applicable.

Differential Revision: https://phabricator.services.mozilla.com/D218358
2024-08-06 18:21:16 +00:00

93 lines
2.8 KiB
JavaScript

/* 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 TurnOffScheduledBackups extends MozLitElement {
static get queries() {
return {
cancelButtonEl: "#backup-turn-off-scheduled-cancel-button",
confirmButtonEl: "#backup-turn-off-scheduled-confirm-button",
};
}
close() {
this.dispatchEvent(
new CustomEvent("dialogCancel", {
bubbles: true,
composed: true,
})
);
}
handleConfirm() {
this.dispatchEvent(
new CustomEvent("BackupUI:DisableScheduledBackups", {
bubbles: true,
})
);
}
contentTemplate() {
return html`
<div
id="backup-turn-off-scheduled-wrapper"
aria-labelledby="backup-turn-off-scheduled-header"
aria-describedby="backup-turn-off-scheduled-description"
>
<h1
id="backup-turn-off-scheduled-header"
class="heading-medium"
data-l10n-id="turn-off-scheduled-backups-header"
></h1>
<main id="backup-turn-off-scheduled-content">
<div id="backup-turn-off-scheduled-description">
<span
id="backup-turn-off-scheduled-description-span"
data-l10n-id="turn-off-scheduled-backups-description"
></span>
<!--TODO: finalize support page links (bug 1900467)-->
<a
id="backup-turn-off-scheduled-learn-more-link"
is="moz-support-link"
support-page="todo-backup"
data-l10n-id="turn-off-scheduled-backups-support-link"
></a>
</div>
</main>
<moz-button-group id="backup-turn-off-scheduled-button-group">
<moz-button
id="backup-turn-off-scheduled-cancel-button"
@click=${this.close}
data-l10n-id="turn-off-scheduled-backups-cancel-button"
></moz-button>
<moz-button
id="backup-turn-off-scheduled-confirm-button"
@click=${this.handleConfirm}
type="primary"
data-l10n-id="turn-off-scheduled-backups-confirm-button"
></moz-button>
</moz-button-group>
</div>
`;
}
render() {
return html`
<link
rel="stylesheet"
href="chrome://browser/content/backup/turn-off-scheduled-backups.css"
/>
${this.contentTemplate()}
`;
}
}
customElements.define("turn-off-scheduled-backups", TurnOffScheduledBackups);