Skip to content

Commit

Permalink
Bug 1819334 - Display an error message when no importable resources c…
Browse files Browse the repository at this point in the history
…an be found for a browser / profile pair. r=mconley,fluent-reviewers.

Differential Revision: https://phabricator.services.mozilla.com/D173544
  • Loading branch information
Steven100695 committed Mar 31, 2023
1 parent 98a276c commit 901ad85
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 4 deletions.
16 changes: 13 additions & 3 deletions browser/components/migration/content/migration-wizard.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ export class MigrationWizard extends HTMLElement {
</div>
<span class="dropdown-icon"></span>
</button>
<div data-l10n-id="migration-wizard-selection-list" class="resource-selection-preamble deemphasized-text"></div>
<details class="resource-selection-details">
<div class="no-resources-found error-message">
<span class="error-icon" role="img"></span>
<div data-l10n-id="migration-wizard-import-browser-no-resources"></div>
</div>
<div data-l10n-id="migration-wizard-selection-list" class="resource-selection-preamble deemphasized-text hide-on-error"></div>
<details class="resource-selection-details hide-on-error">
<summary>
<div class="selected-data-header" data-l10n-id="migration-all-available-data-label"></div>
<div class="selected-data deemphasized-text">&nbsp;</div>
Expand Down Expand Up @@ -150,7 +154,7 @@ export class MigrationWizard extends HTMLElement {
<div name="page-no-browsers-found">
<h1 data-l10n-id="migration-wizard-selection-header"></h1>
<div class="no-browsers-found">
<div class="no-browsers-found error-message">
<span class="error-icon" role="img"></span>
<div class="no-browsers-found-message" data-l10n-id="migration-wizard-import-browser-no-browsers"></div>
</div>
Expand Down Expand Up @@ -360,6 +364,12 @@ export class MigrationWizard extends HTMLElement {
let selectAll = this.#shadowRoot.querySelector("#select-all").control;
selectAll.checked = true;
this.#displaySelectedResources();
this.#browserProfileSelector.selectedPanelItem = panelItem;

let selectionPage = this.#shadowRoot.querySelector(
"div[name='page-selection']"
);
selectionPage.toggleAttribute("no-resources", !resourceTypes.length);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,32 @@
ok(!isHidden(details), "Details should be shown.");
});

/**
* Tests the migration wizard with no resources
*/
add_task(async function test_no_resources() {
gWiz.setState({
page: MigrationWizardConstants.PAGES.SELECTION,
migrators: [{
key: "some-browser-0",
displayName: "Some Browser 0 with no resources",
resourceTypes: [],
profile: { id: "person-1", name: "Person 1" },
}],
showImportAll: false,
});

let noResourcesFound = gShadowRoot.querySelector(".no-resources-found");
let hideOnErrorEls = gShadowRoot.querySelectorAll(".hide-on-error");
ok(
!isHidden(noResourcesFound),
"Error message of no reasources should be shown."
);
for (let hideOnErrorEl of hideOnErrorEls) {
ok(isHidden(hideOnErrorEl), "Item should be hidden.");
}
});

/**
* Tests variant 2 of the migration wizard
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ const FAKE_BROWSER_LIST = [
profile: { id: "Default", name: "Default" },
brandImage: "chrome://browser/content/migration/brands/vivaldi.png",
},
{
key: "no-resources-browser",
displayName: "Browser with no resources",
resourceTypes: [],
profile: { id: "Default", name: "Default" },
},
];

const Template = ({ state, dialogMode }) => html`
Expand Down
1 change: 1 addition & 0 deletions browser/locales-preview/migrationWizard.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ migration-cancel-button-label = Cancel
migration-done-button-label = Done
migration-wizard-import-browser-no-browsers = { -brand-short-name } couldn’t find any programs that contain bookmark, history or password data.
migration-wizard-import-browser-no-resources = There was an error. { -brand-short-name } can’t find any data to import from that browser profile.
## These strings will be used to create a dynamic list of items that can be
## imported. The list will be created using Intl.ListFormat(), so it will
Expand Down
12 changes: 11 additions & 1 deletion browser/themes/shared/migration/migration-wizard.css
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,21 @@ details:not([open]) summary {
display: flex;
}

.no-browsers-found {
.error-message {
display: flex;
align-items: start;
}

.no-resources-found {
font-size: 0.84em;
margin-block-start: 16px;
}

div[name="page-selection"]:not([no-resources]) .no-resources-found,
div[name="page-selection"][no-resources] .hide-on-error {
display: none;
}

/**
* Workaround for bug 1671784, which shows a slight outline around the
* rotating masked element.
Expand Down

0 comments on commit 901ad85

Please sign in to comment.