@zengenti/contensis-react-base 4.0.0-beta.37 → 4.0.0-beta.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/{App-C8XjopaN.js → App-DIks7cRe.js} +238 -228
- package/cjs/App-DIks7cRe.js.map +1 -0
- package/cjs/{ContensisDeliveryApi-StchaSC-.js → ContensisDeliveryApi-DVWMsCyk.js} +2 -2
- package/cjs/{ContensisDeliveryApi-StchaSC-.js.map → ContensisDeliveryApi-DVWMsCyk.js.map} +1 -1
- package/cjs/{RouteLoader-C3b4eo2z.js → RouteLoader-DtJz9Sss.js} +2 -2
- package/cjs/{RouteLoader-C3b4eo2z.js.map → RouteLoader-DtJz9Sss.js.map} +1 -1
- package/cjs/{SSRContext-Op85CUQt.js → SSRContext-BjS2_F0M.js} +2 -2
- package/cjs/{SSRContext-Op85CUQt.js.map → SSRContext-BjS2_F0M.js.map} +1 -1
- package/cjs/client.js +18 -22
- package/cjs/client.js.map +1 -1
- package/cjs/contensis-react-base.js +10 -14
- package/cjs/contensis-react-base.js.map +1 -1
- package/cjs/i18n.js +57 -1
- package/cjs/i18n.js.map +1 -1
- package/cjs/redux.js +3 -3
- package/cjs/routing.js +6 -6
- package/cjs/{sagas-BLyC5pxW.js → sagas-gLdoj-sa.js} +4 -4
- package/cjs/{sagas-BLyC5pxW.js.map → sagas-gLdoj-sa.js.map} +1 -1
- package/cjs/search.js +5 -5
- package/cjs/{slice-DzItS3J5.js → slice-Q_VcvbKA.js} +16 -18
- package/cjs/slice-Q_VcvbKA.js.map +1 -0
- package/cjs/{store-Thi-k3pU.js → store-C2CTORM5.js} +2 -2
- package/cjs/{store-Thi-k3pU.js.map → store-C2CTORM5.js.map} +1 -1
- package/cjs/{util-D65Zmo5R.js → util-O9_pi6m4.js} +2 -2
- package/cjs/{util-D65Zmo5R.js.map → util-O9_pi6m4.js.map} +1 -1
- package/cjs/util.js +4 -4
- package/cjs/{version-oqn7qotZ.js → version-D5a_ApvZ.js} +2 -2
- package/cjs/{version-oqn7qotZ.js.map → version-D5a_ApvZ.js.map} +1 -1
- package/esm/{App-D8L4sT6e.js → App-BENe9naB.js} +201 -191
- package/esm/App-BENe9naB.js.map +1 -0
- package/esm/{ChangePassword.container-BS_ruqX8.js → ChangePassword.container-giznBLAf.js} +3 -3
- package/esm/{ChangePassword.container-BS_ruqX8.js.map → ChangePassword.container-giznBLAf.js.map} +1 -1
- package/esm/{ContensisDeliveryApi-DHZ52vNg.js → ContensisDeliveryApi-oy2cByTy.js} +3 -3
- package/esm/{ContensisDeliveryApi-DHZ52vNg.js.map → ContensisDeliveryApi-oy2cByTy.js.map} +1 -1
- package/esm/{RouteLoader-D4a8D5FU.js → RouteLoader-3vl5WOjR.js} +4 -4
- package/esm/{RouteLoader-D4a8D5FU.js.map → RouteLoader-3vl5WOjR.js.map} +1 -1
- package/esm/{SSRContext-CXYTpsVV.js → SSRContext-BI9VbHMQ.js} +2 -2
- package/esm/{SSRContext-CXYTpsVV.js.map → SSRContext-BI9VbHMQ.js.map} +1 -1
- package/esm/{VersionInfo-fBaJIe2X.js → VersionInfo-BMAAda1K.js} +3 -3
- package/esm/{VersionInfo-fBaJIe2X.js.map → VersionInfo-BMAAda1K.js.map} +1 -1
- package/esm/client.js +22 -26
- package/esm/client.js.map +1 -1
- package/esm/contensis-react-base.js +17 -21
- package/esm/contensis-react-base.js.map +1 -1
- package/esm/i18n.js +62 -2
- package/esm/i18n.js.map +1 -1
- package/esm/{matchGroups-BkB1ERVS.js → matchGroups-DT-RunAc.js} +2 -2
- package/esm/{matchGroups-BkB1ERVS.js.map → matchGroups-DT-RunAc.js.map} +1 -1
- package/esm/redux.js +8 -8
- package/esm/routing.js +8 -8
- package/esm/{sagas-AyubwCW8.js → sagas-C-yDQMGy.js} +7 -7
- package/esm/{sagas-AyubwCW8.js.map → sagas-C-yDQMGy.js.map} +1 -1
- package/esm/search.js +10 -10
- package/esm/{selectors-lvyF1LmZ.js → selectors-DcmvOeX2.js} +2 -2
- package/esm/{selectors-lvyF1LmZ.js.map → selectors-DcmvOeX2.js.map} +1 -1
- package/esm/{selectors-C2gX5tLA.js → selectors-PJo8AWy0.js} +2 -2
- package/esm/{selectors-C2gX5tLA.js.map → selectors-PJo8AWy0.js.map} +1 -1
- package/esm/{slice-BO-KB30v.js → slice-TYc5KMRz.js} +16 -19
- package/esm/slice-TYc5KMRz.js.map +1 -0
- package/esm/{store-KUjdLK3-.js → store-B-i8GHBX.js} +3 -3
- package/esm/{store-KUjdLK3-.js.map → store-B-i8GHBX.js.map} +1 -1
- package/esm/user.js +5 -5
- package/esm/{util-CnXqe4uK.js → util-C59CejNT.js} +2 -2
- package/esm/{util-CnXqe4uK.js.map → util-C59CejNT.js.map} +1 -1
- package/esm/util.js +7 -7
- package/esm/{version-CsMa2_lY.js → version-DlaBPQ7d.js} +2 -2
- package/esm/{version-CsMa2_lY.js.map → version-DlaBPQ7d.js.map} +1 -1
- package/esm/{version-Cin2m8K5.js → version-ffmUWUXX.js} +3 -3
- package/esm/{version-Cin2m8K5.js.map → version-ffmUWUXX.js.map} +1 -1
- package/i18n/package.json +5 -0
- package/models/i18n/index.d.ts +1 -0
- package/models/i18n/redux/sagas.d.ts +13 -0
- package/models/i18n/redux/slice.d.ts +5 -28
- package/models/i18n/useI18n.hook.d.ts +20 -0
- package/package.json +1 -1
- package/cjs/App-C8XjopaN.js.map +0 -1
- package/cjs/slice-DzItS3J5.js.map +0 -1
- package/esm/App-D8L4sT6e.js.map +0 -1
- package/esm/slice-BO-KB30v.js.map +0 -1
|
@@ -3,31 +3,31 @@
|
|
|
3
3
|
var history$1 = require('history');
|
|
4
4
|
var effects = require('@redux-saga/core/effects');
|
|
5
5
|
var log = require('loglevel');
|
|
6
|
-
var store = require('./store-
|
|
7
|
-
var version = require('./version-
|
|
6
|
+
var store = require('./store-C2CTORM5.js');
|
|
7
|
+
var version = require('./version-D5a_ApvZ.js');
|
|
8
8
|
var to = require('await-to-js');
|
|
9
|
-
var
|
|
9
|
+
var contensisDeliveryApi = require('contensis-delivery-api');
|
|
10
|
+
var slice = require('./slice-Q_VcvbKA.js');
|
|
11
|
+
var selectors$1 = require('./selectors-C1CqEUmL.js');
|
|
10
12
|
var version$1 = require('./version-CukCz8zL.js');
|
|
11
|
-
var
|
|
13
|
+
var ContensisDeliveryApi = require('./ContensisDeliveryApi-DVWMsCyk.js');
|
|
12
14
|
var React = require('react');
|
|
13
15
|
require('react-cookie');
|
|
14
16
|
require('react-redux');
|
|
17
|
+
require('./VersionInfo-CTPtw_Xd.js');
|
|
15
18
|
require('jsonpath-mapper');
|
|
16
|
-
|
|
17
|
-
var
|
|
18
|
-
require('./
|
|
19
|
+
require('react-router-dom');
|
|
20
|
+
var selectors = require('./selectors-DAQR0uZa.js');
|
|
21
|
+
var ChangePassword_container = require('./ChangePassword.container-BWh4R32r.js');
|
|
22
|
+
require('./sagas-gLdoj-sa.js');
|
|
19
23
|
require('reselect');
|
|
20
24
|
require('immer');
|
|
21
25
|
require('deep-equal');
|
|
22
26
|
require('deepmerge');
|
|
23
|
-
var util = require('./util-
|
|
27
|
+
var util = require('./util-O9_pi6m4.js');
|
|
24
28
|
require('contensis-core-api');
|
|
25
29
|
var matchGroups = require('./matchGroups-CxRa9Ej9.js');
|
|
26
|
-
var
|
|
27
|
-
require('./VersionInfo-CTPtw_Xd.js');
|
|
28
|
-
require('react-router-dom');
|
|
29
|
-
var selectors$1 = require('./selectors-DAQR0uZa.js');
|
|
30
|
-
var RouteLoader = require('./RouteLoader-C3b4eo2z.js');
|
|
30
|
+
var RouteLoader = require('./RouteLoader-DtJz9Sss.js');
|
|
31
31
|
require('query-string');
|
|
32
32
|
|
|
33
33
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -134,6 +134,180 @@ function* ensureNodeTreeSaga(action) {
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
const i18nSagas = [effects.takeEvery(slice.actions.INIT_LOCALES.type, getProjectLanguages), effects.takeEvery(slice.actions.UPDATE_LANGUAGE.type, updateLanguage)];
|
|
138
|
+
function* resolveCurrentRouteLanguage({
|
|
139
|
+
entry,
|
|
140
|
+
node
|
|
141
|
+
}) {
|
|
142
|
+
var _entry$sys, _staticRoute$route;
|
|
143
|
+
const currentLanguage = yield effects.select(selectors.selectCurrentLanguage);
|
|
144
|
+
const staticRoute = yield effects.select(selectors$1.selectStaticRoute);
|
|
145
|
+
let nextLanguage = currentLanguage;
|
|
146
|
+
if (entry !== null && entry !== void 0 && (_entry$sys = entry.sys) !== null && _entry$sys !== void 0 && _entry$sys.language) nextLanguage = entry.sys.language;else if (node !== null && node !== void 0 && node.language) nextLanguage = node.language;else if (staticRoute !== null && staticRoute !== void 0 && (_staticRoute$route = staticRoute.route) !== null && _staticRoute$route !== void 0 && _staticRoute$route.language) nextLanguage = staticRoute.route.language;else nextLanguage = yield effects.select(selectors.selectPrimaryLanguage);
|
|
147
|
+
if (nextLanguage && nextLanguage !== currentLanguage) {
|
|
148
|
+
const dictionary = yield effects.call(resolveDictionaryForLanguage, nextLanguage);
|
|
149
|
+
yield effects.put(slice.actions.SET_LANGUAGE({
|
|
150
|
+
language: nextLanguage,
|
|
151
|
+
dictionary
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function* resolveDictionaryForLanguage(language) {
|
|
156
|
+
let dictionary = yield effects.select(selectors.selectDictionary);
|
|
157
|
+
// try and resolve a dictionary for this language
|
|
158
|
+
const resolver = yield effects.select(selectors.selectDictionaryResolver);
|
|
159
|
+
if (typeof resolver === 'function') {
|
|
160
|
+
try {
|
|
161
|
+
// dynamic import of dictionary file
|
|
162
|
+
const loadedDictionary = yield effects.call(resolver, language);
|
|
163
|
+
dictionary = loadedDictionary;
|
|
164
|
+
} catch (error) {
|
|
165
|
+
console.error(`No dictionary resolved for language ${language}`, error);
|
|
166
|
+
}
|
|
167
|
+
} else {
|
|
168
|
+
// Load dictionary from locales in state
|
|
169
|
+
const locales = yield effects.select(selectors.selectLocales);
|
|
170
|
+
if (locales && locales[language]) {
|
|
171
|
+
dictionary = locales[language];
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return dictionary;
|
|
175
|
+
}
|
|
176
|
+
function* updateLanguage({
|
|
177
|
+
payload: {
|
|
178
|
+
language,
|
|
179
|
+
redirect,
|
|
180
|
+
fallbackPath
|
|
181
|
+
}
|
|
182
|
+
}) {
|
|
183
|
+
const currentLanguage = yield effects.select(selectors.selectCurrentLanguage);
|
|
184
|
+
if (language === currentLanguage) {
|
|
185
|
+
// no change needed
|
|
186
|
+
return;
|
|
187
|
+
} else {
|
|
188
|
+
const dictionary = language !== currentLanguage ? yield effects.call(resolveDictionaryForLanguage, language) : yield effects.select(selectors.selectDictionary);
|
|
189
|
+
const uri = yield effects.call(navigateToLanguageRoute, {
|
|
190
|
+
language,
|
|
191
|
+
redirect,
|
|
192
|
+
fallbackPath
|
|
193
|
+
});
|
|
194
|
+
const currentPath = yield effects.select(selectors$1.selectCurrentPath);
|
|
195
|
+
if (uri === currentPath || redirect === false) {
|
|
196
|
+
// already on the correct path, no need to redirect
|
|
197
|
+
if (dictionary) yield effects.put(slice.actions.SET_LANGUAGE({
|
|
198
|
+
language,
|
|
199
|
+
dictionary
|
|
200
|
+
}));
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
yield effects.put(selectors$1.setRoute(uri));
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
function* navigateToLanguageRoute({
|
|
207
|
+
language,
|
|
208
|
+
redirect,
|
|
209
|
+
fallbackPath
|
|
210
|
+
}) {
|
|
211
|
+
// have they supplied the route to go to?
|
|
212
|
+
if (typeof redirect === 'string') {
|
|
213
|
+
return redirect;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// is this an entry or a static route?
|
|
217
|
+
const availableLanguages = yield effects.select(selectors$1.selectRouteEntryAvailableLanguages);
|
|
218
|
+
if (availableLanguages.find(l => l.toLowerCase() === language.toLowerCase())) {
|
|
219
|
+
// if entry, get the uri for this language variation from the api
|
|
220
|
+
const entryUri = yield effects.call(getEntryUriForLanguage, {
|
|
221
|
+
entryId: yield effects.select(selectors$1.selectRouteEntryID),
|
|
222
|
+
language
|
|
223
|
+
});
|
|
224
|
+
if (entryUri) {
|
|
225
|
+
return entryUri;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// if static route, get the uri from the routes config
|
|
230
|
+
const staticRouteUri = yield effects.call(getStaticRouteUri, {
|
|
231
|
+
language
|
|
232
|
+
});
|
|
233
|
+
if (staticRouteUri) {
|
|
234
|
+
return staticRouteUri;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// if all else fails, fallback to the supplied fallback path or homepage
|
|
238
|
+
return fallbackPath || `/${language.toLowerCase()}`;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** Check any current static route for a language variation we have stored in i18n.routes */
|
|
242
|
+
function* getStaticRouteUri({
|
|
243
|
+
language
|
|
244
|
+
}) {
|
|
245
|
+
const staticRoute = yield effects.select(selectors$1.selectStaticRoute);
|
|
246
|
+
if (staticRoute !== null && staticRoute !== void 0 && staticRoute.route.path) {
|
|
247
|
+
var _Object$entries$find;
|
|
248
|
+
// Routes can have parameters such as `/:facet?` we need to deparameterise
|
|
249
|
+
// so we can check against our stored locale routes
|
|
250
|
+
const deparameterisedPath = deparameterise(staticRoute.route.path);
|
|
251
|
+
const localeRoutes = yield effects.select(selectors.selectLocaleRoutes);
|
|
252
|
+
const originalPath = (_Object$entries$find = Object.entries(localeRoutes || {}).find(([, locales]) => Object.values(locales).includes(deparameterisedPath))) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0];
|
|
253
|
+
const routeLocales = localeRoutes[deparameterisedPath] || localeRoutes[originalPath || ''];
|
|
254
|
+
const routeUri = routeLocales === null || routeLocales === void 0 ? void 0 : routeLocales[language];
|
|
255
|
+
return routeUri;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
function* getProjectLanguages({
|
|
259
|
+
payload
|
|
260
|
+
}) {
|
|
261
|
+
const stateLocales = yield effects.select(selectors.selectLocales);
|
|
262
|
+
if (stateLocales && Object.keys(stateLocales).length > 0)
|
|
263
|
+
// Locales already set in state, no need to fetch again
|
|
264
|
+
return;
|
|
265
|
+
const locales = {};
|
|
266
|
+
const supportedLanguages = payload.supportedLanguages || [];
|
|
267
|
+
if (supportedLanguages !== null && supportedLanguages !== void 0 && supportedLanguages.length) {
|
|
268
|
+
// If supported languages are provided in config, use these
|
|
269
|
+
for (const supportedLanguage of supportedLanguages) {
|
|
270
|
+
locales[supportedLanguage] = {};
|
|
271
|
+
}
|
|
272
|
+
} else {
|
|
273
|
+
// Fallback to getting languages from the project
|
|
274
|
+
const project = yield ContensisDeliveryApi.cachedSearch.getClient().project.get();
|
|
275
|
+
for (const supportedLanguage of project.supportedLanguages) {
|
|
276
|
+
locales[supportedLanguage] = {};
|
|
277
|
+
supportedLanguages.push(supportedLanguage);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (Object.keys(locales).length === 0) {
|
|
281
|
+
// Ensure at least the primary language is included
|
|
282
|
+
locales[payload.primaryLanguage] = {};
|
|
283
|
+
supportedLanguages.push(payload.primaryLanguage);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// Only commit if we have locales to set or we will end up in an infinite loop
|
|
287
|
+
if (Object.keys(locales).length) yield effects.put(slice.actions.SET_LOCALES({
|
|
288
|
+
...payload,
|
|
289
|
+
locales
|
|
290
|
+
}));
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/** Run a Delivery API query to get all language variations for this entryId */
|
|
294
|
+
function* getEntryUriForLanguage({
|
|
295
|
+
entryId,
|
|
296
|
+
language
|
|
297
|
+
}) {
|
|
298
|
+
try {
|
|
299
|
+
const versionStatus = yield effects.select(version$1.selectVersionStatus);
|
|
300
|
+
const query = new contensisDeliveryApi.Query(contensisDeliveryApi.Op.equalTo('sys.id', entryId), contensisDeliveryApi.Op.equalTo('sys.language', language), contensisDeliveryApi.Op.equalTo('sys.versionStatus', versionStatus));
|
|
301
|
+
query.fields = ['sys.uri'];
|
|
302
|
+
query.pageSize = 1;
|
|
303
|
+
const result = yield ContensisDeliveryApi.cachedSearch.search(query);
|
|
304
|
+
return result.items.length ? result.items[0].sys.uri : null;
|
|
305
|
+
} catch (error) {
|
|
306
|
+
console.error('Error fetching language variations:', error);
|
|
307
|
+
yield effects.put(slice.actions.GET_ENTRY_URI_ERROR(error));
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
137
311
|
const sys = {
|
|
138
312
|
versionStatus: 'sys.versionStatus'
|
|
139
313
|
};
|
|
@@ -236,7 +410,7 @@ function* handleSearchSaga({
|
|
|
236
410
|
}
|
|
237
411
|
}
|
|
238
412
|
|
|
239
|
-
const routingSagas = [effects.takeEvery(selectors.SET_NAVIGATION_PATH, getRouteSaga), effects.takeEvery(selectors.SET_ROUTE, setRouteSaga)];
|
|
413
|
+
const routingSagas = [effects.takeEvery(selectors$1.SET_NAVIGATION_PATH, getRouteSaga), effects.takeEvery(selectors$1.SET_ROUTE, setRouteSaga)];
|
|
240
414
|
|
|
241
415
|
/**
|
|
242
416
|
* To navigate / push a specific route via redux middleware
|
|
@@ -254,7 +428,7 @@ function* setRouteSaga(action) {
|
|
|
254
428
|
function* getRouteSaga(action) {
|
|
255
429
|
let entry = null;
|
|
256
430
|
try {
|
|
257
|
-
var _staticRoute$route, _staticRoute$route2, _staticRoute$route3, _staticRoute$route4, _appsays, _appsays2, _appsays3, _pathNode3, _pathNode4;
|
|
431
|
+
var _staticRoute$route, _staticRoute$route2, _staticRoute$route3, _staticRoute$route4, _appsays, _appsays2, _appsays3, _pathNode3, _pathNode4, _pathNode5;
|
|
258
432
|
const {
|
|
259
433
|
withEvents,
|
|
260
434
|
routes: {
|
|
@@ -299,11 +473,11 @@ function* getRouteSaga(action) {
|
|
|
299
473
|
const setStaticRouteLimits = typeof linkDepth !== 'undefined' || fields || fieldLinkDepths;
|
|
300
474
|
const setContentTypeLimits = !!ContentTypeMappings.find(ct => ct.fields || ct.linkDepth || ct.nodeOptions || ct.fieldLinkDepths);
|
|
301
475
|
const state = yield effects.select();
|
|
302
|
-
const routeEntry = selectors.selectRouteEntry(state, 'js');
|
|
303
|
-
const routeNode = selectors.selectCurrentNode(state, 'js');
|
|
476
|
+
const routeEntry = selectors$1.selectRouteEntry(state, 'js');
|
|
477
|
+
const routeNode = selectors$1.selectCurrentNode(state, 'js');
|
|
304
478
|
const currentPath = action.path; //selectCurrentPath(state);
|
|
305
479
|
const deliveryApiStatus = version$1.selectVersionStatus(state);
|
|
306
|
-
const project = selectors.selectCurrentProject(state);
|
|
480
|
+
const project = selectors$1.selectCurrentProject(state);
|
|
307
481
|
// const isHome = currentPath === '/';
|
|
308
482
|
const isPreview = currentPath && currentPath.startsWith('/preview/');
|
|
309
483
|
const defaultLang = appsays && appsays.defaultLang || 'en-GB';
|
|
@@ -320,10 +494,10 @@ function* getRouteSaga(action) {
|
|
|
320
494
|
};
|
|
321
495
|
pathNode.entry = entry = routeEntry;
|
|
322
496
|
yield effects.put({
|
|
323
|
-
type: selectors.UPDATE_LOADING_STATE,
|
|
497
|
+
type: selectors$1.UPDATE_LOADING_STATE,
|
|
324
498
|
isLoading: false
|
|
325
499
|
});
|
|
326
|
-
} else yield effects.call(setRouteEntry, currentPath, routeEntry, yield effects.select(selectors.selectCurrentNode), yield effects.select(selectors.selectCurrentAncestors), yield effects.select(selectors.selectCurrentSiblings));
|
|
500
|
+
} else yield effects.call(setRouteEntry, currentPath, routeEntry, yield effects.select(selectors$1.selectCurrentNode), yield effects.select(selectors$1.selectCurrentAncestors), yield effects.select(selectors$1.selectCurrentSiblings));
|
|
327
501
|
} else {
|
|
328
502
|
var _staticRoute$route6;
|
|
329
503
|
// Handle preview routes
|
|
@@ -439,7 +613,15 @@ function* getRouteSaga(action) {
|
|
|
439
613
|
});
|
|
440
614
|
if (children) pathNode.children = children;
|
|
441
615
|
}
|
|
442
|
-
|
|
616
|
+
|
|
617
|
+
// We initially listened for SET_ENTRY to complete before
|
|
618
|
+
// resolving the current route language, but this meant
|
|
619
|
+
// that the language change was not captured in time for the SSR response
|
|
620
|
+
yield effects.call(resolveCurrentRouteLanguage, {
|
|
621
|
+
entry: (_pathNode3 = pathNode) === null || _pathNode3 === void 0 ? void 0 : _pathNode3.entry,
|
|
622
|
+
node: pathNode
|
|
623
|
+
});
|
|
624
|
+
const contentTypeRoute = ChangePassword_container.findContentTypeMapping(ContentTypeMappings, (_pathNode4 = pathNode) === null || _pathNode4 === void 0 || (_pathNode4 = _pathNode4.entry) === null || _pathNode4 === void 0 || (_pathNode4 = _pathNode4.sys) === null || _pathNode4 === void 0 ? void 0 : _pathNode4.contentTypeId);
|
|
443
625
|
|
|
444
626
|
// Inject redux { key, reducer, saga } provided by ContentTypeMapping
|
|
445
627
|
if (contentTypeRoute !== null && contentTypeRoute !== void 0 && contentTypeRoute.injectRedux) yield effects.call(reduxInjectorSaga, contentTypeRoute.injectRedux);
|
|
@@ -480,7 +662,7 @@ function* getRouteSaga(action) {
|
|
|
480
662
|
// Scroll into View
|
|
481
663
|
if (typeof window !== 'undefined') window.scrollTo(0, 0);
|
|
482
664
|
}
|
|
483
|
-
if ((
|
|
665
|
+
if ((_pathNode5 = pathNode) !== null && _pathNode5 !== void 0 && (_pathNode5 = _pathNode5.entry) !== null && _pathNode5 !== void 0 && (_pathNode5 = _pathNode5.sys) !== null && _pathNode5 !== void 0 && _pathNode5.id) {
|
|
484
666
|
var _appsays4;
|
|
485
667
|
entry = pathNode.entry;
|
|
486
668
|
yield effects.call(setRouteEntry, currentPath, entry, pathNode, ancestors, siblings, entryMapper || (contentTypeRoute === null || contentTypeRoute === void 0 ? void 0 : contentTypeRoute.entryMapper), false, (_appsays4 = appsays) === null || _appsays4 === void 0 ? void 0 : _appsays4.refetchNode);
|
|
@@ -597,16 +779,16 @@ function* setRouteEntry(currentPath, entry, node, ancestors, siblings, entryMapp
|
|
|
597
779
|
// Update a window global to provide the preview toolbar
|
|
598
780
|
// an updated entry id in client-side navigation
|
|
599
781
|
if (typeof window !== 'undefined') window.ContensisEntryId = entrySys.id;
|
|
600
|
-
const currentEntryId = yield effects.select(selectors.selectRouteEntryEntryId);
|
|
601
|
-
const currentEntryLang = yield effects.select(selectors.selectRouteEntryLanguage);
|
|
602
|
-
const mappedEntry = !entryMapper ? null : currentEntryId === entrySys.id && currentEntryLang === entrySys.language && remapEntry === false ? (yield effects.select(selectors.selectMappedEntry, 'js')) || {} : yield mapRouteEntry(entryMapper, {
|
|
782
|
+
const currentEntryId = yield effects.select(selectors$1.selectRouteEntryEntryId);
|
|
783
|
+
const currentEntryLang = yield effects.select(selectors$1.selectRouteEntryLanguage);
|
|
784
|
+
const mappedEntry = !entryMapper ? null : currentEntryId === entrySys.id && currentEntryLang === entrySys.language && remapEntry === false ? (yield effects.select(selectors$1.selectMappedEntry, 'js')) || {} : yield mapRouteEntry(entryMapper, {
|
|
603
785
|
...node,
|
|
604
786
|
entry,
|
|
605
787
|
ancestors,
|
|
606
788
|
siblings
|
|
607
789
|
});
|
|
608
790
|
yield effects.all([effects.put({
|
|
609
|
-
type: selectors.SET_ENTRY,
|
|
791
|
+
type: selectors$1.SET_ENTRY,
|
|
610
792
|
id: entrySys.id,
|
|
611
793
|
currentPath,
|
|
612
794
|
entry,
|
|
@@ -614,10 +796,10 @@ function* setRouteEntry(currentPath, entry, node, ancestors, siblings, entryMapp
|
|
|
614
796
|
node,
|
|
615
797
|
notFound
|
|
616
798
|
}), ancestors && effects.put({
|
|
617
|
-
type: selectors.SET_ANCESTORS,
|
|
799
|
+
type: selectors$1.SET_ANCESTORS,
|
|
618
800
|
ancestors
|
|
619
801
|
}), siblings && effects.put({
|
|
620
|
-
type: selectors.SET_SIBLINGS,
|
|
802
|
+
type: selectors$1.SET_SIBLINGS,
|
|
621
803
|
siblings
|
|
622
804
|
})]);
|
|
623
805
|
}
|
|
@@ -637,14 +819,14 @@ function* mapRouteEntry(entryMapper, node) {
|
|
|
637
819
|
function* do404() {
|
|
638
820
|
yield effects.call(clientReloadHitServer);
|
|
639
821
|
yield effects.put({
|
|
640
|
-
type: selectors.SET_ENTRY,
|
|
822
|
+
type: selectors$1.SET_ENTRY,
|
|
641
823
|
id: null,
|
|
642
824
|
entry: null,
|
|
643
825
|
notFound: true
|
|
644
826
|
});
|
|
645
827
|
}
|
|
646
828
|
function* clientReloadHitServer() {
|
|
647
|
-
const stateEntry = yield effects.select(selectors.selectRouteEntry);
|
|
829
|
+
const stateEntry = yield effects.select(selectors$1.selectRouteEntry);
|
|
648
830
|
|
|
649
831
|
// If in client and there is a stateEntry.sys field reload the page,
|
|
650
832
|
// on the 2nd load stateEntry.sys should be null at this point,
|
|
@@ -655,7 +837,7 @@ function* clientReloadHitServer() {
|
|
|
655
837
|
}
|
|
656
838
|
function* do500(error) {
|
|
657
839
|
yield effects.put({
|
|
658
|
-
type: selectors.SET_ENTRY,
|
|
840
|
+
type: selectors$1.SET_ENTRY,
|
|
659
841
|
id: null,
|
|
660
842
|
entry: null,
|
|
661
843
|
notFound: true,
|
|
@@ -665,7 +847,7 @@ function* do500(error) {
|
|
|
665
847
|
});
|
|
666
848
|
}
|
|
667
849
|
|
|
668
|
-
const registerSagas = [effects.takeEvery(selectors.REGISTER_USER, registerSaga), effects.takeEvery(selectors.REGISTER_USER_SUCCESS, redirectSaga)];
|
|
850
|
+
const registerSagas = [effects.takeEvery(selectors$1.REGISTER_USER, registerSaga), effects.takeEvery(selectors$1.REGISTER_USER_SUCCESS, redirectSaga)];
|
|
669
851
|
function* registerSaga({
|
|
670
852
|
user,
|
|
671
853
|
mappers
|
|
@@ -697,13 +879,13 @@ function* registerSaga({
|
|
|
697
879
|
}
|
|
698
880
|
// Update user object with mappedResponse or responseBody
|
|
699
881
|
yield effects.put({
|
|
700
|
-
type: selectors.REGISTER_USER_SUCCESS,
|
|
882
|
+
type: selectors$1.REGISTER_USER_SUCCESS,
|
|
701
883
|
user: mappedResponse || responseBody
|
|
702
884
|
});
|
|
703
885
|
} else {
|
|
704
886
|
// OK response but unable to parse the response body
|
|
705
887
|
yield effects.put({
|
|
706
|
-
type: selectors.REGISTER_USER_FAILED,
|
|
888
|
+
type: selectors$1.REGISTER_USER_FAILED,
|
|
707
889
|
error: {
|
|
708
890
|
message: 'Unable to parse the created user from the register service response'
|
|
709
891
|
}
|
|
@@ -721,18 +903,18 @@ function* registerSaga({
|
|
|
721
903
|
error.status = response.status;
|
|
722
904
|
}
|
|
723
905
|
yield effects.put({
|
|
724
|
-
type: selectors.REGISTER_USER_FAILED,
|
|
906
|
+
type: selectors$1.REGISTER_USER_FAILED,
|
|
725
907
|
error
|
|
726
908
|
});
|
|
727
909
|
}
|
|
728
910
|
}
|
|
729
911
|
function* redirectSaga() {
|
|
730
912
|
// Check if querystring contains a redirect_uri
|
|
731
|
-
const currentQs = selectors.queryParams(yield effects.select(selectors.selectCurrentSearch));
|
|
913
|
+
const currentQs = selectors$1.queryParams(yield effects.select(selectors$1.selectCurrentSearch));
|
|
732
914
|
const redirectUri = currentQs.redirect_uri || currentQs.redirect;
|
|
733
915
|
|
|
734
916
|
// We must use redux based navigation to preserve the registration state
|
|
735
|
-
if (redirectUri) yield effects.put(selectors.setRoute(redirectUri));
|
|
917
|
+
if (redirectUri) yield effects.put(selectors$1.setRoute(redirectUri));
|
|
736
918
|
}
|
|
737
919
|
|
|
738
920
|
const PAP_URL = 'https://pap.zengenti.com';
|
|
@@ -800,11 +982,11 @@ async function api(url, options) {
|
|
|
800
982
|
});
|
|
801
983
|
}
|
|
802
984
|
|
|
803
|
-
const resetPasswordSagas = [effects.takeEvery(selectors.REQUEST_USER_PASSWORD_RESET, requestPasswordResetSaga), effects.takeEvery(selectors.RESET_USER_PASSWORD, resetPasswordSaga), effects.takeEvery(selectors.CHANGE_USER_PASSWORD, changePasswordSaga)];
|
|
985
|
+
const resetPasswordSagas = [effects.takeEvery(selectors$1.REQUEST_USER_PASSWORD_RESET, requestPasswordResetSaga), effects.takeEvery(selectors$1.RESET_USER_PASSWORD, resetPasswordSaga), effects.takeEvery(selectors$1.CHANGE_USER_PASSWORD, changePasswordSaga)];
|
|
804
986
|
function* requestPasswordResetSaga(action) {
|
|
805
987
|
const userEmailObject = action.userEmailObject;
|
|
806
988
|
yield effects.put({
|
|
807
|
-
type: selectors.REQUEST_USER_PASSWORD_RESET_SENDING
|
|
989
|
+
type: selectors$1.REQUEST_USER_PASSWORD_RESET_SENDING
|
|
808
990
|
});
|
|
809
991
|
if (userEmailObject && userEmailObject.userEmail) {
|
|
810
992
|
try {
|
|
@@ -812,29 +994,29 @@ function* requestPasswordResetSaga(action) {
|
|
|
812
994
|
if (passwordResetRequestResponse) {
|
|
813
995
|
if (!passwordResetRequestResponse.error) {
|
|
814
996
|
yield effects.put({
|
|
815
|
-
type: selectors.REQUEST_USER_PASSWORD_RESET_SUCCESS
|
|
997
|
+
type: selectors$1.REQUEST_USER_PASSWORD_RESET_SUCCESS
|
|
816
998
|
});
|
|
817
999
|
} else {
|
|
818
1000
|
yield effects.put({
|
|
819
|
-
type: selectors.REQUEST_USER_PASSWORD_RESET_ERROR,
|
|
1001
|
+
type: selectors$1.REQUEST_USER_PASSWORD_RESET_ERROR,
|
|
820
1002
|
error: passwordResetRequestResponse.error.message
|
|
821
1003
|
});
|
|
822
1004
|
}
|
|
823
1005
|
} else {
|
|
824
1006
|
yield effects.put({
|
|
825
|
-
type: selectors.REQUEST_USER_PASSWORD_RESET_ERROR,
|
|
1007
|
+
type: selectors$1.REQUEST_USER_PASSWORD_RESET_ERROR,
|
|
826
1008
|
error: 'No response from server'
|
|
827
1009
|
});
|
|
828
1010
|
}
|
|
829
1011
|
} catch (error) {
|
|
830
1012
|
yield effects.put({
|
|
831
|
-
type: selectors.REQUEST_USER_PASSWORD_RESET_ERROR,
|
|
1013
|
+
type: selectors$1.REQUEST_USER_PASSWORD_RESET_ERROR,
|
|
832
1014
|
error: error && error.toString()
|
|
833
1015
|
});
|
|
834
1016
|
}
|
|
835
1017
|
} else {
|
|
836
1018
|
yield effects.put({
|
|
837
|
-
type: selectors.REQUEST_USER_PASSWORD_RESET_ERROR,
|
|
1019
|
+
type: selectors$1.REQUEST_USER_PASSWORD_RESET_ERROR,
|
|
838
1020
|
error: 'Invalid object'
|
|
839
1021
|
});
|
|
840
1022
|
}
|
|
@@ -842,7 +1024,7 @@ function* requestPasswordResetSaga(action) {
|
|
|
842
1024
|
function* resetPasswordSaga(action) {
|
|
843
1025
|
const resetPasswordObject = action.resetPasswordObject;
|
|
844
1026
|
yield effects.put({
|
|
845
|
-
type: selectors.RESET_USER_PASSWORD_SENDING
|
|
1027
|
+
type: selectors$1.RESET_USER_PASSWORD_SENDING
|
|
846
1028
|
});
|
|
847
1029
|
if (resetPasswordObject.token && resetPasswordObject.password) {
|
|
848
1030
|
try {
|
|
@@ -850,30 +1032,30 @@ function* resetPasswordSaga(action) {
|
|
|
850
1032
|
if (resetPasswordResponse) {
|
|
851
1033
|
if (!resetPasswordResponse.error) {
|
|
852
1034
|
yield effects.put({
|
|
853
|
-
type: selectors.RESET_USER_PASSWORD_SUCCESS
|
|
1035
|
+
type: selectors$1.RESET_USER_PASSWORD_SUCCESS
|
|
854
1036
|
});
|
|
855
1037
|
} else {
|
|
856
1038
|
const error = resetPasswordResponse.error.data && resetPasswordResponse.error.data.length > 0 && resetPasswordResponse.error.data[0].message || resetPasswordResponse.error.message;
|
|
857
1039
|
yield effects.put({
|
|
858
|
-
type: selectors.RESET_USER_PASSWORD_ERROR,
|
|
1040
|
+
type: selectors$1.RESET_USER_PASSWORD_ERROR,
|
|
859
1041
|
error
|
|
860
1042
|
});
|
|
861
1043
|
}
|
|
862
1044
|
} else {
|
|
863
1045
|
yield effects.put({
|
|
864
|
-
type: selectors.RESET_USER_PASSWORD_ERROR,
|
|
1046
|
+
type: selectors$1.RESET_USER_PASSWORD_ERROR,
|
|
865
1047
|
error: 'No response from server'
|
|
866
1048
|
});
|
|
867
1049
|
}
|
|
868
1050
|
} catch (error) {
|
|
869
1051
|
yield effects.put({
|
|
870
|
-
type: selectors.RESET_USER_PASSWORD_ERROR,
|
|
1052
|
+
type: selectors$1.RESET_USER_PASSWORD_ERROR,
|
|
871
1053
|
error: error && error.toString()
|
|
872
1054
|
});
|
|
873
1055
|
}
|
|
874
1056
|
} else {
|
|
875
1057
|
yield effects.put({
|
|
876
|
-
type: selectors.RESET_USER_PASSWORD_ERROR,
|
|
1058
|
+
type: selectors$1.RESET_USER_PASSWORD_ERROR,
|
|
877
1059
|
error: 'Invalid object'
|
|
878
1060
|
});
|
|
879
1061
|
}
|
|
@@ -885,7 +1067,7 @@ function* resetPasswordSaga(action) {
|
|
|
885
1067
|
function* changePasswordSaga(action) {
|
|
886
1068
|
if (!action || !action.userId || !action.currentPassword || !action.newPassword) {
|
|
887
1069
|
yield effects.put({
|
|
888
|
-
type: selectors.CHANGE_USER_PASSWORD_ERROR,
|
|
1070
|
+
type: selectors$1.CHANGE_USER_PASSWORD_ERROR,
|
|
889
1071
|
error: 'Invalid action object sent to changePassword saga'
|
|
890
1072
|
});
|
|
891
1073
|
return;
|
|
@@ -897,7 +1079,7 @@ function* changePasswordSaga(action) {
|
|
|
897
1079
|
new: action.newPassword
|
|
898
1080
|
};
|
|
899
1081
|
yield effects.put({
|
|
900
|
-
type: selectors.CHANGE_USER_PASSWORD_SENDING
|
|
1082
|
+
type: selectors$1.CHANGE_USER_PASSWORD_SENDING
|
|
901
1083
|
});
|
|
902
1084
|
const clientCredentials = yield effects.select(matchGroups.selectClientCredentials, 'js');
|
|
903
1085
|
const client = yield ChangePassword_container.getManagementApiClient({
|
|
@@ -908,17 +1090,17 @@ function* changePasswordSaga(action) {
|
|
|
908
1090
|
var _err$data, _err$data2;
|
|
909
1091
|
const error = (err === null || err === void 0 || (_err$data = err.data) === null || _err$data === void 0 || (_err$data = _err$data.data) === null || _err$data === void 0 ? void 0 : _err$data.length) > 0 && err.data.data[0].message || (err === null || err === void 0 || (_err$data2 = err.data) === null || _err$data2 === void 0 ? void 0 : _err$data2.message);
|
|
910
1092
|
yield effects.put({
|
|
911
|
-
type: selectors.CHANGE_USER_PASSWORD_ERROR,
|
|
1093
|
+
type: selectors$1.CHANGE_USER_PASSWORD_ERROR,
|
|
912
1094
|
error
|
|
913
1095
|
});
|
|
914
1096
|
return;
|
|
915
1097
|
}
|
|
916
1098
|
yield effects.put({
|
|
917
|
-
type: selectors.CHANGE_USER_PASSWORD_SUCCESS
|
|
1099
|
+
type: selectors$1.CHANGE_USER_PASSWORD_SUCCESS
|
|
918
1100
|
});
|
|
919
1101
|
} catch (error) {
|
|
920
1102
|
yield effects.put({
|
|
921
|
-
type: selectors.CHANGE_USER_PASSWORD_ERROR,
|
|
1103
|
+
type: selectors$1.CHANGE_USER_PASSWORD_ERROR,
|
|
922
1104
|
error: error && error.toString()
|
|
923
1105
|
});
|
|
924
1106
|
}
|
|
@@ -926,178 +1108,6 @@ function* changePasswordSaga(action) {
|
|
|
926
1108
|
|
|
927
1109
|
const userSagas = [...ChangePassword_container.loginSagas, ...registerSagas, ...resetPasswordSagas];
|
|
928
1110
|
|
|
929
|
-
const i18nSagas = [effects.takeEvery(slice.actions.INIT_LOCALES.type, getProjectLanguages), effects.takeEvery(selectors.SET_ENTRY, resolveCurrentRouteLanguage), effects.takeEvery(slice.actions.UPDATE_LANGUAGE.type, updateLanguage)];
|
|
930
|
-
function* resolveCurrentRouteLanguage({
|
|
931
|
-
entry,
|
|
932
|
-
node
|
|
933
|
-
}) {
|
|
934
|
-
var _entry$sys, _staticRoute$route;
|
|
935
|
-
const currentLanguage = yield effects.select(selectors$1.selectCurrentLanguage);
|
|
936
|
-
const staticRoute = yield effects.select(selectors.selectStaticRoute);
|
|
937
|
-
let nextLanguage = currentLanguage;
|
|
938
|
-
if (entry !== null && entry !== void 0 && (_entry$sys = entry.sys) !== null && _entry$sys !== void 0 && _entry$sys.language) nextLanguage = entry.sys.language;else if (node !== null && node !== void 0 && node.language) nextLanguage = node.language;else if (staticRoute !== null && staticRoute !== void 0 && (_staticRoute$route = staticRoute.route) !== null && _staticRoute$route !== void 0 && _staticRoute$route.language) nextLanguage = staticRoute.route.language;else nextLanguage = yield effects.select(selectors$1.selectPrimaryLanguage);
|
|
939
|
-
if (nextLanguage && nextLanguage !== currentLanguage) {
|
|
940
|
-
const dictionary = yield effects.call(resolveDictionaryForLanguage, nextLanguage);
|
|
941
|
-
yield effects.put(slice.actions.SET_LANGUAGE({
|
|
942
|
-
language: nextLanguage,
|
|
943
|
-
dictionary
|
|
944
|
-
}));
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
function* resolveDictionaryForLanguage(language) {
|
|
948
|
-
let dictionary = yield effects.select(selectors$1.selectDictionary);
|
|
949
|
-
// try and resolve a dictionary for this language
|
|
950
|
-
const resolver = yield effects.select(selectors$1.selectDictionaryResolver);
|
|
951
|
-
if (typeof resolver === 'function') {
|
|
952
|
-
try {
|
|
953
|
-
// dynamic import of dictionary file
|
|
954
|
-
const loadedDictionary = yield effects.call(resolver, language);
|
|
955
|
-
dictionary = loadedDictionary;
|
|
956
|
-
} catch (error) {
|
|
957
|
-
console.error(`No dictionary resolved for language ${language}`, error);
|
|
958
|
-
}
|
|
959
|
-
} else {
|
|
960
|
-
// Load dictionary from locales in state
|
|
961
|
-
const locales = yield effects.select(selectors$1.selectLocales);
|
|
962
|
-
if (locales && locales[language]) {
|
|
963
|
-
dictionary = locales[language];
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
return dictionary;
|
|
967
|
-
}
|
|
968
|
-
function* updateLanguage({
|
|
969
|
-
payload: {
|
|
970
|
-
language,
|
|
971
|
-
redirect,
|
|
972
|
-
fallbackPath
|
|
973
|
-
}
|
|
974
|
-
}) {
|
|
975
|
-
const currentLanguage = yield effects.select(selectors$1.selectCurrentLanguage);
|
|
976
|
-
if (language === currentLanguage) {
|
|
977
|
-
// no change needed
|
|
978
|
-
return;
|
|
979
|
-
} else {
|
|
980
|
-
const dictionary = language !== currentLanguage ? yield effects.call(resolveDictionaryForLanguage, language) : yield effects.select(selectors$1.selectDictionary);
|
|
981
|
-
const uri = yield effects.call(navigateToLanguageRoute, {
|
|
982
|
-
language,
|
|
983
|
-
redirect,
|
|
984
|
-
fallbackPath
|
|
985
|
-
});
|
|
986
|
-
const currentPath = yield effects.select(selectors.selectCurrentPath);
|
|
987
|
-
if (uri === currentPath || redirect === false) {
|
|
988
|
-
// already on the correct path, no need to redirect
|
|
989
|
-
if (dictionary) yield effects.put(slice.actions.SET_LANGUAGE({
|
|
990
|
-
language,
|
|
991
|
-
dictionary
|
|
992
|
-
}));
|
|
993
|
-
return;
|
|
994
|
-
}
|
|
995
|
-
yield effects.put(selectors.setRoute(uri));
|
|
996
|
-
}
|
|
997
|
-
}
|
|
998
|
-
function* navigateToLanguageRoute({
|
|
999
|
-
language,
|
|
1000
|
-
redirect,
|
|
1001
|
-
fallbackPath
|
|
1002
|
-
}) {
|
|
1003
|
-
// have they supplied the route to go to?
|
|
1004
|
-
if (typeof redirect === 'string') {
|
|
1005
|
-
return redirect;
|
|
1006
|
-
}
|
|
1007
|
-
|
|
1008
|
-
// is this an entry or a static route?
|
|
1009
|
-
const availableLanguages = yield effects.select(selectors.selectRouteEntryAvailableLanguages);
|
|
1010
|
-
if (availableLanguages.find(l => l.toLowerCase() === language.toLowerCase())) {
|
|
1011
|
-
// if entry, get the uri for this language variation from the api
|
|
1012
|
-
const entryUri = yield effects.call(getEntryUriForLanguage, {
|
|
1013
|
-
entryId: yield effects.select(selectors.selectRouteEntryID),
|
|
1014
|
-
language
|
|
1015
|
-
});
|
|
1016
|
-
if (entryUri) {
|
|
1017
|
-
return entryUri;
|
|
1018
|
-
}
|
|
1019
|
-
}
|
|
1020
|
-
|
|
1021
|
-
// if static route, get the uri from the routes config
|
|
1022
|
-
const staticRouteUri = yield effects.call(getStaticRouteUri, {
|
|
1023
|
-
language
|
|
1024
|
-
});
|
|
1025
|
-
if (staticRouteUri) {
|
|
1026
|
-
return staticRouteUri;
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
// if all else fails, fallback to the supplied fallback path or homepage
|
|
1030
|
-
return fallbackPath || `/${language.toLowerCase()}`;
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
/** Check any current static route for a language variation we have stored in i18n.routes */
|
|
1034
|
-
function* getStaticRouteUri({
|
|
1035
|
-
language
|
|
1036
|
-
}) {
|
|
1037
|
-
const staticRoute = yield effects.select(selectors.selectStaticRoute);
|
|
1038
|
-
if (staticRoute !== null && staticRoute !== void 0 && staticRoute.route.path) {
|
|
1039
|
-
var _Object$entries$find;
|
|
1040
|
-
// Routes can have parameters such as `/:facet?` we need to deparameterise
|
|
1041
|
-
// so we can check against our stored locale routes
|
|
1042
|
-
const deparameterisedPath = deparameterise(staticRoute.route.path);
|
|
1043
|
-
const localeRoutes = yield effects.select(selectors$1.selectLocaleRoutes);
|
|
1044
|
-
const originalPath = (_Object$entries$find = Object.entries(localeRoutes || {}).find(([, locales]) => Object.values(locales).includes(deparameterisedPath))) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0];
|
|
1045
|
-
const routeLocales = localeRoutes[deparameterisedPath] || localeRoutes[originalPath || ''];
|
|
1046
|
-
const routeUri = routeLocales === null || routeLocales === void 0 ? void 0 : routeLocales[language];
|
|
1047
|
-
return routeUri;
|
|
1048
|
-
}
|
|
1049
|
-
}
|
|
1050
|
-
function* getProjectLanguages({
|
|
1051
|
-
payload
|
|
1052
|
-
}) {
|
|
1053
|
-
var _payload$supportedLan;
|
|
1054
|
-
const stateLocales = yield effects.select(selectors$1.selectLocales);
|
|
1055
|
-
if (stateLocales && Object.keys(stateLocales).length > 0)
|
|
1056
|
-
// Locales already set in state, no need to fetch again
|
|
1057
|
-
return;
|
|
1058
|
-
const locales = {};
|
|
1059
|
-
if ((_payload$supportedLan = payload.supportedLanguages) !== null && _payload$supportedLan !== void 0 && _payload$supportedLan.length) {
|
|
1060
|
-
// If supported languages are provided in config, use these
|
|
1061
|
-
for (const supportedLanguage of payload.supportedLanguages) {
|
|
1062
|
-
locales[supportedLanguage] = {};
|
|
1063
|
-
}
|
|
1064
|
-
} else {
|
|
1065
|
-
// Fallback to getting languages from the project
|
|
1066
|
-
const project = yield ContensisDeliveryApi.cachedSearch.getClient().project.get();
|
|
1067
|
-
for (const supportedLanguage of project.supportedLanguages) {
|
|
1068
|
-
locales[supportedLanguage] = {};
|
|
1069
|
-
}
|
|
1070
|
-
}
|
|
1071
|
-
if (Object.keys(locales).length === 0) {
|
|
1072
|
-
// Ensure at least the primary language is included
|
|
1073
|
-
locales[payload.primaryLanguage] = {};
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
// Only commit if we have locales to set or we will end up in an infinite loop
|
|
1077
|
-
if (Object.keys(locales).length) yield effects.put(slice.actions.SET_LOCALES({
|
|
1078
|
-
...payload,
|
|
1079
|
-
locales
|
|
1080
|
-
}));
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
/** Run a Delivery API query to get all language variations for this entryId */
|
|
1084
|
-
function* getEntryUriForLanguage({
|
|
1085
|
-
entryId,
|
|
1086
|
-
language
|
|
1087
|
-
}) {
|
|
1088
|
-
try {
|
|
1089
|
-
const versionStatus = yield effects.select(version$1.selectVersionStatus);
|
|
1090
|
-
const query = new contensisDeliveryApi.Query(contensisDeliveryApi.Op.equalTo('sys.id', entryId), contensisDeliveryApi.Op.equalTo('sys.language', language), contensisDeliveryApi.Op.equalTo('sys.versionStatus', versionStatus));
|
|
1091
|
-
query.fields = ['sys.uri'];
|
|
1092
|
-
query.pageSize = 1;
|
|
1093
|
-
const result = yield ContensisDeliveryApi.cachedSearch.search(query);
|
|
1094
|
-
return result.items.length ? result.items[0].sys.uri : null;
|
|
1095
|
-
} catch (error) {
|
|
1096
|
-
console.error('Error fetching language variations:', error);
|
|
1097
|
-
yield effects.put(slice.actions.GET_ENTRY_URI_ERROR(error));
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
|
|
1101
1111
|
var rootSaga = (featureSagas = []) => {
|
|
1102
1112
|
return [...i18nSagas, ...routingSagas, ...navigationSagas, ...userSagas, ...featureSagas];
|
|
1103
1113
|
};
|
|
@@ -1158,4 +1168,4 @@ exports.createLocaleRoutes = createLocaleRoutes;
|
|
|
1158
1168
|
exports.history = history;
|
|
1159
1169
|
exports.pickProject = pickProject;
|
|
1160
1170
|
exports.rootSaga = rootSaga;
|
|
1161
|
-
//# sourceMappingURL=App-
|
|
1171
|
+
//# sourceMappingURL=App-DIks7cRe.js.map
|