forked from mirrors/gecko-dev
This adds:
1. A new <migration-wizard> component
2. A new migration-dialog.html document that loads it
3. JSWindowActors for communicating between whatever process the migration-wizard is
loaded in and the parent process. The actors are currently restricted to running
in these documents:
about:welcome
about:preferences
chrome://browser/content/migration/migration-dialog.html
4. A very small, simple mochitest-chrome test for testing the widget
5. Some Fluent strings for the new <migration-wizard>, dropped into a new folder in
/browser called "locales-preview". This is so that both the jar packaging can
put the Fluent file somewhere sensible that doesn't (currently) require our
localizers to translate, but also so that Storybook can load that Fluent file.
6. Modifications to our Storybook infrastructure so that attempts to load items
from locales-preview will map to the browser/locales-preview folder.
7. A Storybook story for the <migration-wizard> that puts it in a few basic states.
Most of those states aren't actually implemented yet, but are left in the story to
make it easier to develop those states in the component.
The hope is that when this is done, it should be relatively straight-forward to
embed the <migration-wizard> not just in the migration-dialog.html document (which
is used for tab modals and the stand alone migration dialog), but also in existing
in-content pages like about:welcome and about:preferences.
For those worried about the TODO strings or incomplete behaviour, remember that this
is just a base for building upon, and that this component / dialog isn't actually
exposed to users yet.
The dialog can be opened manually via:
```lang=js
gBrowser.getTabDialogBox(gBrowser.selectedBrowser).open("chrome://browser/content/migration/migration-dialog.html")
```
and see the documentation in browser/components/storybook/README.md for guidance on
how to view this component using Storybook.
Differential Revision: https://phabricator.services.mozilla.com/D162623
57 lines
1.8 KiB
JavaScript
57 lines
1.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 { MigrationWizard } from "chrome://browser/content/migration/migration-wizard.mjs";
|
|
|
|
/**
|
|
* This class is responsible for updating the state of a <migration-wizard>
|
|
* component, and for listening for events from that component to perform
|
|
* various migration functions.
|
|
*/
|
|
export class MigrationWizardChild extends JSWindowActorChild {
|
|
#wizardEl = null;
|
|
|
|
/**
|
|
* General event handler function for events dispatched from the
|
|
* <migration-wizard> component.
|
|
*
|
|
* @param {Event} event
|
|
* The DOM event being handled.
|
|
* @returns {Promise}
|
|
*/
|
|
async handleEvent(event) {
|
|
if (event.type == "MigrationWizard:Init") {
|
|
this.#wizardEl = event.target;
|
|
let migrators = await this.sendQuery("GetAvailableMigrators");
|
|
this.setComponentState({
|
|
migrators,
|
|
page: MigrationWizard.PAGES.SELECTION,
|
|
});
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Calls the `setState` method on the <migration-wizard> component. The
|
|
* state is cloned into the execution scope of this.#wizardEl.
|
|
*
|
|
* @param {object} state The state object that a <migration-wizard>
|
|
* component expects. See the documentation for the element's setState
|
|
* method for more details.
|
|
*/
|
|
setComponentState(state) {
|
|
if (!this.#wizardEl) {
|
|
return;
|
|
}
|
|
// We waive XrayWrappers in the event that the element is embedded in
|
|
// a document without system privileges, like about:welcome.
|
|
Cu.waiveXrays(this.#wizardEl).setState(
|
|
Cu.cloneInto(
|
|
state,
|
|
// ownerGlobal doesn't exist in content windows.
|
|
// eslint-disable-next-line mozilla/use-ownerGlobal
|
|
this.#wizardEl.ownerDocument.defaultView
|
|
)
|
|
);
|
|
}
|
|
}
|