tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

turn-on-scheduled-backups.stories.mjs (2839B)


      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 // eslint-disable-next-line import/no-unresolved
      6 import { html, ifDefined } from "lit.all.mjs";
      7 import "chrome://global/content/elements/moz-card.mjs";
      8 import { ERRORS } from "chrome://browser/content/backup/backup-constants.mjs";
      9 import "./turn-on-scheduled-backups.mjs";
     10 
     11 window.MozXULElement.insertFTLIfNeeded("browser/backupSettings.ftl");
     12 window.MozXULElement.insertFTLIfNeeded("branding/brand.ftl");
     13 
     14 const SELECTABLE_ERRORS = {
     15  "(none)": 0,
     16  ...ERRORS,
     17 };
     18 
     19 export default {
     20  title: "Domain-specific UI Widgets/Backup/Turn On Scheduled Backups",
     21  component: "turn-on-scheduled-backups",
     22  argTypes: {
     23    enableBackupErrorCode: {
     24      options: Object.keys(SELECTABLE_ERRORS),
     25      mapping: SELECTABLE_ERRORS,
     26      control: { type: "select" },
     27    },
     28    hideFilePathChooser: { control: "boolean" },
     29    embeddedFxBackupOptIn: { control: "boolean" },
     30    isEncryptedBackup: { control: "boolean" },
     31  },
     32 };
     33 
     34 const Template = ({
     35  defaultPath,
     36  defaultLabel,
     37  _newPath,
     38  _newLabel,
     39  enableBackupErrorCode,
     40  hideFilePathChooser,
     41  embeddedFxBackupOptIn,
     42 }) => html`
     43  <turn-on-scheduled-backups
     44    defaultPath=${defaultPath}
     45    defaultLabel=${defaultLabel}
     46    _newPath=${ifDefined(_newPath)}
     47    _newLabel=${ifDefined(_newLabel)}
     48    .enableBackupErrorCode=${enableBackupErrorCode}
     49    ?hide-file-path-chooser=${hideFilePathChooser}
     50    ?embedded-fx-backup-opt-in=${embeddedFxBackupOptIn}
     51  ></turn-on-scheduled-backups>
     52 `;
     53 
     54 // ---------------------- Default / legacy stories ----------------------
     55 export const Default = Template.bind({});
     56 Default.args = {
     57  defaultPath: "/Some/User/Documents",
     58  defaultLabel: "Documents",
     59  hideFilePathChooser: false,
     60  embeddedFxBackupOptIn: false,
     61  enableBackupErrorCode: 0,
     62 };
     63 
     64 export const CustomLocation = Template.bind({});
     65 CustomLocation.args = {
     66  ...Default.args,
     67  _newPath: "/Some/Test/Custom/Dir",
     68  _newLabel: "Dir",
     69 };
     70 
     71 export const EnableError = Template.bind({});
     72 EnableError.args = {
     73  ...CustomLocation.args,
     74  enableBackupErrorCode: ERRORS.FILE_SYSTEM_ERROR,
     75 };
     76 
     77 // ---------------------- Embedded Fx Backup Opt-In Stories ----------------------
     78 export const EmbeddedFx_UnencryptedBackup = Template.bind({});
     79 EmbeddedFx_UnencryptedBackup.args = {
     80  ...Default.args,
     81  embeddedFxBackupOptIn: true,
     82  hideFilePathChooser: false, // Shows file path chooser, password section hidden via CSS
     83 };
     84 
     85 export const EmbeddedFx_EncryptedBackup_HideFilePathChooser = Template.bind({});
     86 EmbeddedFx_EncryptedBackup_HideFilePathChooser.args = {
     87  ...Default.args,
     88  embeddedFxBackupOptIn: true,
     89  hideFilePathChooser: true, // Hide file path chooser, show password input
     90 };