@zengenti/contensis-react-base 4.0.0-beta.2 → 4.0.0-beta.20
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/LICENSE +7 -0
- package/README.md +24 -478
- package/cjs/{App-b56aca04.js → App-C_1U2j24.js} +218 -236
- package/cjs/App-C_1U2j24.js.map +1 -0
- package/cjs/{ChangePassword.container-ae35785e.js → ChangePassword.container-H4i1yRi6.js} +240 -315
- package/cjs/ChangePassword.container-H4i1yRi6.js.map +1 -0
- package/cjs/{ContensisDeliveryApi-4fcf049d.js → ContensisDeliveryApi-lcZ45Kxx.js} +125 -118
- package/cjs/ContensisDeliveryApi-lcZ45Kxx.js.map +1 -0
- package/cjs/{CookieConstants-000427db.js → CookieConstants-DfPiWCRZ.js} +3 -1
- package/cjs/CookieConstants-DfPiWCRZ.js.map +1 -0
- package/cjs/CookieHelper.class-Det3qfdU.js +462 -0
- package/cjs/CookieHelper.class-Det3qfdU.js.map +1 -0
- package/cjs/{RouteLoader-c06dccd5.js → RouteLoader-CAkG-Y5y.js} +62 -74
- package/cjs/RouteLoader-CAkG-Y5y.js.map +1 -0
- package/cjs/SSRContext-ciyKagks.js +71 -0
- package/cjs/SSRContext-ciyKagks.js.map +1 -0
- package/cjs/ToJs-BsWqWjdm.js +23 -0
- package/cjs/ToJs-BsWqWjdm.js.map +1 -0
- package/cjs/VersionInfo-D0mF1vkY.js +204 -0
- package/cjs/VersionInfo-D0mF1vkY.js.map +1 -0
- package/cjs/{_commonjsHelpers-b3309d7b.js → _commonjsHelpers-BJu3ubxk.js} +1 -1
- package/cjs/_commonjsHelpers-BJu3ubxk.js.map +1 -0
- package/cjs/client.js +47 -71
- package/cjs/client.js.map +1 -1
- package/cjs/contensis-react-base.js +645 -3303
- package/cjs/contensis-react-base.js.map +1 -1
- package/cjs/{fromJSLeaveImmer-e74c673c.js → fromJSLeaveImmer-Blvlk4t2.js} +3 -7
- package/{esm/fromJSLeaveImmer-0114ffcf.js.map → cjs/fromJSLeaveImmer-Blvlk4t2.js.map} +1 -1
- package/cjs/{ToJs-a8d8f3f0.js → matchGroups-CNt2aNoC.js} +22 -96
- package/cjs/matchGroups-CNt2aNoC.js.map +1 -0
- package/cjs/redux.js +20 -20
- package/cjs/redux.js.map +1 -1
- package/cjs/routing.js +19 -7
- package/cjs/routing.js.map +1 -1
- package/cjs/sagas-CMBI1syl.js +5835 -0
- package/cjs/sagas-CMBI1syl.js.map +1 -0
- package/cjs/search.js +119 -321
- package/cjs/search.js.map +1 -1
- package/cjs/selectors-Bp_TrwG5.js +468 -0
- package/cjs/selectors-Bp_TrwG5.js.map +1 -0
- package/cjs/{version-34d91f68.js → store-CO5xslDu.js} +44 -114
- package/cjs/store-CO5xslDu.js.map +1 -0
- package/cjs/user.js +28 -33
- package/cjs/user.js.map +1 -1
- package/cjs/util-CTvFvplw.js +148 -0
- package/cjs/util-CTvFvplw.js.map +1 -0
- package/cjs/util.js +87 -215
- package/cjs/util.js.map +1 -1
- package/cjs/version-BolvQdgT.js +20 -0
- package/cjs/version-BolvQdgT.js.map +1 -0
- package/cjs/{version-a410c88e.js → version-DabwEeLw.js} +19 -22
- package/{esm/version-9f29becb.js.map → cjs/version-DabwEeLw.js.map} +1 -1
- package/esm/{App-83107d7e.js → App-DdEKwCTJ.js} +178 -196
- package/esm/App-DdEKwCTJ.js.map +1 -0
- package/esm/{ChangePassword.container-76fd5e9b.js → ChangePassword.container-BzycNMRX.js} +193 -250
- package/esm/ChangePassword.container-BzycNMRX.js.map +1 -0
- package/esm/{ContensisDeliveryApi-fe57a037.js → ContensisDeliveryApi-BgfEEyIk.js} +124 -119
- package/esm/ContensisDeliveryApi-BgfEEyIk.js.map +1 -0
- package/esm/{CookieConstants-3d3b6531.js → CookieConstants-DEmbwzYr.js} +3 -2
- package/esm/CookieConstants-DEmbwzYr.js.map +1 -0
- package/esm/CookieHelper.class-C6rTRl_1.js +459 -0
- package/esm/CookieHelper.class-C6rTRl_1.js.map +1 -0
- package/esm/{RouteLoader-29fd689a.js → RouteLoader-Bk6e6UV-.js} +46 -58
- package/esm/RouteLoader-Bk6e6UV-.js.map +1 -0
- package/esm/SSRContext-CXRqYy6B.js +63 -0
- package/esm/SSRContext-CXRqYy6B.js.map +1 -0
- package/esm/ToJs-BnRRHk6f.js +17 -0
- package/esm/ToJs-BnRRHk6f.js.map +1 -0
- package/esm/VersionInfo-j6NR0QJR.js +193 -0
- package/esm/VersionInfo-j6NR0QJR.js.map +1 -0
- package/esm/{_commonjsHelpers-1789f0cf.js → _commonjsHelpers-BFTU3MAI.js} +1 -1
- package/esm/_commonjsHelpers-BFTU3MAI.js.map +1 -0
- package/esm/client.js +39 -62
- package/esm/client.js.map +1 -1
- package/esm/contensis-react-base.js +616 -3272
- package/esm/contensis-react-base.js.map +1 -1
- package/esm/{fromJSLeaveImmer-0114ffcf.js → fromJSLeaveImmer-C_YACmOf.js} +2 -6
- package/{cjs/fromJSLeaveImmer-e74c673c.js.map → esm/fromJSLeaveImmer-C_YACmOf.js.map} +1 -1
- package/esm/{ToJs-df57f31d.js → matchGroups-Bq8QnqFx.js} +23 -91
- package/esm/matchGroups-Bq8QnqFx.js.map +1 -0
- package/esm/redux.js +11 -9
- package/esm/redux.js.map +1 -1
- package/esm/routing.js +18 -5
- package/esm/routing.js.map +1 -1
- package/esm/sagas-BFQ4tBq_.js +5743 -0
- package/esm/sagas-BFQ4tBq_.js.map +1 -0
- package/esm/search.js +124 -323
- package/esm/search.js.map +1 -1
- package/esm/selectors-CNC7sDxg.js +404 -0
- package/esm/selectors-CNC7sDxg.js.map +1 -0
- package/esm/{version-3d9911e2.js → store-CtDx5MLq.js} +38 -85
- package/esm/store-CtDx5MLq.js.map +1 -0
- package/esm/user.js +10 -13
- package/esm/user.js.map +1 -1
- package/esm/util-BC8LWRKL.js +136 -0
- package/esm/util-BC8LWRKL.js.map +1 -0
- package/esm/util.js +69 -201
- package/esm/util.js.map +1 -1
- package/esm/version-CaL4czqJ.js +15 -0
- package/esm/version-CaL4czqJ.js.map +1 -0
- package/esm/{version-9f29becb.js → version-CfABeHJA.js} +6 -9
- package/{cjs/version-a410c88e.js.map → esm/version-CfABeHJA.js.map} +1 -1
- package/models/app/App.d.ts +1 -1
- package/models/app/pages/VersionInfo/components/VersionInfo.d.ts +4 -1
- package/models/app/pages/VersionInfo/components/VersionInfo.styled.d.ts +1 -1
- package/models/client/client.d.ts +1 -1
- package/models/index.d.ts +1 -2
- package/models/models/AppRouteProps.d.ts +11 -0
- package/models/{redux/appstate.d.ts → models/AppState.d.ts} +3 -3
- package/models/models/ContentTypeMapping.d.ts +89 -0
- package/models/models/EntryMapper.d.ts +3 -0
- package/models/models/GetRouteActionArgs.d.ts +15 -0
- package/models/models/MatchedRoute.d.ts +8 -0
- package/models/models/ReduxInjector.d.ts +5 -0
- package/models/models/RequireLogin.d.ts +6 -0
- package/models/models/RouteComponent.d.ts +3 -0
- package/models/models/RouteComponentProps.d.ts +9 -0
- package/models/models/RouteLoaderProps.d.ts +9 -0
- package/models/models/RouteNode.d.ts +5 -0
- package/models/models/SSRContext.d.ts +32 -0
- package/models/models/StaticRoute.d.ts +61 -0
- package/models/models/WithEvents.d.ts +58 -0
- package/models/models/config/AppConfig.d.ts +13 -0
- package/models/{config.d.ts → models/config/ServerConfig.d.ts} +4 -12
- package/models/models/config/StateType.d.ts +2 -0
- package/models/models/config/index.d.ts +3 -0
- package/models/models/index.d.ts +16 -0
- package/models/redux/actions/index.d.ts +2 -2
- package/models/redux/sagas/navigation.d.ts +1 -3
- package/models/redux/selectors/index.d.ts +2 -2
- package/models/redux/store/injectors.d.ts +16 -4
- package/models/redux/store/store.d.ts +10 -4
- package/models/redux/types/index.d.ts +2 -2
- package/models/redux/types/navigation.d.ts +3 -3
- package/models/redux/types/version.d.ts +2 -2
- package/models/redux/util.d.ts +1 -1
- package/models/routing/components/Redirect.d.ts +1 -1
- package/models/routing/components/RouteLoader.d.ts +3 -3
- package/models/routing/components/StaticRouteLoader.d.ts +1 -1
- package/models/routing/components/Status.d.ts +1 -1
- package/models/routing/httpContext.d.ts +0 -1
- package/models/routing/index.d.ts +1 -0
- package/models/routing/redux/actions.d.ts +3 -4
- package/models/routing/redux/selectors.d.ts +44 -4
- package/models/routing/redux/types.d.ts +11 -11
- package/models/routing/util/expressions.d.ts +1 -1
- package/models/routing/util/find-contenttype-mapping.d.ts +1 -1
- package/models/routing/util/queries.d.ts +2 -2
- package/models/search/containers/withListing.d.ts +4 -1
- package/models/search/containers/withSearch.d.ts +4 -1
- package/models/search/models/Queries.d.ts +6 -6
- package/models/search/models/Search.d.ts +13 -4
- package/models/search/models/SearchActions.d.ts +29 -12
- package/models/search/models/SearchProps.d.ts +4 -10
- package/models/search/models/SearchState.d.ts +8 -2
- package/models/search/redux/getIn.d.ts +2 -2
- package/models/search/redux/reducers.d.ts +5 -261
- package/models/search/redux/sagas.d.ts +13 -14
- package/models/search/redux/schema.d.ts +2 -2
- package/models/search/redux/selectors.d.ts +10 -10
- package/models/search/redux/util.d.ts +9 -1
- package/models/search/search/ContensisDeliveryApi.d.ts +6 -26
- package/models/search/search/expressions.d.ts +3 -3
- package/models/search/search/util.d.ts +25 -8
- package/models/search/transformations/searchresult-to-state.mapper.d.ts +1 -2
- package/models/server/features/caching/cacheDuration.schema.d.ts +1 -0
- package/models/server/features/linkdepth-api/search.d.ts +2 -2
- package/models/server/features/response-handler/render-stream.d.ts +25 -0
- package/models/server/features/static-assets/index.d.ts +3 -3
- package/models/server/internalServer.d.ts +2 -3
- package/models/server/util/bundles.d.ts +10 -10
- package/models/server/util/headers.d.ts +1 -1
- package/models/server/util/html.d.ts +23 -0
- package/models/server/util/jsx.d.ts +42 -0
- package/models/server/webApp.d.ts +1 -1
- package/models/user/components/Login.d.ts +1 -1
- package/models/user/components/LoginForm.d.ts +6 -6
- package/models/user/components/LogoutForm.d.ts +4 -4
- package/models/user/components.styled/Login.styled.d.ts +1 -1
- package/models/user/components.styled/LoginForm.styled.d.ts +1 -1
- package/models/user/hocs/withLogin.d.ts +4 -4
- package/models/user/hocs/withRegistration.d.ts +6 -3
- package/models/user/hooks/useLogin.d.ts +4 -4
- package/models/user/redux/actions.d.ts +7 -6
- package/models/user/redux/sagas/index.d.ts +1 -1
- package/models/user/redux/sagas/login.d.ts +5 -17
- package/models/user/redux/selectors.d.ts +1 -2
- package/models/user/redux/types.d.ts +21 -21
- package/models/user/state.d.ts +12 -0
- package/models/user/transformations/mapClientCredentials.d.ts +3 -1
- package/models/user/util/ContensisManagementApi.d.ts +10 -9
- package/models/user/util/CookieConstants.d.ts +1 -0
- package/models/user/util/CookieHelper.class.d.ts +8 -4
- package/models/user/util/LoginHelper.class.d.ts +25 -37
- package/models/user/util/OidcUserManager.d.ts +1 -1
- package/models/user/util/matchGroups.d.ts +1 -1
- package/models/util/CachedDeliveryApi.d.ts +19 -12
- package/models/util/ContensisDeliveryApi.d.ts +11 -9
- package/models/util/NoSSR.d.ts +6 -0
- package/models/util/SSRContext.d.ts +24 -0
- package/models/util/donotuse_useHistory.d.ts +6 -0
- package/models/util/index.d.ts +5 -1
- package/models/util/json-mapper.d.ts +4 -5
- package/models/util/useIsClient.d.ts +6 -0
- package/package.json +75 -97
- package/cjs/App-b56aca04.js.map +0 -1
- package/cjs/ChangePassword.container-ae35785e.js.map +0 -1
- package/cjs/ContensisDeliveryApi-4fcf049d.js.map +0 -1
- package/cjs/CookieConstants-000427db.js.map +0 -1
- package/cjs/RouteLoader-c06dccd5.js.map +0 -1
- package/cjs/ToJs-a8d8f3f0.js.map +0 -1
- package/cjs/_commonjsHelpers-b3309d7b.js.map +0 -1
- package/cjs/forms.js +0 -5998
- package/cjs/forms.js.map +0 -1
- package/cjs/reducers-73a03ef4.js +0 -257
- package/cjs/reducers-73a03ef4.js.map +0 -1
- package/cjs/sagas-570f23ba.js +0 -2175
- package/cjs/sagas-570f23ba.js.map +0 -1
- package/cjs/selectors-14caa813.js +0 -228
- package/cjs/selectors-14caa813.js.map +0 -1
- package/cjs/urls-6fcaf4c6.js +0 -25
- package/cjs/urls-6fcaf4c6.js.map +0 -1
- package/cjs/version-34d91f68.js.map +0 -1
- package/esm/App-83107d7e.js.map +0 -1
- package/esm/ChangePassword.container-76fd5e9b.js.map +0 -1
- package/esm/ContensisDeliveryApi-fe57a037.js.map +0 -1
- package/esm/CookieConstants-3d3b6531.js.map +0 -1
- package/esm/RouteLoader-29fd689a.js.map +0 -1
- package/esm/ToJs-df57f31d.js.map +0 -1
- package/esm/_commonjsHelpers-1789f0cf.js.map +0 -1
- package/esm/forms.js +0 -5984
- package/esm/forms.js.map +0 -1
- package/esm/reducers-aa8cef1e.js +0 -234
- package/esm/reducers-aa8cef1e.js.map +0 -1
- package/esm/sagas-07e82e18.js +0 -2083
- package/esm/sagas-07e82e18.js.map +0 -1
- package/esm/selectors-691caf02.js +0 -186
- package/esm/selectors-691caf02.js.map +0 -1
- package/esm/urls-eac9a747.js +0 -22
- package/esm/urls-eac9a747.js.map +0 -1
- package/esm/version-3d9911e2.js.map +0 -1
- package/models/forms/index.d.ts +0 -1
- package/models/routing/routes.d.ts +0 -133
- package/models/search/search/ToJs.d.ts +0 -4
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var history$1 = require('history');
|
|
4
4
|
var effects = require('@redux-saga/core/effects');
|
|
5
5
|
var log = require('loglevel');
|
|
6
|
-
var
|
|
7
|
-
var version = require('./version-
|
|
8
|
-
var version$1 = require('./version-a410c88e.js');
|
|
9
|
-
var selectors = require('./selectors-14caa813.js');
|
|
6
|
+
var store = require('./store-CO5xslDu.js');
|
|
7
|
+
var version = require('./version-DabwEeLw.js');
|
|
10
8
|
var to = require('await-to-js');
|
|
11
|
-
var
|
|
9
|
+
var selectors = require('./selectors-Bp_TrwG5.js');
|
|
10
|
+
var version$1 = require('./version-BolvQdgT.js');
|
|
11
|
+
var ChangePassword_container = require('./ChangePassword.container-H4i1yRi6.js');
|
|
12
12
|
var React = require('react');
|
|
13
13
|
require('react-cookie');
|
|
14
14
|
require('react-redux');
|
|
15
15
|
require('jsonpath-mapper');
|
|
16
|
-
var reducers = require('./reducers-73a03ef4.js');
|
|
17
16
|
var contensisDeliveryApi = require('contensis-delivery-api');
|
|
18
|
-
var
|
|
19
|
-
require('query-string');
|
|
17
|
+
var matchGroups = require('./matchGroups-CNt2aNoC.js');
|
|
20
18
|
require('react-router-dom');
|
|
21
|
-
var RouteLoader = require('./RouteLoader-
|
|
19
|
+
var RouteLoader = require('./RouteLoader-CAkG-Y5y.js');
|
|
20
|
+
require('query-string');
|
|
21
|
+
require('./ContensisDeliveryApi-lcZ45Kxx.js');
|
|
22
22
|
|
|
23
|
-
function
|
|
23
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
24
24
|
|
|
25
25
|
function _interopNamespace(e) {
|
|
26
26
|
if (e && e.__esModule) return e;
|
|
@@ -36,69 +36,60 @@ function _interopNamespace(e) {
|
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
n
|
|
39
|
+
n.default = e;
|
|
40
40
|
return Object.freeze(n);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
var log__namespace = /*#__PURE__*/_interopNamespace(log);
|
|
44
|
-
var to__default = /*#__PURE__*/
|
|
45
|
-
var React__default = /*#__PURE__*/
|
|
44
|
+
var to__default = /*#__PURE__*/_interopDefault(to);
|
|
45
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
// Create a history depending on the environment
|
|
48
|
+
const selectedHistory = typeof window !== 'undefined' ? history$1.createBrowserHistory : history$1.createMemoryHistory;
|
|
48
49
|
const history = (options = {}) => selectedHistory(options);
|
|
49
50
|
const browserHistory = selectedHistory();
|
|
50
51
|
|
|
51
|
-
const navigationSagas = [effects.takeEvery(
|
|
52
|
+
const navigationSagas = [effects.takeEvery(store.GET_NODE_TREE, ensureNodeTreeSaga)];
|
|
52
53
|
function* ensureNodeTreeSaga(action) {
|
|
54
|
+
const {
|
|
55
|
+
api,
|
|
56
|
+
language,
|
|
57
|
+
project,
|
|
58
|
+
versionStatus,
|
|
59
|
+
treeDepth
|
|
60
|
+
} = action;
|
|
53
61
|
const state = yield effects.select();
|
|
54
|
-
|
|
55
62
|
try {
|
|
56
|
-
if (!version
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
language: action.language
|
|
62
|
-
});
|
|
63
|
-
|
|
63
|
+
if (!version.hasNavigationTree(state)) {
|
|
64
|
+
const nodes = yield api.getRootNode({
|
|
65
|
+
depth: treeDepth || 0,
|
|
66
|
+
language
|
|
67
|
+
}, versionStatus, project);
|
|
64
68
|
if (nodes) {
|
|
65
69
|
yield effects.put({
|
|
66
|
-
type:
|
|
70
|
+
type: store.SET_NODE_TREE,
|
|
67
71
|
nodes
|
|
68
72
|
});
|
|
69
73
|
} else {
|
|
70
74
|
yield effects.put({
|
|
71
|
-
type:
|
|
75
|
+
type: store.GET_NODE_TREE_ERROR
|
|
72
76
|
});
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
79
|
} catch (ex) {
|
|
76
80
|
log__namespace.error(...['Error running ensureNodeTreeSaga:', ex]);
|
|
77
81
|
yield effects.put({
|
|
78
|
-
type:
|
|
82
|
+
type: store.GET_NODE_TREE_ERROR,
|
|
79
83
|
error: ex.toString()
|
|
80
84
|
});
|
|
81
85
|
}
|
|
82
86
|
}
|
|
83
87
|
|
|
84
88
|
const sys = {
|
|
85
|
-
contentTypeId: 'sys.contentTypeId',
|
|
86
|
-
dataFormat: 'sys.dataFormat',
|
|
87
|
-
filename: 'sys.properties.filename',
|
|
88
|
-
id: 'sys.id',
|
|
89
|
-
includeInSearch: 'sys.metadata.includeInSearch',
|
|
90
|
-
slug: 'sys.slug',
|
|
91
|
-
uri: 'sys.uri',
|
|
92
89
|
versionStatus: 'sys.versionStatus'
|
|
93
90
|
};
|
|
94
91
|
const Fields = {
|
|
95
|
-
|
|
96
|
-
entryDescription: 'entryDescription',
|
|
97
|
-
keywords: 'keywords',
|
|
98
|
-
sys,
|
|
99
|
-
contentTypeId: 'sys.contentTypeId',
|
|
100
|
-
wildcard: '*'
|
|
101
|
-
};
|
|
92
|
+
sys};
|
|
102
93
|
|
|
103
94
|
const fieldExpression = (field, value, operator = 'equalTo', weight = null) => {
|
|
104
95
|
if (!field || !value) return [];
|
|
@@ -107,21 +98,21 @@ const fieldExpression = (field, value, operator = 'equalTo', weight = null) => {
|
|
|
107
98
|
const defaultExpressions = versionStatus => {
|
|
108
99
|
return [contensisDeliveryApi.Op.equalTo(Fields.sys.versionStatus, versionStatus)];
|
|
109
100
|
};
|
|
110
|
-
|
|
111
101
|
const equalToOrIn = (field, arr, operator = 'equalTo') => arr.length === 0 ? [] : arr.length === 1 ? [contensisDeliveryApi.Op[operator](field, arr[0])] : [contensisDeliveryApi.Op.in(field, ...arr)];
|
|
112
102
|
|
|
113
|
-
const routeEntryByFieldsQuery = (id, language = 'en-GB', fields = [], versionStatus = 'published') => {
|
|
114
|
-
const query = new contensisDeliveryApi.Query(...[...fieldExpression('sys.id', id), ...fieldExpression('sys.language', language), ...defaultExpressions(versionStatus)]);
|
|
103
|
+
const routeEntryByFieldsQuery = (id, language = 'en-GB', contentTypeId = '', fields = [], fieldLinkDepths, versionStatus = 'published') => {
|
|
104
|
+
const query = new contensisDeliveryApi.Query(...[...fieldExpression('sys.id', id), ...fieldExpression('sys.language', language), ...(contentTypeId ? fieldExpression('sys.contentTypeId', contentTypeId) : fieldExpression('sys.dataFormat', 'entry')), ...defaultExpressions(versionStatus)]);
|
|
115
105
|
query.fields = fields;
|
|
106
|
+
query.fieldLinkDepths = fieldLinkDepths;
|
|
116
107
|
return query;
|
|
117
108
|
};
|
|
118
109
|
|
|
119
110
|
const routingSagas = [effects.takeEvery(selectors.SET_NAVIGATION_PATH, getRouteSaga), effects.takeEvery(selectors.SET_ROUTE, setRouteSaga)];
|
|
111
|
+
|
|
120
112
|
/**
|
|
121
113
|
* To navigate / push a specific route via redux middleware
|
|
122
114
|
* @param {path, state} action
|
|
123
115
|
*/
|
|
124
|
-
|
|
125
116
|
function* setRouteSaga(action) {
|
|
126
117
|
yield effects.put({
|
|
127
118
|
type: 'CALL_HISTORY_METHOD',
|
|
@@ -131,87 +122,97 @@ function* setRouteSaga(action) {
|
|
|
131
122
|
}
|
|
132
123
|
});
|
|
133
124
|
}
|
|
134
|
-
|
|
135
125
|
function* getRouteSaga(action) {
|
|
136
126
|
let entry = null;
|
|
137
|
-
|
|
138
127
|
try {
|
|
139
|
-
var _staticRoute$route, _staticRoute$
|
|
140
|
-
|
|
128
|
+
var _staticRoute$route, _staticRoute$route2, _staticRoute$route3, _staticRoute$route4, _appsays, _appsays2, _appsays3, _pathNode3, _pathNode4;
|
|
141
129
|
const {
|
|
142
130
|
withEvents,
|
|
143
131
|
routes: {
|
|
144
132
|
ContentTypeMappings = {}
|
|
145
133
|
} = {},
|
|
146
134
|
staticRoute,
|
|
147
|
-
|
|
135
|
+
// get api instance from ssr context that is connected to the specific request in ssr
|
|
136
|
+
ssr: {
|
|
137
|
+
api
|
|
138
|
+
}
|
|
148
139
|
} = action;
|
|
149
|
-
const api = ContensisDeliveryApi.cachedSearchWithCookies(cookies.raw); // Inject redux { key, reducer, saga } provided by staticRoute
|
|
150
140
|
|
|
151
|
-
|
|
141
|
+
// Inject redux { key, reducer, saga } provided by staticRoute
|
|
142
|
+
if (staticRoute && staticRoute.route.injectRedux) yield effects.call(reduxInjectorSaga, staticRoute.route.injectRedux);
|
|
152
143
|
|
|
144
|
+
// Variables we will pass to setRouteEntry
|
|
153
145
|
let pathNode = null,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
let contentTypeMapping = {};
|
|
158
|
-
// calls to withEvents.onRouteLoad and onRouteLoaded
|
|
146
|
+
ancestors = null,
|
|
147
|
+
children = [],
|
|
148
|
+
siblings = null;
|
|
149
|
+
let contentTypeMapping = {};
|
|
159
150
|
|
|
151
|
+
// These variables are the return values from
|
|
152
|
+
// calls to withEvents.onRouteLoad and onRouteLoaded
|
|
160
153
|
let appsays,
|
|
161
|
-
|
|
162
|
-
|
|
154
|
+
requireLogin = false;
|
|
163
155
|
if (withEvents && withEvents.onRouteLoad) {
|
|
164
156
|
appsays = yield withEvents.onRouteLoad(action);
|
|
165
157
|
}
|
|
166
158
|
|
|
167
|
-
|
|
168
|
-
|
|
159
|
+
// We could improve this further with a reusable mapper
|
|
160
|
+
// function to return these params given a static route
|
|
161
|
+
// or matching a content type mapping we could call at various points
|
|
162
|
+
// enabling us to mix and match and prioritise inputs if there are multiple
|
|
163
|
+
let linkDepth = staticRoute === null || staticRoute === void 0 || (_staticRoute$route = staticRoute.route) === null || _staticRoute$route === void 0 || (_staticRoute$route = _staticRoute$route.fetchNode) === null || _staticRoute$route === void 0 ? void 0 : _staticRoute$route.linkDepth;
|
|
164
|
+
let fields = staticRoute === null || staticRoute === void 0 || (_staticRoute$route2 = staticRoute.route) === null || _staticRoute$route2 === void 0 || (_staticRoute$route2 = _staticRoute$route2.fetchNode) === null || _staticRoute$route2 === void 0 ? void 0 : _staticRoute$route2.fields;
|
|
165
|
+
let fieldLinkDepths = staticRoute === null || staticRoute === void 0 || (_staticRoute$route3 = staticRoute.route) === null || _staticRoute$route3 === void 0 || (_staticRoute$route3 = _staticRoute$route3.fetchNode) === null || _staticRoute$route3 === void 0 ? void 0 : _staticRoute$route3.fieldLinkDepths;
|
|
166
|
+
let entryMapper = staticRoute === null || staticRoute === void 0 || (_staticRoute$route4 = staticRoute.route) === null || _staticRoute$route4 === void 0 || (_staticRoute$route4 = _staticRoute$route4.fetchNode) === null || _staticRoute$route4 === void 0 ? void 0 : _staticRoute$route4.entryMapper;
|
|
169
167
|
const entryLinkDepth = appsays && appsays.entryLinkDepth !== undefined ? appsays.entryLinkDepth : 2;
|
|
170
|
-
const
|
|
168
|
+
const entryFieldLinkDepths = (_appsays = appsays) === null || _appsays === void 0 ? void 0 : _appsays.entryFieldLinkDepths;
|
|
169
|
+
const setStaticRouteLimits = typeof linkDepth !== 'undefined' || fields || fieldLinkDepths;
|
|
170
|
+
const setContentTypeLimits = !!ContentTypeMappings.find(ct => ct.fields || ct.linkDepth || ct.nodeOptions || ct.fieldLinkDepths);
|
|
171
171
|
const state = yield effects.select();
|
|
172
172
|
const routeEntry = selectors.selectRouteEntry(state, 'js');
|
|
173
173
|
const routeNode = selectors.selectCurrentNode(state, 'js');
|
|
174
174
|
const currentPath = action.path; //selectCurrentPath(state);
|
|
175
|
-
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
|
|
175
|
+
const deliveryApiStatus = version$1.selectVersionStatus(state);
|
|
176
|
+
const project = selectors.selectCurrentProject(state);
|
|
177
|
+
// const isHome = currentPath === '/';
|
|
179
178
|
const isPreview = currentPath && currentPath.startsWith('/preview/');
|
|
180
179
|
const defaultLang = appsays && appsays.defaultLang || 'en-GB';
|
|
181
|
-
|
|
182
|
-
|
|
180
|
+
if (!isPreview && ((_appsays2 = appsays) !== null && _appsays2 !== void 0 && _appsays2.customRouting || staticRoute && !staticRoute.route.fetchNode || routeEntry && action.statePath === action.path && ((_appsays3 = appsays) === null || _appsays3 === void 0 ? void 0 : _appsays3.refetchNode) !== true)) {
|
|
181
|
+
var _staticRoute$route5;
|
|
183
182
|
// To prevent erroneous 404s and wasted network calls, this covers
|
|
184
183
|
// - appsays customRouting and does SET_ENTRY etc. via the consuming app
|
|
185
184
|
// - all staticRoutes (where custom 'route.fetchNode' attribute is falsey)
|
|
186
185
|
// - standard Contensis SiteView Routing where we already have that entry in state
|
|
187
|
-
if (routeEntry && (!staticRoute || staticRoute
|
|
188
|
-
pathNode = {
|
|
186
|
+
if (routeEntry && (!staticRoute || staticRoute !== null && staticRoute !== void 0 && (_staticRoute$route5 = staticRoute.route) !== null && _staticRoute$route5 !== void 0 && _staticRoute$route5.fetchNode)) {
|
|
187
|
+
pathNode = {
|
|
188
|
+
...routeNode,
|
|
189
189
|
entry: null
|
|
190
190
|
};
|
|
191
|
-
pathNode.entry = entry = routeEntry;
|
|
191
|
+
pathNode.entry = entry = routeEntry;
|
|
192
|
+
//Do nothing, the entry is allready the right one.
|
|
192
193
|
// yield put({
|
|
193
194
|
// type: SET_ENTRY,
|
|
194
195
|
// entry,
|
|
195
196
|
// node: routeNode,
|
|
196
197
|
// isLoading: false,
|
|
197
198
|
// });
|
|
198
|
-
|
|
199
199
|
yield effects.put({
|
|
200
200
|
type: selectors.UPDATE_LOADING_STATE,
|
|
201
201
|
isLoading: false
|
|
202
202
|
});
|
|
203
203
|
} else yield effects.call(setRouteEntry, currentPath, routeEntry, yield effects.select(selectors.selectCurrentNode), yield effects.select(selectors.selectCurrentAncestors), yield effects.select(selectors.selectCurrentSiblings));
|
|
204
204
|
} else {
|
|
205
|
+
var _staticRoute$route6;
|
|
205
206
|
// Handle preview routes
|
|
206
207
|
if (isPreview) {
|
|
207
208
|
let splitPath = currentPath.split('/');
|
|
208
209
|
let entryGuid = splitPath[2];
|
|
209
210
|
let language = defaultLang;
|
|
210
|
-
|
|
211
211
|
if (splitPath.length >= 3) {
|
|
212
212
|
//set lang key if available in the path, else use default lang
|
|
213
213
|
//assumes preview url on content type is: http://preview.ALIAS.contensis.cloud/preview/{GUID}/{LANG}
|
|
214
|
-
if (splitPath.length == 4) language = splitPath[3];
|
|
214
|
+
if (splitPath.length == 4) language = splitPath[3];
|
|
215
|
+
// According to product dev we cannot use Node API
|
|
215
216
|
// for previewing entries as it gives a response of []
|
|
216
217
|
// -- apparently it is not correct to request latest content
|
|
217
218
|
// with Node API
|
|
@@ -221,7 +222,6 @@ function* getRouteSaga(action) {
|
|
|
221
222
|
language,
|
|
222
223
|
linkDepth: entryLinkDepth
|
|
223
224
|
});
|
|
224
|
-
|
|
225
225
|
if (previewEntry) {
|
|
226
226
|
pathNode = {
|
|
227
227
|
entry: previewEntry
|
|
@@ -232,29 +232,30 @@ function* getRouteSaga(action) {
|
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
} else {
|
|
235
|
-
var _pathNode,
|
|
236
|
-
|
|
235
|
+
var _pathNode, _pathNode2;
|
|
237
236
|
// Handle all other routes
|
|
238
237
|
let nodeError = undefined;
|
|
239
|
-
|
|
238
|
+
// Resolve a stub of route node if we are setting limits in content type mappings
|
|
239
|
+
// Resolve the complete entry with the node if we are setting limits in a static route
|
|
240
|
+
[nodeError, pathNode] = yield to__default.default(api.getNode({
|
|
240
241
|
depth: 0,
|
|
241
242
|
path: currentPath,
|
|
242
|
-
entryFields: setContentTypeLimits ? ['sys.contentTypeId', 'sys.id'] :
|
|
243
|
-
entryLinkDepth:
|
|
243
|
+
entryFields: setStaticRouteLimits ? fields || '*' : setContentTypeLimits ? ['sys.contentTypeId', 'sys.id'] : '*',
|
|
244
|
+
entryLinkDepth: setStaticRouteLimits && typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth || 0,
|
|
245
|
+
entryFieldLinkDepths: setStaticRouteLimits ? fieldLinkDepths : setContentTypeLimits ? undefined : entryFieldLinkDepths,
|
|
244
246
|
language: defaultLang,
|
|
245
247
|
versionStatus: deliveryApiStatus
|
|
246
248
|
}, project));
|
|
247
|
-
|
|
248
249
|
if (nodeError) {
|
|
249
250
|
if ([401, 403].includes(nodeError.status)) {
|
|
250
251
|
// Capture specific auth errors with the delivery api
|
|
251
252
|
// and fire the user down the handleRequiresLoginSaga
|
|
252
253
|
// If auth was successful via a refreshToken we need to reload the page
|
|
253
254
|
// to run this getRouteSaga again with the security token cookie
|
|
254
|
-
const userLoggedIn = yield effects.call(ChangePassword_container.handleRequiresLoginSaga, {
|
|
255
|
+
const userLoggedIn = yield effects.call(ChangePassword_container.handleRequiresLoginSaga, {
|
|
256
|
+
...action,
|
|
255
257
|
requireLogin: true
|
|
256
258
|
});
|
|
257
|
-
|
|
258
259
|
if (userLoggedIn && nodeError.status === 401) {
|
|
259
260
|
// Reload the route so we can re-run the routing request now the
|
|
260
261
|
// authentication cookies are written
|
|
@@ -273,31 +274,41 @@ function* getRouteSaga(action) {
|
|
|
273
274
|
entry
|
|
274
275
|
} = pathNode || {});
|
|
275
276
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
277
|
+
// Try resolve a content type mapping
|
|
278
|
+
if ((_pathNode = pathNode) !== null && _pathNode !== void 0 && (_pathNode = _pathNode.entry) !== null && _pathNode !== void 0 && (_pathNode = _pathNode.sys) !== null && _pathNode !== void 0 && _pathNode.id && pathNode.entry.sys.contentTypeId) {
|
|
279
279
|
// Get fields[] and linkDepth from ContentTypeMapping to get the entry data
|
|
280
280
|
// and current node's ordinates at a specified depth with specified fields
|
|
281
|
-
contentTypeMapping = ChangePassword_container.findContentTypeMapping(ContentTypeMappings, pathNode.entry.sys.contentTypeId)
|
|
282
|
-
|
|
281
|
+
contentTypeMapping = ChangePassword_container.findContentTypeMapping(ContentTypeMappings, pathNode.entry.sys.contentTypeId);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// Run a second search query if we aren't setting limits from a static route
|
|
285
|
+
// but we are setting limits from a content type mapping, now we have a handle
|
|
286
|
+
// on a contentTypeId from the resolve node, we can apply the right limits when
|
|
287
|
+
// fetching the entry
|
|
288
|
+
if (!setStaticRouteLimits && setContentTypeLimits && (_pathNode2 = pathNode) !== null && _pathNode2 !== void 0 && (_pathNode2 = _pathNode2.entry) !== null && _pathNode2 !== void 0 && (_pathNode2 = _pathNode2.sys) !== null && _pathNode2 !== void 0 && _pathNode2.id) {
|
|
289
|
+
var _payload$items;
|
|
290
|
+
// Now we have a handle on a content type mapping we can
|
|
291
|
+
// reassign the query limiting variables if we haven't
|
|
292
|
+
// already set them in a static route
|
|
293
|
+
if (!setStaticRouteLimits) ({
|
|
294
|
+
fieldLinkDepths,
|
|
283
295
|
fields,
|
|
284
296
|
linkDepth
|
|
285
|
-
} = contentTypeMapping;
|
|
286
|
-
const query = routeEntryByFieldsQuery(pathNode.entry.sys.id, pathNode.entry.sys.language, fields, deliveryApiStatus);
|
|
297
|
+
} = contentTypeMapping || {});
|
|
298
|
+
const query = routeEntryByFieldsQuery(pathNode.entry.sys.id, pathNode.entry.sys.language, pathNode.entry.sys.contentTypeId, fields, fieldLinkDepths, deliveryApiStatus);
|
|
287
299
|
const payload = yield api.search(query, typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth || 0, project);
|
|
288
|
-
|
|
289
|
-
if ((payload === null || payload === void 0 ? void 0 : (_payload$items = payload.items) === null || _payload$items === void 0 ? void 0 : _payload$items.length) > 0) {
|
|
300
|
+
if ((payload === null || payload === void 0 || (_payload$items = payload.items) === null || _payload$items === void 0 ? void 0 : _payload$items.length) > 0) {
|
|
290
301
|
pathNode.entry = entry = payload.items[0];
|
|
291
302
|
}
|
|
292
303
|
}
|
|
293
|
-
}
|
|
294
|
-
// siblings or entire node tree
|
|
295
|
-
|
|
304
|
+
}
|
|
296
305
|
|
|
306
|
+
// make calls to fetch node ancestors, children,
|
|
307
|
+
// siblings or entire node tree
|
|
297
308
|
[ancestors, children, siblings] = yield effects.call(resolveCurrentNodeOrdinates, {
|
|
298
309
|
api,
|
|
299
310
|
appsays,
|
|
300
|
-
contentTypeMapping,
|
|
311
|
+
contentTypeMapping: contentTypeMapping || (staticRoute === null || staticRoute === void 0 || (_staticRoute$route6 = staticRoute.route) === null || _staticRoute$route6 === void 0 ? void 0 : _staticRoute$route6.fetchNode) || {},
|
|
301
312
|
language: defaultLang,
|
|
302
313
|
path: currentPath,
|
|
303
314
|
pathNode,
|
|
@@ -306,39 +317,36 @@ function* getRouteSaga(action) {
|
|
|
306
317
|
});
|
|
307
318
|
if (children) pathNode.children = children;
|
|
308
319
|
}
|
|
320
|
+
const resolvedContentTypeMapping = ChangePassword_container.findContentTypeMapping(ContentTypeMappings, (_pathNode3 = pathNode) === null || _pathNode3 === void 0 || (_pathNode3 = _pathNode3.entry) === null || _pathNode3 === void 0 || (_pathNode3 = _pathNode3.sys) === null || _pathNode3 === void 0 ? void 0 : _pathNode3.contentTypeId) || {};
|
|
309
321
|
|
|
310
|
-
|
|
311
|
-
|
|
322
|
+
// Inject redux { key, reducer, saga } provided by ContentTypeMapping
|
|
312
323
|
if (resolvedContentTypeMapping.injectRedux) yield effects.call(reduxInjectorSaga, resolvedContentTypeMapping.injectRedux);
|
|
313
|
-
|
|
314
324
|
if (withEvents && withEvents.onRouteLoaded) {
|
|
315
325
|
// Check if the app has provided a requireLogin boolean flag or groups array
|
|
316
326
|
// in addition to checking if requireLogin is set in the route definition
|
|
317
327
|
({
|
|
318
328
|
requireLogin
|
|
319
|
-
} = (yield withEvents.onRouteLoaded({
|
|
329
|
+
} = (yield withEvents.onRouteLoaded({
|
|
330
|
+
...action,
|
|
320
331
|
entry
|
|
321
332
|
})) || {});
|
|
322
333
|
}
|
|
323
|
-
|
|
324
334
|
if (requireLogin !== false) {
|
|
325
335
|
// Do not call the login feature saga if requireLogin is false
|
|
326
|
-
yield effects.call(ChangePassword_container.handleRequiresLoginSaga, {
|
|
336
|
+
yield effects.call(ChangePassword_container.handleRequiresLoginSaga, {
|
|
337
|
+
...action,
|
|
327
338
|
entry,
|
|
328
339
|
requireLogin
|
|
329
340
|
});
|
|
330
341
|
}
|
|
331
|
-
|
|
332
342
|
if (!appsays || !appsays.preventScrollTop) {
|
|
333
343
|
// Scroll into View
|
|
334
344
|
if (typeof window !== 'undefined') window.scrollTo(0, 0);
|
|
335
345
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
var _staticRoute$route3, _staticRoute$route3$f, _appsays;
|
|
339
|
-
|
|
346
|
+
if ((_pathNode4 = pathNode) !== null && _pathNode4 !== void 0 && (_pathNode4 = _pathNode4.entry) !== null && _pathNode4 !== void 0 && (_pathNode4 = _pathNode4.sys) !== null && _pathNode4 !== void 0 && _pathNode4.id) {
|
|
347
|
+
var _appsays4;
|
|
340
348
|
entry = pathNode.entry;
|
|
341
|
-
yield effects.call(setRouteEntry, currentPath, entry, pathNode, ancestors, siblings,
|
|
349
|
+
yield effects.call(setRouteEntry, currentPath, entry, pathNode, ancestors, siblings, entryMapper || resolvedContentTypeMapping.entryMapper, false, (_appsays4 = appsays) === null || _appsays4 === void 0 ? void 0 : _appsays4.refetchNode);
|
|
342
350
|
} else {
|
|
343
351
|
if (staticRoute) yield effects.call(setRouteEntry, currentPath, null, pathNode, ancestors, siblings);else yield effects.call(do404);
|
|
344
352
|
}
|
|
@@ -347,29 +355,30 @@ function* getRouteSaga(action) {
|
|
|
347
355
|
yield effects.call(do500, e);
|
|
348
356
|
}
|
|
349
357
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
}
|
|
361
|
-
const apiCall = [() => null, () => null, () => null, () => null];
|
|
358
|
+
function* resolveCurrentNodeOrdinates(action) {
|
|
359
|
+
const {
|
|
360
|
+
api,
|
|
361
|
+
appsays,
|
|
362
|
+
contentTypeMapping,
|
|
363
|
+
language,
|
|
364
|
+
path,
|
|
365
|
+
pathNode,
|
|
366
|
+
project,
|
|
367
|
+
versionStatus
|
|
368
|
+
} = action;
|
|
369
|
+
const apiCall = [() => null, () => null, () => null, () => null];
|
|
370
|
+
|
|
371
|
+
// if appsays customNavigation: true, we will set doNavigation to false
|
|
362
372
|
// if appsays customNavigation: { ... }, we will set doNavigation to the customNavigation object and check for child elements
|
|
363
373
|
// if appsays nothing we will set doNavigation to true and continue to do navigation calls
|
|
364
|
-
|
|
365
374
|
const doNavigation = !appsays || ((appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) === true ? false : (appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) || true);
|
|
366
375
|
const {
|
|
367
376
|
entryLinkDepth = 0,
|
|
377
|
+
fieldLinkDepths,
|
|
368
378
|
fields,
|
|
369
379
|
linkDepth,
|
|
370
380
|
nodeOptions = {}
|
|
371
381
|
} = contentTypeMapping;
|
|
372
|
-
|
|
373
382
|
if (pathNode && pathNode.id) {
|
|
374
383
|
if (doNavigation === true || doNavigation.ancestors) {
|
|
375
384
|
apiCall[0] = function* getAncestors() {
|
|
@@ -385,17 +394,15 @@ function* resolveCurrentNodeOrdinates({
|
|
|
385
394
|
}
|
|
386
395
|
};
|
|
387
396
|
}
|
|
388
|
-
|
|
389
397
|
const childrenDepth = doNavigation === true || doNavigation.children === true ? 1 : doNavigation && doNavigation.children || 0;
|
|
390
|
-
|
|
391
398
|
if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.children) === 'undefined' && childrenDepth > 0 || nodeOptions.children) {
|
|
392
|
-
const childrenOptions = typeof nodeOptions.children === 'boolean' ? {} : nodeOptions.children;
|
|
393
|
-
|
|
399
|
+
const childrenOptions = !nodeOptions.children || typeof nodeOptions.children === 'boolean' ? {} : nodeOptions.children;
|
|
394
400
|
apiCall[1] = function* getChildren() {
|
|
395
401
|
try {
|
|
396
402
|
return yield api.getNode({
|
|
397
403
|
depth: childrenOptions.depth !== undefined ? childrenOptions.depth : childrenDepth,
|
|
398
404
|
path,
|
|
405
|
+
entryFieldLinkDepths: childrenOptions.fieldLinkDepths || fieldLinkDepths,
|
|
399
406
|
entryFields: childrenOptions.fields || fields || undefined,
|
|
400
407
|
entryLinkDepth: typeof childrenOptions.linkDepth !== 'undefined' ? childrenOptions.linkDepth : typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth,
|
|
401
408
|
language,
|
|
@@ -407,16 +414,15 @@ function* resolveCurrentNodeOrdinates({
|
|
|
407
414
|
}
|
|
408
415
|
};
|
|
409
416
|
}
|
|
410
|
-
|
|
411
417
|
if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.siblings) === 'undefined' && doNavigation.siblings || nodeOptions.siblings) {
|
|
412
418
|
apiCall[2] = function* getSiblings() {
|
|
413
419
|
try {
|
|
414
|
-
var _nodeOptions$siblings, _nodeOptions$siblings2;
|
|
415
|
-
|
|
420
|
+
var _nodeOptions$siblings, _nodeOptions$siblings2, _nodeOptions$siblings3;
|
|
416
421
|
return yield api.getSiblings({
|
|
417
422
|
id: pathNode.id,
|
|
418
|
-
|
|
419
|
-
|
|
423
|
+
entryFieldLinkDepths: (nodeOptions === null || nodeOptions === void 0 || (_nodeOptions$siblings = nodeOptions.siblings) === null || _nodeOptions$siblings === void 0 ? void 0 : _nodeOptions$siblings.fieldLinkDepths) || fieldLinkDepths,
|
|
424
|
+
entryFields: (nodeOptions === null || nodeOptions === void 0 || (_nodeOptions$siblings2 = nodeOptions.siblings) === null || _nodeOptions$siblings2 === void 0 ? void 0 : _nodeOptions$siblings2.fields) || fields || undefined,
|
|
425
|
+
entryLinkDepth: typeof (nodeOptions === null || nodeOptions === void 0 || (_nodeOptions$siblings3 = nodeOptions.siblings) === null || _nodeOptions$siblings3 === void 0 ? void 0 : _nodeOptions$siblings3.linkDepth) !== 'undefined' ? nodeOptions.siblings.linkDepth : typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth,
|
|
420
426
|
includeInMenu: true,
|
|
421
427
|
language,
|
|
422
428
|
versionStatus
|
|
@@ -428,20 +434,18 @@ function* resolveCurrentNodeOrdinates({
|
|
|
428
434
|
};
|
|
429
435
|
}
|
|
430
436
|
}
|
|
431
|
-
|
|
432
|
-
const isTreeLoaded = yield effects.select(version$1.hasNavigationTree);
|
|
437
|
+
const isTreeLoaded = yield effects.select(version.hasNavigationTree);
|
|
433
438
|
if (!isTreeLoaded && (doNavigation === true || doNavigation.tree)) apiCall[3] = function* getNodeTree() {
|
|
434
439
|
const treeDepth = doNavigation === true || !doNavigation.tree || doNavigation.tree === true ? 2 : doNavigation.tree;
|
|
435
|
-
|
|
436
440
|
if (typeof window !== 'undefined') {
|
|
437
441
|
return yield effects.put({
|
|
438
|
-
type:
|
|
439
|
-
|
|
442
|
+
type: store.GET_NODE_TREE,
|
|
443
|
+
...action,
|
|
440
444
|
treeDepth
|
|
441
445
|
});
|
|
442
446
|
} else {
|
|
443
447
|
return yield effects.call(ensureNodeTreeSaga, {
|
|
444
|
-
|
|
448
|
+
...action,
|
|
445
449
|
treeDepth
|
|
446
450
|
});
|
|
447
451
|
}
|
|
@@ -450,15 +454,16 @@ function* resolveCurrentNodeOrdinates({
|
|
|
450
454
|
const [ancestors, nodeWithChildren, siblings] = yield effects.all([loadAncestors(), loadChildren(), loadSiblings(), loadTree()]);
|
|
451
455
|
return [ancestors, nodeWithChildren === null || nodeWithChildren === void 0 ? void 0 : nodeWithChildren.children, siblings];
|
|
452
456
|
}
|
|
453
|
-
|
|
454
457
|
function* setRouteEntry(currentPath, entry, node, ancestors, siblings, entryMapper, notFound = false, remapEntry = false) {
|
|
455
|
-
const entrySys = entry && entry.sys || {};
|
|
456
|
-
// an updated entry id in client-side navigation
|
|
458
|
+
const entrySys = entry && entry.sys || {};
|
|
457
459
|
|
|
460
|
+
// Update a window global to provide the preview toolbar
|
|
461
|
+
// an updated entry id in client-side navigation
|
|
458
462
|
if (typeof window !== 'undefined') window.ContensisEntryId = entrySys.id;
|
|
459
463
|
const currentEntryId = yield effects.select(selectors.selectRouteEntryEntryId);
|
|
460
464
|
const currentEntryLang = yield effects.select(selectors.selectRouteEntryLanguage);
|
|
461
|
-
const mappedEntry = currentEntryId === entrySys.id && currentEntryLang === entrySys.language && remapEntry === false ? (yield effects.select(selectors.selectMappedEntry, 'js')) || {} : yield mapRouteEntry(entryMapper, {
|
|
465
|
+
const mappedEntry = !entryMapper ? null : currentEntryId === entrySys.id && currentEntryLang === entrySys.language && remapEntry === false ? (yield effects.select(selectors.selectMappedEntry, 'js')) || {} : yield mapRouteEntry(entryMapper, {
|
|
466
|
+
...node,
|
|
462
467
|
entry,
|
|
463
468
|
ancestors,
|
|
464
469
|
siblings
|
|
@@ -479,7 +484,6 @@ function* setRouteEntry(currentPath, entry, node, ancestors, siblings, entryMapp
|
|
|
479
484
|
siblings
|
|
480
485
|
})]);
|
|
481
486
|
}
|
|
482
|
-
|
|
483
487
|
function* mapRouteEntry(entryMapper, node) {
|
|
484
488
|
try {
|
|
485
489
|
if (typeof entryMapper === 'function') {
|
|
@@ -489,11 +493,10 @@ function* mapRouteEntry(entryMapper, node) {
|
|
|
489
493
|
}
|
|
490
494
|
} catch (e) {
|
|
491
495
|
log__namespace.error(...['Error running entryMapper:', e, e.stack]);
|
|
496
|
+
throw e;
|
|
492
497
|
}
|
|
493
|
-
|
|
494
498
|
return;
|
|
495
499
|
}
|
|
496
|
-
|
|
497
500
|
function* do404() {
|
|
498
501
|
yield effects.call(clientReloadHitServer);
|
|
499
502
|
yield effects.put({
|
|
@@ -503,17 +506,16 @@ function* do404() {
|
|
|
503
506
|
notFound: true
|
|
504
507
|
});
|
|
505
508
|
}
|
|
506
|
-
|
|
507
509
|
function* clientReloadHitServer() {
|
|
508
|
-
const stateEntry = yield effects.select(selectors.selectRouteEntry);
|
|
510
|
+
const stateEntry = yield effects.select(selectors.selectRouteEntry);
|
|
511
|
+
|
|
512
|
+
// If in client and there is a stateEntry.sys field reload the page,
|
|
509
513
|
// on the 2nd load stateEntry.sys should be null at this point,
|
|
510
514
|
// we do not wish to reload again and get stuck in an infinite reloading loop
|
|
511
|
-
|
|
512
515
|
if (typeof window !== 'undefined' && (stateEntry !== null && stateEntry !== void 0 && stateEntry.sys || null)) {
|
|
513
516
|
window.location.reload();
|
|
514
517
|
}
|
|
515
518
|
}
|
|
516
|
-
|
|
517
519
|
function* do500(error) {
|
|
518
520
|
yield effects.put({
|
|
519
521
|
type: selectors.SET_ENTRY,
|
|
@@ -525,7 +527,6 @@ function* do500(error) {
|
|
|
525
527
|
statusCode: error && error.status ? error.status : 500
|
|
526
528
|
});
|
|
527
529
|
}
|
|
528
|
-
|
|
529
530
|
function* reduxInjectorSaga(injectorFn) {
|
|
530
531
|
if (typeof injectorFn === 'function') {
|
|
531
532
|
const {
|
|
@@ -533,7 +534,7 @@ function* reduxInjectorSaga(injectorFn) {
|
|
|
533
534
|
reducer,
|
|
534
535
|
saga
|
|
535
536
|
} = yield injectorFn();
|
|
536
|
-
version
|
|
537
|
+
version.injectRedux({
|
|
537
538
|
key,
|
|
538
539
|
reducer,
|
|
539
540
|
saga
|
|
@@ -541,20 +542,19 @@ function* reduxInjectorSaga(injectorFn) {
|
|
|
541
542
|
}
|
|
542
543
|
}
|
|
543
544
|
|
|
544
|
-
const registerSagas = [effects.takeEvery(
|
|
545
|
-
|
|
545
|
+
const registerSagas = [effects.takeEvery(selectors.REGISTER_USER, registerSaga), effects.takeEvery(selectors.REGISTER_USER_SUCCESS, redirectSaga)];
|
|
546
546
|
function* registerSaga({
|
|
547
547
|
user,
|
|
548
548
|
mappers
|
|
549
549
|
}) {
|
|
550
|
-
let requestBody = user;
|
|
550
|
+
let requestBody = user;
|
|
551
|
+
// Allow use of request mapper to take a user object
|
|
551
552
|
// of any format and return the payload for the api request
|
|
552
|
-
|
|
553
553
|
if (mappers && mappers.request && typeof mappers.request === 'function') {
|
|
554
554
|
requestBody = yield mappers.request(user);
|
|
555
|
-
}
|
|
556
|
-
|
|
555
|
+
}
|
|
557
556
|
|
|
557
|
+
// Make POST call to register API
|
|
558
558
|
const response = yield fetch('/account/register', {
|
|
559
559
|
method: 'POST',
|
|
560
560
|
headers: {
|
|
@@ -563,27 +563,24 @@ function* registerSaga({
|
|
|
563
563
|
},
|
|
564
564
|
body: JSON.stringify(requestBody)
|
|
565
565
|
});
|
|
566
|
-
|
|
567
566
|
if (response.ok) {
|
|
568
567
|
let mappedResponse;
|
|
569
568
|
const [, responseBody] = yield to.to(response.json());
|
|
570
|
-
|
|
571
569
|
if (responseBody) {
|
|
572
570
|
// Allow use of response mapper to convert the successful user object
|
|
573
571
|
// from the api response body into a user object of any format
|
|
574
572
|
if (mappers && mappers.response && typeof mappers.response === 'function') {
|
|
575
573
|
mappedResponse = yield mappers.response(responseBody);
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
|
|
574
|
+
}
|
|
575
|
+
// Update user object with mappedResponse or responseBody
|
|
579
576
|
yield effects.put({
|
|
580
|
-
type:
|
|
577
|
+
type: selectors.REGISTER_USER_SUCCESS,
|
|
581
578
|
user: mappedResponse || responseBody
|
|
582
579
|
});
|
|
583
580
|
} else {
|
|
584
581
|
// OK response but unable to parse the response body
|
|
585
582
|
yield effects.put({
|
|
586
|
-
type:
|
|
583
|
+
type: selectors.REGISTER_USER_FAILED,
|
|
587
584
|
error: {
|
|
588
585
|
message: 'Unable to parse the created user from the register service response'
|
|
589
586
|
}
|
|
@@ -594,25 +591,24 @@ function* registerSaga({
|
|
|
594
591
|
// or status codes echoed from the responses received from
|
|
595
592
|
// management api when registering the user
|
|
596
593
|
const [, errorResponse] = yield to.to(response.json());
|
|
597
|
-
const error = errorResponse && errorResponse.error || errorResponse || {};
|
|
598
|
-
|
|
594
|
+
const error = errorResponse && errorResponse.error || errorResponse || {};
|
|
595
|
+
// Get something meaningful from the response if there is no message in the body
|
|
599
596
|
if (!error.message) {
|
|
600
597
|
error.message = `Registration service: ${response.statusText}`;
|
|
601
598
|
error.status = response.status;
|
|
602
599
|
}
|
|
603
|
-
|
|
604
600
|
yield effects.put({
|
|
605
|
-
type:
|
|
601
|
+
type: selectors.REGISTER_USER_FAILED,
|
|
606
602
|
error
|
|
607
603
|
});
|
|
608
604
|
}
|
|
609
605
|
}
|
|
610
|
-
|
|
611
606
|
function* redirectSaga() {
|
|
612
607
|
// Check if querystring contains a redirect_uri
|
|
613
608
|
const currentQs = selectors.queryParams(yield effects.select(selectors.selectCurrentSearch));
|
|
614
|
-
const redirectUri = currentQs.redirect_uri || currentQs.redirect;
|
|
609
|
+
const redirectUri = currentQs.redirect_uri || currentQs.redirect;
|
|
615
610
|
|
|
611
|
+
// We must use redux based navigation to preserve the registration state
|
|
616
612
|
if (redirectUri) yield effects.put(selectors.setRoute(redirectUri));
|
|
617
613
|
}
|
|
618
614
|
|
|
@@ -630,36 +626,36 @@ const BASE_OPTIONS = {
|
|
|
630
626
|
};
|
|
631
627
|
class UserHelper {
|
|
632
628
|
static async GetUsersEnvironments(securityToken) {
|
|
633
|
-
const options = {
|
|
629
|
+
const options = {
|
|
630
|
+
...BASE_OPTIONS,
|
|
634
631
|
headers: {
|
|
635
632
|
'x-security-token': securityToken
|
|
636
633
|
}
|
|
637
634
|
};
|
|
638
635
|
return await UserHelper.get(USER_ENVS_URL, options);
|
|
639
636
|
}
|
|
640
|
-
|
|
641
637
|
static async ResendUserVerification(userEmail) {
|
|
642
|
-
const options = {
|
|
638
|
+
const options = {
|
|
639
|
+
...BASE_OPTIONS
|
|
643
640
|
};
|
|
644
641
|
return await UserHelper.get(`/${USER_RESEND_VERIFICATION_URI}?user=${userEmail}`, options);
|
|
645
642
|
}
|
|
646
|
-
|
|
647
643
|
static async RequestPasswordReset(userEmailObject) {
|
|
648
|
-
const options = {
|
|
644
|
+
const options = {
|
|
645
|
+
...BASE_OPTIONS,
|
|
649
646
|
body: JSON.stringify(userEmailObject)
|
|
650
647
|
};
|
|
651
648
|
options.method = 'POST';
|
|
652
649
|
return await UserHelper.get(`/${USER_REQUEST_PASSWORD_RESET_URI}`, options);
|
|
653
650
|
}
|
|
654
|
-
|
|
655
651
|
static async ResetPassword(resetPasswordObject) {
|
|
656
|
-
const options = {
|
|
652
|
+
const options = {
|
|
653
|
+
...BASE_OPTIONS,
|
|
657
654
|
body: JSON.stringify(resetPasswordObject)
|
|
658
655
|
};
|
|
659
656
|
options.method = 'POST';
|
|
660
657
|
return await UserHelper.get(`/${USER_RESET_PASSWORD_URI}`, options);
|
|
661
658
|
}
|
|
662
|
-
|
|
663
659
|
static async get(url, options = BASE_OPTIONS) {
|
|
664
660
|
try {
|
|
665
661
|
const responseBody = await api(url, options);
|
|
@@ -672,9 +668,7 @@ class UserHelper {
|
|
|
672
668
|
};
|
|
673
669
|
}
|
|
674
670
|
}
|
|
675
|
-
|
|
676
671
|
}
|
|
677
|
-
|
|
678
672
|
async function api(url, options) {
|
|
679
673
|
return fetch(url, options).then(async response => {
|
|
680
674
|
return response.json().then(data => data);
|
|
@@ -683,103 +677,96 @@ async function api(url, options) {
|
|
|
683
677
|
});
|
|
684
678
|
}
|
|
685
679
|
|
|
686
|
-
const resetPasswordSagas = [effects.takeEvery(
|
|
687
|
-
|
|
680
|
+
const resetPasswordSagas = [effects.takeEvery(selectors.REQUEST_USER_PASSWORD_RESET, requestPasswordResetSaga), effects.takeEvery(selectors.RESET_USER_PASSWORD, resetPasswordSaga), effects.takeEvery(selectors.CHANGE_USER_PASSWORD, changePasswordSaga)];
|
|
688
681
|
function* requestPasswordResetSaga(action) {
|
|
689
682
|
const userEmailObject = action.userEmailObject;
|
|
690
683
|
yield effects.put({
|
|
691
|
-
type:
|
|
684
|
+
type: selectors.REQUEST_USER_PASSWORD_RESET_SENDING
|
|
692
685
|
});
|
|
693
|
-
|
|
694
686
|
if (userEmailObject && userEmailObject.userEmail) {
|
|
695
687
|
try {
|
|
696
688
|
const passwordResetRequestResponse = yield UserHelper.RequestPasswordReset(userEmailObject);
|
|
697
|
-
|
|
698
689
|
if (passwordResetRequestResponse) {
|
|
699
690
|
if (!passwordResetRequestResponse.error) {
|
|
700
691
|
yield effects.put({
|
|
701
|
-
type:
|
|
692
|
+
type: selectors.REQUEST_USER_PASSWORD_RESET_SUCCESS
|
|
702
693
|
});
|
|
703
694
|
} else {
|
|
704
695
|
yield effects.put({
|
|
705
|
-
type:
|
|
696
|
+
type: selectors.REQUEST_USER_PASSWORD_RESET_ERROR,
|
|
706
697
|
error: passwordResetRequestResponse.error.message
|
|
707
698
|
});
|
|
708
699
|
}
|
|
709
700
|
} else {
|
|
710
701
|
yield effects.put({
|
|
711
|
-
type:
|
|
702
|
+
type: selectors.REQUEST_USER_PASSWORD_RESET_ERROR,
|
|
712
703
|
error: 'No response from server'
|
|
713
704
|
});
|
|
714
705
|
}
|
|
715
706
|
} catch (error) {
|
|
716
707
|
yield effects.put({
|
|
717
|
-
type:
|
|
708
|
+
type: selectors.REQUEST_USER_PASSWORD_RESET_ERROR,
|
|
718
709
|
error: error && error.toString()
|
|
719
710
|
});
|
|
720
711
|
}
|
|
721
712
|
} else {
|
|
722
713
|
yield effects.put({
|
|
723
|
-
type:
|
|
714
|
+
type: selectors.REQUEST_USER_PASSWORD_RESET_ERROR,
|
|
724
715
|
error: 'Invalid object'
|
|
725
716
|
});
|
|
726
717
|
}
|
|
727
718
|
}
|
|
728
|
-
|
|
729
719
|
function* resetPasswordSaga(action) {
|
|
730
720
|
const resetPasswordObject = action.resetPasswordObject;
|
|
731
721
|
yield effects.put({
|
|
732
|
-
type:
|
|
722
|
+
type: selectors.RESET_USER_PASSWORD_SENDING
|
|
733
723
|
});
|
|
734
|
-
|
|
735
724
|
if (resetPasswordObject.token && resetPasswordObject.password) {
|
|
736
725
|
try {
|
|
737
726
|
const resetPasswordResponse = yield UserHelper.ResetPassword(resetPasswordObject);
|
|
738
|
-
|
|
739
727
|
if (resetPasswordResponse) {
|
|
740
728
|
if (!resetPasswordResponse.error) {
|
|
741
729
|
yield effects.put({
|
|
742
|
-
type:
|
|
730
|
+
type: selectors.RESET_USER_PASSWORD_SUCCESS
|
|
743
731
|
});
|
|
744
732
|
} else {
|
|
745
733
|
const error = resetPasswordResponse.error.data && resetPasswordResponse.error.data.length > 0 && resetPasswordResponse.error.data[0].message || resetPasswordResponse.error.message;
|
|
746
734
|
yield effects.put({
|
|
747
|
-
type:
|
|
735
|
+
type: selectors.RESET_USER_PASSWORD_ERROR,
|
|
748
736
|
error
|
|
749
737
|
});
|
|
750
738
|
}
|
|
751
739
|
} else {
|
|
752
740
|
yield effects.put({
|
|
753
|
-
type:
|
|
741
|
+
type: selectors.RESET_USER_PASSWORD_ERROR,
|
|
754
742
|
error: 'No response from server'
|
|
755
743
|
});
|
|
756
744
|
}
|
|
757
745
|
} catch (error) {
|
|
758
746
|
yield effects.put({
|
|
759
|
-
type:
|
|
747
|
+
type: selectors.RESET_USER_PASSWORD_ERROR,
|
|
760
748
|
error: error && error.toString()
|
|
761
749
|
});
|
|
762
750
|
}
|
|
763
751
|
} else {
|
|
764
752
|
yield effects.put({
|
|
765
|
-
type:
|
|
753
|
+
type: selectors.RESET_USER_PASSWORD_ERROR,
|
|
766
754
|
error: 'Invalid object'
|
|
767
755
|
});
|
|
768
756
|
}
|
|
769
|
-
}
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
// userId
|
|
770
760
|
// existingPassword
|
|
771
761
|
// newPassword
|
|
772
|
-
|
|
773
|
-
|
|
774
762
|
function* changePasswordSaga(action) {
|
|
775
763
|
if (!action || !action.userId || !action.currentPassword || !action.newPassword) {
|
|
776
764
|
yield effects.put({
|
|
777
|
-
type:
|
|
765
|
+
type: selectors.CHANGE_USER_PASSWORD_ERROR,
|
|
778
766
|
error: 'Invalid action object sent to changePassword saga'
|
|
779
767
|
});
|
|
780
768
|
return;
|
|
781
769
|
}
|
|
782
|
-
|
|
783
770
|
try {
|
|
784
771
|
const changePasswordObject = {
|
|
785
772
|
userId: action.userId,
|
|
@@ -787,34 +774,33 @@ function* changePasswordSaga(action) {
|
|
|
787
774
|
new: action.newPassword
|
|
788
775
|
};
|
|
789
776
|
yield effects.put({
|
|
790
|
-
type:
|
|
777
|
+
type: selectors.CHANGE_USER_PASSWORD_SENDING
|
|
791
778
|
});
|
|
792
|
-
const clientCredentials = yield effects.select(
|
|
793
|
-
const client = yield ChangePassword_container.getManagementApiClient({
|
|
779
|
+
const clientCredentials = yield effects.select(matchGroups.selectClientCredentials, 'js');
|
|
780
|
+
const client = yield ChangePassword_container.getManagementApiClient({
|
|
781
|
+
...clientCredentials
|
|
794
782
|
});
|
|
795
783
|
const [err, res] = yield to.to(client.security.users.updatePassword(changePasswordObject));
|
|
796
|
-
|
|
797
784
|
if (err) {
|
|
798
|
-
var _err$data, _err$
|
|
799
|
-
|
|
800
|
-
const error = (err === null || err === void 0 ? void 0 : (_err$data = err.data) === null || _err$data === void 0 ? void 0 : (_err$data$data = _err$data.data) === null || _err$data$data === void 0 ? void 0 : _err$data$data.length) > 0 && err.data.data[0].message || (err === null || err === void 0 ? void 0 : (_err$data2 = err.data) === null || _err$data2 === void 0 ? void 0 : _err$data2.message);
|
|
785
|
+
var _err$data, _err$data2;
|
|
786
|
+
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);
|
|
801
787
|
yield effects.put({
|
|
802
|
-
type:
|
|
788
|
+
type: selectors.CHANGE_USER_PASSWORD_ERROR,
|
|
803
789
|
error
|
|
804
790
|
});
|
|
805
791
|
return;
|
|
806
|
-
}
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
// // eslint-disable-next-line no-console
|
|
807
795
|
// console.log(changePasswordObject);
|
|
808
796
|
// // eslint-disable-next-line no-console
|
|
809
797
|
// console.log(userCredentialsObject);
|
|
810
|
-
|
|
811
|
-
|
|
812
798
|
yield effects.put({
|
|
813
|
-
type:
|
|
799
|
+
type: selectors.CHANGE_USER_PASSWORD_SUCCESS
|
|
814
800
|
});
|
|
815
801
|
} catch (error) {
|
|
816
802
|
yield effects.put({
|
|
817
|
-
type:
|
|
803
|
+
type: selectors.CHANGE_USER_PASSWORD_ERROR,
|
|
818
804
|
error: error && error.toString()
|
|
819
805
|
});
|
|
820
806
|
}
|
|
@@ -830,35 +816,32 @@ function rootSaga (featureSagas = []) {
|
|
|
830
816
|
};
|
|
831
817
|
}
|
|
832
818
|
|
|
833
|
-
const servers = SERVERS;
|
|
834
|
-
/* global SERVERS */
|
|
835
|
-
|
|
819
|
+
const servers = SERVERS; /* global SERVERS */
|
|
836
820
|
const alias = servers.alias.toLowerCase();
|
|
837
|
-
const publicUri = PUBLIC_URI;
|
|
838
|
-
/* global
|
|
821
|
+
const publicUri = PUBLIC_URI; /* global PUBLIC_URI */
|
|
822
|
+
const projects = PROJECTS; /* global PROJECTS */
|
|
839
823
|
|
|
840
|
-
const projects = PROJECTS;
|
|
841
|
-
/* global PROJECTS */
|
|
842
824
|
// return a projectId via the request hostname
|
|
843
|
-
|
|
844
825
|
const pickProject = (hostname, query) => {
|
|
845
826
|
// if localhost we can only infer via a querystring, and take your word for it
|
|
846
827
|
if (hostname == 'localhost') {
|
|
847
828
|
return query && query.p || projects[0].id;
|
|
848
|
-
}
|
|
849
|
-
|
|
829
|
+
}
|
|
850
830
|
|
|
831
|
+
// if hostname is the actual public uri we can return the first project from the list
|
|
851
832
|
if (hostname == publicUri) {
|
|
852
833
|
return projects[0].id;
|
|
853
834
|
}
|
|
835
|
+
let project = 'unknown';
|
|
854
836
|
|
|
855
|
-
|
|
837
|
+
// // go through all the defined projects
|
|
856
838
|
// Object.entries(projects).map(([, p]) => {
|
|
839
|
+
const p = projects[0];
|
|
857
840
|
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
if (hostname.includes(p.publicUri)) project = p.id; // the url structure is different for website (we don't prefix)
|
|
841
|
+
// check if we're accessing via the project's public uri
|
|
842
|
+
if (hostname.includes(p.publicUri)) project = p.id;
|
|
861
843
|
|
|
844
|
+
// the url structure is different for website (we don't prefix)
|
|
862
845
|
if (p.id.startsWith('website')) {
|
|
863
846
|
// check for internal and external hostnames
|
|
864
847
|
// we check live and preview distinctly so our rule does not clash with
|
|
@@ -867,14 +850,13 @@ const pickProject = (hostname, query) => {
|
|
|
867
850
|
} else {
|
|
868
851
|
// check for internal and external hostnames, prefixed with the projectId
|
|
869
852
|
if (hostname.includes(`${p.id.toLowerCase()}-${alias}.cloud.contensis.com`) || hostname.includes(`${p.id.toLowerCase()}.${alias}.contensis.cloud`)) project = p.id;
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
|
|
853
|
+
}
|
|
854
|
+
// });
|
|
873
855
|
return project === 'unknown' ? p.id : project;
|
|
874
856
|
};
|
|
875
857
|
|
|
876
858
|
const AppRoot = props => {
|
|
877
|
-
return /*#__PURE__*/React__default
|
|
859
|
+
return /*#__PURE__*/React__default.default.createElement(RouteLoader.RouteLoader, props);
|
|
878
860
|
};
|
|
879
861
|
|
|
880
862
|
exports.AppRoot = AppRoot;
|
|
@@ -882,4 +864,4 @@ exports.browserHistory = browserHistory;
|
|
|
882
864
|
exports.history = history;
|
|
883
865
|
exports.pickProject = pickProject;
|
|
884
866
|
exports.rootSaga = rootSaga;
|
|
885
|
-
//# sourceMappingURL=App-
|
|
867
|
+
//# sourceMappingURL=App-C_1U2j24.js.map
|