Bug 1613093 - Fixing Navigation componenet and locale prop. r=Mardak

Differential Revision: https://phabricator.services.mozilla.com/D63511

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Scott 2020-02-20 21:38:53 +00:00
Родитель 7f634ba2c0
Коммит d2b6fe9743
8 изменённых файлов: 17 добавлений и 12 удалений

Просмотреть файл

@ -20,6 +20,7 @@ const INITIAL_STATE = {
App: { App: {
// Have we received real data from the app yet? // Have we received real data from the app yet?
initialized: false, initialized: false,
locale: "",
}, },
ASRouter: { initialized: false }, ASRouter: { initialized: false },
Snippets: { initialized: false }, Snippets: { initialized: false },

Просмотреть файл

@ -21,7 +21,6 @@ ReactDOM.hydrate(
<Provider store={store}> <Provider store={store}>
<Base <Base
isFirstrun={global.document.location.href === "about:welcome"} isFirstrun={global.document.location.href === "about:welcome"}
locale={global.document.documentElement.lang}
strings={global.gActivityStreamStrings} strings={global.gActivityStreamStrings}
/> />
</Provider>, </Provider>,

Просмотреть файл

@ -174,7 +174,7 @@ export class BaseContent extends React.PureComponent {
<div className={`body-wrapper${initialized ? " on" : ""}`}> <div className={`body-wrapper${initialized ? " on" : ""}`}>
{isDiscoveryStream ? ( {isDiscoveryStream ? (
<ErrorBoundary className="borderless-error"> <ErrorBoundary className="borderless-error">
<DiscoveryStreamBase /> <DiscoveryStreamBase locale={props.App.locale} />
</ErrorBoundary> </ErrorBoundary>
) : ( ) : (
<Sections /> <Sections />

Просмотреть файл

@ -304,7 +304,7 @@ export class _DiscoveryStreamBase extends React.PureComponent {
state: this.props.DiscoveryStream, state: this.props.DiscoveryStream,
prefs: this.props.Prefs.values, prefs: this.props.Prefs.values,
rollCache, rollCache,
lang: this.props.document.documentElement.lang, locale: this.props.locale,
}); });
const { config, spocs, feeds } = this.props.DiscoveryStream; const { config, spocs, feeds } = this.props.DiscoveryStream;

Просмотреть файл

@ -6,7 +6,7 @@ export const selectLayoutRender = ({
state = {}, state = {},
prefs = {}, prefs = {},
rollCache = [], rollCache = [],
lang = "", locale = "",
}) => { }) => {
const { layout, feeds, spocs } = state; const { layout, feeds, spocs } = state;
let spocIndexMap = {}; let spocIndexMap = {};
@ -68,7 +68,7 @@ export const selectLayoutRender = ({
filterArray.push("TopSites"); filterArray.push("TopSites");
} }
if (!lang.startsWith("en-")) { if (!locale.startsWith("en-")) {
filterArray.push("Navigation"); filterArray.push("Navigation");
} }

Просмотреть файл

@ -122,7 +122,6 @@ react_dom__WEBPACK_IMPORTED_MODULE_6___default.a.hydrate(react__WEBPACK_IMPORTED
store: store store: store
}, react__WEBPACK_IMPORTED_MODULE_5___default.a.createElement(content_src_components_Base_Base__WEBPACK_IMPORTED_MODULE_1__["Base"], { }, react__WEBPACK_IMPORTED_MODULE_5___default.a.createElement(content_src_components_Base_Base__WEBPACK_IMPORTED_MODULE_1__["Base"], {
isFirstrun: global.document.location.href === "about:welcome", isFirstrun: global.document.location.href === "about:welcome",
locale: global.document.documentElement.lang,
strings: global.gActivityStreamStrings strings: global.gActivityStreamStrings
})), document.getElementById("root")); })), document.getElementById("root"));
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(1))) /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(1)))
@ -727,7 +726,9 @@ class BaseContent extends react__WEBPACK_IMPORTED_MODULE_7___default.a.PureCompo
className: `body-wrapper${initialized ? " on" : ""}` className: `body-wrapper${initialized ? " on" : ""}`
}, isDiscoveryStream ? react__WEBPACK_IMPORTED_MODULE_7___default.a.createElement(content_src_components_ErrorBoundary_ErrorBoundary__WEBPACK_IMPORTED_MODULE_6__["ErrorBoundary"], { }, isDiscoveryStream ? react__WEBPACK_IMPORTED_MODULE_7___default.a.createElement(content_src_components_ErrorBoundary_ErrorBoundary__WEBPACK_IMPORTED_MODULE_6__["ErrorBoundary"], {
className: "borderless-error" className: "borderless-error"
}, react__WEBPACK_IMPORTED_MODULE_7___default.a.createElement(content_src_components_DiscoveryStreamBase_DiscoveryStreamBase__WEBPACK_IMPORTED_MODULE_5__["DiscoveryStreamBase"], null)) : react__WEBPACK_IMPORTED_MODULE_7___default.a.createElement(content_src_components_Sections_Sections__WEBPACK_IMPORTED_MODULE_9__["Sections"], null), react__WEBPACK_IMPORTED_MODULE_7___default.a.createElement(PrefsButton, { }, react__WEBPACK_IMPORTED_MODULE_7___default.a.createElement(content_src_components_DiscoveryStreamBase_DiscoveryStreamBase__WEBPACK_IMPORTED_MODULE_5__["DiscoveryStreamBase"], {
locale: props.App.locale
})) : react__WEBPACK_IMPORTED_MODULE_7___default.a.createElement(content_src_components_Sections_Sections__WEBPACK_IMPORTED_MODULE_9__["Sections"], null), react__WEBPACK_IMPORTED_MODULE_7___default.a.createElement(PrefsButton, {
onClick: this.openPreferences onClick: this.openPreferences
})), react__WEBPACK_IMPORTED_MODULE_7___default.a.createElement(content_src_components_ConfirmDialog_ConfirmDialog__WEBPACK_IMPORTED_MODULE_3__["ConfirmDialog"], null)))); })), react__WEBPACK_IMPORTED_MODULE_7___default.a.createElement(content_src_components_ConfirmDialog_ConfirmDialog__WEBPACK_IMPORTED_MODULE_3__["ConfirmDialog"], null))));
} }
@ -4383,7 +4384,7 @@ class _DiscoveryStreamBase extends react__WEBPACK_IMPORTED_MODULE_14___default.a
state: this.props.DiscoveryStream, state: this.props.DiscoveryStream,
prefs: this.props.Prefs.values, prefs: this.props.Prefs.values,
rollCache, rollCache,
lang: this.props.document.documentElement.lang locale: this.props.locale
}); });
const { const {
config, config,
@ -10235,7 +10236,7 @@ const selectLayoutRender = ({
state = {}, state = {},
prefs = {}, prefs = {},
rollCache = [], rollCache = [],
lang = "" locale = ""
}) => { }) => {
const { const {
layout, layout,
@ -10296,7 +10297,7 @@ const selectLayoutRender = ({
filterArray.push("TopSites"); filterArray.push("TopSites");
} }
if (!lang.startsWith("en-")) { if (!locale.startsWith("en-")) {
filterArray.push("Navigation"); filterArray.push("Navigation");
} }
@ -14359,7 +14360,8 @@ const dedupe = new Dedupe(site => site && site.url);
const INITIAL_STATE = { const INITIAL_STATE = {
App: { App: {
// Have we received real data from the app yet? // Have we received real data from the app yet?
initialized: false initialized: false,
locale: ""
}, },
ASRouter: { ASRouter: {
initialized: false initialized: false

Просмотреть файл

@ -692,7 +692,9 @@ this.ActivityStream = class ActivityStream {
this.feeds, this.feeds,
ac.BroadcastToContent({ ac.BroadcastToContent({
type: at.INIT, type: at.INIT,
data: {}, data: {
locale: this.locale,
},
}), }),
{ type: at.UNINIT } { type: at.UNINIT }
); );

Просмотреть файл

@ -102,6 +102,7 @@ describe("<DiscoveryStreamBase>", () => {
}; };
return shallow( return shallow(
<DiscoveryStreamBase <DiscoveryStreamBase
locale="en-US"
DiscoveryStream={defaultProps} DiscoveryStream={defaultProps}
Prefs={{ Prefs={{
values: { values: {