Skip to content

Commit

Permalink
Backed out changeset 7ebfd2e7a63a (bug 1840139) for causing failures …
Browse files Browse the repository at this point in the history
…in browser_unanalyzed_product.js CLOSED TREE
  • Loading branch information
nerli1 committed Aug 1, 2023
1 parent 6b8bda2 commit cc43184
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 38 deletions.
1 change: 0 additions & 1 deletion browser/components/shopping/ShoppingSidebarChild.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ export class ShoppingSidebarChild extends RemotePageChild {
this.#product = new ShoppingProduct(uri);
let data = await this.#product.requestAnalysis().catch(err => {
console.error("Failed to fetch product analysis data", err);
return { error: err };
});
// Check if the product URI or opt in changed while we waited.
if (uri != this.#productURI || !this.canFetchAndShowData) {
Expand Down
28 changes: 11 additions & 17 deletions browser/components/shopping/content/shopping-container.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -87,25 +87,19 @@ export class ShoppingContainer extends MozLitElement {
}

getContentTemplate() {
return html`${this.warningCardTemplate()}${this.getAnalysisDetailsTemplate()}`;
}

warningCardTemplate() {
if (this.data.needs_analysis && this.data.product_id) {
return html`<shopping-message-bar type="stale"></shopping-message-bar>`;
} else if (!this.data.product_id) {
return html`<unanalyzed-product-card
productUrl=${ifDefined(this.productUrl)}
></unanalyzed-product-card>`;
}

if (this.data?.error) {
return html`<shopping-message-bar
type="generic-error"
></shopping-message-bar>`;
if (this.data.needs_analysis) {
if (!this.data.product_id) {
return html`<unanalyzed-product-card
productUrl=${ifDefined(this.productUrl)}
></unanalyzed-product-card>`;
}
return html`
<shopping-message-bar type="stale"></shopping-message-bar>
${this.getAnalysisDetailsTemplate()}
`;
}

return null;
return this.getAnalysisDetailsTemplate();
}

renderContainer(sidebarContent) {
Expand Down
15 changes: 1 addition & 14 deletions browser/components/shopping/content/shopping-message-bar.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { MozLitElement } from "chrome://global/content/lit-utils.mjs";
class ShoppingMessageBar extends MozLitElement {
#MESSAGE_TYPES_RENDER_TEMPLATE_MAPPING = new Map([
["stale", this.getStaleWarningTemplate()],
["generic-error", this.getGenericErrorTemplate()],
]);

static properties = {
Expand All @@ -36,18 +35,6 @@ class ShoppingMessageBar extends MozLitElement {
</message-bar>`;
}

getGenericErrorTemplate() {
return html` <message-bar type="error">
<article id="message-bar-container" aria-labelledby="header">
<strong
id="header"
data-l10n-id="shopping-message-bar-generic-error-title"
></strong>
<span data-l10n-id="shopping-message-bar-generic-error-message"></span>
</article>
</message-bar>`;
}

render() {
let messageBarTemplate = this.#MESSAGE_TYPES_RENDER_TEMPLATE_MAPPING.get(
this.type
Expand All @@ -64,7 +51,7 @@ class ShoppingMessageBar extends MozLitElement {
return null;
}

updated() {
firstUpdated() {
// message-bar does not support adding a header and does not align it with the icon.
// Override styling to make them align.
let messageBar = this.renderRoot.querySelector("message-bar");
Expand Down
3 changes: 0 additions & 3 deletions browser/components/shopping/content/shopping.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ shopping-message-bar-warning-stale-analysis-title = Updates available
shopping-message-bar-warning-stale-analysis-message = Re-analyze the reviews for this product, so you have the latest info.
shopping-message-bar-warning-stale-analysis-link = Re-analyze reviews
shopping-message-bar-generic-error-title = Something went wrong
shopping-message-bar-generic-error-message = Couldn’t load information. Please try again later.
## Strings for the product review snippets card

shopping-highlights-label =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default {
type: {
control: {
type: "select",
options: ["stale", "generic-error"],
options: ["stale"],
},
},
},
Expand All @@ -24,8 +24,6 @@ export default {
shopping-message-bar-warning-stale-analysis-title = Updates available
shopping-message-bar-warning-stale-analysis-message = Re-analyze the reviews for this product, so you have the latest info.
shopping-message-bar-warning-stale-analysis-link = Re-analyze reviews
shopping-message-bar-generic-error-title = Something went wrong
shopping-message-bar-generic-error-message = Couldn't load information. Please try again later.
`,
},
};
Expand Down

0 comments on commit cc43184

Please sign in to comment.