@zengenti/contensis-react-base 3.0.2-beta.2 → 3.0.2-beta.21
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-ee485b92.js → App-21a7d836.js} +120 -432
- package/cjs/App-21a7d836.js.map +1 -0
- package/cjs/ContensisDeliveryApi-c079b03a.js +231 -0
- package/cjs/ContensisDeliveryApi-c079b03a.js.map +1 -0
- package/cjs/{RouteLoader-3aa6456e.js → RouteLoader-7f0d107a.js} +23 -37
- package/{esm/RouteLoader-5171c63f.js.map → cjs/RouteLoader-7f0d107a.js.map} +1 -1
- package/cjs/{ToJs-a9a8522b.js → ToJs-6e9cfa69.js} +3 -4
- package/cjs/{ToJs-a9a8522b.js.map → ToJs-6e9cfa69.js.map} +1 -1
- package/cjs/client.js +20 -27
- package/cjs/client.js.map +1 -1
- package/cjs/contensis-react-base.js +124 -188
- package/cjs/contensis-react-base.js.map +1 -1
- package/cjs/forms.js +1488 -272
- package/cjs/forms.js.map +1 -1
- package/cjs/{fromJSLeaveImmer-e74c673c.js → fromJSLeaveImmer-7c363211.js} +1 -4
- package/cjs/{fromJSLeaveImmer-e74c673c.js.map → fromJSLeaveImmer-7c363211.js.map} +1 -1
- package/cjs/{login-840860bc.js → login-2a6b5be0.js} +64 -113
- package/cjs/login-2a6b5be0.js.map +1 -0
- package/cjs/{reducers-3a4f8971.js → reducers-9afb5f89.js} +14 -31
- package/cjs/reducers-9afb5f89.js.map +1 -0
- package/cjs/redux.js +17 -17
- package/cjs/redux.js.map +1 -1
- package/cjs/routing.js +6 -7
- package/cjs/routing.js.map +1 -1
- package/cjs/{sagas-8a20e424.js → sagas-e04b94c1.js} +225 -301
- package/cjs/sagas-e04b94c1.js.map +1 -0
- package/cjs/search.js +68 -94
- package/cjs/search.js.map +1 -1
- package/cjs/{selectors-656da4b7.js → selectors-bcca60f4.js} +89 -8
- package/cjs/selectors-bcca60f4.js.map +1 -0
- package/cjs/urls-6fcaf4c6.js.map +1 -1
- package/cjs/user.js +4 -13
- package/cjs/user.js.map +1 -1
- package/cjs/util.js +45 -53
- package/cjs/util.js.map +1 -1
- package/cjs/{version-78dfc3bd.js → version-4077e706.js} +50 -159
- package/cjs/version-4077e706.js.map +1 -0
- package/cjs/version-fe28099e.js +98 -0
- package/cjs/version-fe28099e.js.map +1 -0
- package/esm/{App-640239d2.js → App-2af18a99.js} +102 -412
- package/esm/App-2af18a99.js.map +1 -0
- package/esm/ContensisDeliveryApi-5660ee0e.js +227 -0
- package/esm/ContensisDeliveryApi-5660ee0e.js.map +1 -0
- package/esm/{RouteLoader-5171c63f.js → RouteLoader-6eac364e.js} +22 -36
- package/{cjs/RouteLoader-3aa6456e.js.map → esm/RouteLoader-6eac364e.js.map} +1 -1
- package/esm/{ToJs-4e02a04d.js → ToJs-9b30636a.js} +3 -4
- package/esm/{ToJs-4e02a04d.js.map → ToJs-9b30636a.js.map} +1 -1
- package/esm/client.js +15 -22
- package/esm/client.js.map +1 -1
- package/esm/contensis-react-base.js +119 -183
- package/esm/contensis-react-base.js.map +1 -1
- package/esm/forms.js +1490 -274
- package/esm/forms.js.map +1 -1
- package/esm/{fromJSLeaveImmer-0114ffcf.js → fromJSLeaveImmer-e2dacd63.js} +1 -4
- package/esm/{fromJSLeaveImmer-0114ffcf.js.map → fromJSLeaveImmer-e2dacd63.js.map} +1 -1
- package/esm/{login-57395c9c.js → login-71ff3fcb.js} +63 -112
- package/esm/login-71ff3fcb.js.map +1 -0
- package/esm/{reducers-8e5d6232.js → reducers-3d5c37d1.js} +14 -31
- package/esm/reducers-3d5c37d1.js.map +1 -0
- package/esm/redux.js +9 -8
- package/esm/redux.js.map +1 -1
- package/esm/routing.js +3 -4
- package/esm/routing.js.map +1 -1
- package/esm/{sagas-e576b6f6.js → sagas-933a8fc8.js} +177 -254
- package/esm/sagas-933a8fc8.js.map +1 -0
- package/esm/search.js +69 -95
- package/esm/search.js.map +1 -1
- package/esm/{selectors-a5e5835b.js → selectors-74de49a3.js} +75 -8
- package/esm/selectors-74de49a3.js.map +1 -0
- package/esm/urls-eac9a747.js.map +1 -1
- package/esm/user.js +6 -15
- package/esm/user.js.map +1 -1
- package/esm/util.js +42 -53
- package/esm/util.js.map +1 -1
- package/esm/version-b15807c5.js +87 -0
- package/esm/version-b15807c5.js.map +1 -0
- package/esm/{version-e3a5ec66.js → version-ef107106.js} +37 -142
- package/esm/version-ef107106.js.map +1 -0
- package/models/redux/appstate.d.ts +1 -0
- package/models/routing/redux/selectors.d.ts +2 -1
- package/models/search/models/Queries.d.ts +2 -1
- package/models/search/models/Search.d.ts +2 -0
- package/models/search/models/SearchActions.d.ts +3 -3
- package/models/search/redux/actions.d.ts +6 -6
- package/models/search/redux/util.d.ts +1 -1
- package/models/search/search/expressions.d.ts +1 -1
- package/models/server/features/linkdepth-api/search.d.ts +1 -1
- package/models/util/ContensisDeliveryApi.d.ts +6 -0
- package/models/util/index.d.ts +1 -0
- package/package.json +1 -1
- package/cjs/App-ee485b92.js.map +0 -1
- package/cjs/actions-8dc9e8de.js +0 -87
- package/cjs/actions-8dc9e8de.js.map +0 -1
- package/cjs/login-840860bc.js.map +0 -1
- package/cjs/reducers-3a4f8971.js.map +0 -1
- package/cjs/sagas-8a20e424.js.map +0 -1
- package/cjs/selectors-656da4b7.js.map +0 -1
- package/cjs/version-78dfc3bd.js.map +0 -1
- package/cjs/version-eba6d09b.js +0 -20
- package/cjs/version-eba6d09b.js.map +0 -1
- package/esm/App-640239d2.js.map +0 -1
- package/esm/actions-180948dd.js +0 -72
- package/esm/actions-180948dd.js.map +0 -1
- package/esm/login-57395c9c.js.map +0 -1
- package/esm/reducers-8e5d6232.js.map +0 -1
- package/esm/sagas-e576b6f6.js.map +0 -1
- package/esm/selectors-a5e5835b.js.map +0 -1
- package/esm/version-2485e2fb.js +0 -15
- package/esm/version-2485e2fb.js.map +0 -1
- package/esm/version-e3a5ec66.js.map +0 -1
|
@@ -1,294 +1,22 @@
|
|
|
1
1
|
import { createBrowserHistory, createMemoryHistory } from 'history';
|
|
2
2
|
import { takeEvery, select, put, call, all } from '@redux-saga/core/effects';
|
|
3
3
|
import * as log from 'loglevel';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { f as findContentTypeMapping, h as handleRequiresLoginSaga, g as getManagementApiClient, l as loginSagas } from './login-57395c9c.js';
|
|
4
|
+
import { d as deliveryApi, c as cachedSearch } from './ContensisDeliveryApi-5660ee0e.js';
|
|
5
|
+
import { G as GET_NODE_TREE, s as selectVersionStatus, S as SET_NODE_TREE, a as GET_NODE_TREE_ERROR } from './version-ef107106.js';
|
|
6
|
+
import { h as hasNavigationTree, i as injectRedux } from './version-b15807c5.js';
|
|
7
|
+
import { b as selectCurrentProject, S as SET_NAVIGATION_PATH, d as SET_ROUTE, a as selectRouteEntry, e as selectCurrentNode, U as UPDATE_LOADING_STATE, f as selectCurrentAncestors, h as selectCurrentSiblings, i as selectRouteEntryEntryId, j as selectRouteEntryLanguage, k as selectMappedEntry, l as SET_ENTRY, m as SET_ANCESTORS, n as SET_SIBLINGS, q as queryParams, o as selectCurrentSearch, p as setRoute } from './selectors-74de49a3.js';
|
|
8
|
+
import { f as findContentTypeMapping, h as handleRequiresLoginSaga, g as getManagementApiClient, l as loginSagas } from './login-71ff3fcb.js';
|
|
9
|
+
import { Op, Query } from 'contensis-delivery-api';
|
|
11
10
|
import { to } from 'await-to-js';
|
|
12
|
-
import { R as REGISTER_USER, a as REGISTER_USER_SUCCESS, b as REGISTER_USER_FAILED, c as REQUEST_USER_PASSWORD_RESET, d as RESET_USER_PASSWORD, C as CHANGE_USER_PASSWORD, e as REQUEST_USER_PASSWORD_RESET_SENDING, f as REQUEST_USER_PASSWORD_RESET_SUCCESS, g as REQUEST_USER_PASSWORD_RESET_ERROR, h as RESET_USER_PASSWORD_SENDING, i as RESET_USER_PASSWORD_SUCCESS, j as RESET_USER_PASSWORD_ERROR, k as CHANGE_USER_PASSWORD_ERROR, l as CHANGE_USER_PASSWORD_SENDING, m as CHANGE_USER_PASSWORD_SUCCESS } from './reducers-
|
|
13
|
-
import { s as selectClientCredentials } from './ToJs-
|
|
11
|
+
import { R as REGISTER_USER, a as REGISTER_USER_SUCCESS, b as REGISTER_USER_FAILED, c as REQUEST_USER_PASSWORD_RESET, d as RESET_USER_PASSWORD, C as CHANGE_USER_PASSWORD, e as REQUEST_USER_PASSWORD_RESET_SENDING, f as REQUEST_USER_PASSWORD_RESET_SUCCESS, g as REQUEST_USER_PASSWORD_RESET_ERROR, h as RESET_USER_PASSWORD_SENDING, i as RESET_USER_PASSWORD_SUCCESS, j as RESET_USER_PASSWORD_ERROR, k as CHANGE_USER_PASSWORD_ERROR, l as CHANGE_USER_PASSWORD_SENDING, m as CHANGE_USER_PASSWORD_SUCCESS } from './reducers-3d5c37d1.js';
|
|
12
|
+
import { s as selectClientCredentials } from './ToJs-9b30636a.js';
|
|
14
13
|
import React from 'react';
|
|
15
14
|
import 'react-hot-loader';
|
|
16
15
|
import 'jsonpath-mapper';
|
|
17
|
-
import
|
|
18
|
-
|
|
19
|
-
const storeSurrogateKeys = response => {
|
|
20
|
-
const keys = response.headers.get ? response.headers.get('surrogate-key') : response.headers.map['surrogate-key'];
|
|
21
|
-
if (keys) reduxStore === null || reduxStore === void 0 ? void 0 : reduxStore.dispatch(setSurrogateKeys(keys, response.url));
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const getClientConfig = project => {
|
|
25
|
-
let config = DELIVERY_API_CONFIG;
|
|
26
|
-
/* global DELIVERY_API_CONFIG */
|
|
27
|
-
|
|
28
|
-
config.responseHandler = {};
|
|
29
|
-
|
|
30
|
-
if (project) {
|
|
31
|
-
config.projectId = project;
|
|
32
|
-
} // we only want the surrogate key header in a server context
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (typeof window === 'undefined') {
|
|
36
|
-
config.defaultHeaders = {
|
|
37
|
-
'x-require-surrogate-key': true
|
|
38
|
-
};
|
|
39
|
-
config.responseHandler[200] = storeSurrogateKeys;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (typeof window !== 'undefined' && PROXY_DELIVERY_API
|
|
43
|
-
/* global PROXY_DELIVERY_API */
|
|
44
|
-
) {
|
|
45
|
-
// ensure a relative url is used to bypass the need for CORS (separate OPTIONS calls)
|
|
46
|
-
config.rootUrl = '';
|
|
47
|
-
|
|
48
|
-
config.responseHandler[404] = () => null;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return config;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
class DeliveryApi {
|
|
55
|
-
constructor() {
|
|
56
|
-
this.getClientSideVersionStatus = () => {
|
|
57
|
-
if (typeof window !== 'undefined') {
|
|
58
|
-
// Allow overriding versionStatus with the querystring
|
|
59
|
-
const {
|
|
60
|
-
versionStatus
|
|
61
|
-
} = parse(window.location.search);
|
|
62
|
-
if (versionStatus) return versionStatus; // Client-side we will have a global variable set if rendered by SSR in production
|
|
63
|
-
|
|
64
|
-
if (typeof window.versionStatus !== 'undefined') return window.versionStatus; // For localhost development we can only work out versionStatus from the current hostname
|
|
65
|
-
|
|
66
|
-
const currentHostname = window.location.hostname;
|
|
67
|
-
return this.getVersionStatusFromHostname(currentHostname);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return null;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
this.getServerSideVersionStatus = request => request.query.versionStatus || deliveryApi.getVersionStatusFromHeaders(request.headers) || deliveryApi.getVersionStatusFromHostname(request.hostname);
|
|
74
|
-
|
|
75
|
-
this.getVersionStatusFromHeaders = headers => {
|
|
76
|
-
const versionStatusHeader = headers['x-entry-versionstatus'];
|
|
77
|
-
if (typeof versionStatusHeader !== 'undefined') return versionStatusHeader;
|
|
78
|
-
return null;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
this.getVersionStatusFromHostname = currentHostname => {
|
|
82
|
-
if (currentHostname.indexOf('localhost') > -1) return 'latest';
|
|
83
|
-
|
|
84
|
-
if (currentHostname.endsWith('contensis.cloud')) {
|
|
85
|
-
if (currentHostname.indexOf('preview.') > -1) {
|
|
86
|
-
return 'latest';
|
|
87
|
-
} else {
|
|
88
|
-
return 'published';
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (currentHostname.endsWith('cloud.contensis.com')) {
|
|
93
|
-
if (currentHostname.indexOf('preview-') > -1) {
|
|
94
|
-
return 'latest';
|
|
95
|
-
} else {
|
|
96
|
-
return 'published';
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return 'published';
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
this.search = (query, linkDepth, project, env) => {
|
|
104
|
-
const client = Client.create(getClientConfig(project));
|
|
105
|
-
return client.entries.search(query, typeof linkDepth !== 'undefined' ? linkDepth : 1);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
this.getClient = (deliveryApiStatus = 'published', project, env) => {
|
|
109
|
-
const baseConfig = getClientConfig(project);
|
|
110
|
-
baseConfig.versionStatus = deliveryApiStatus;
|
|
111
|
-
return Client.create(baseConfig);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
this.getEntry = (id, linkDepth = 0, deliveryApiStatus = 'published', project, env) => {
|
|
115
|
-
const baseConfig = getClientConfig(project);
|
|
116
|
-
baseConfig.versionStatus = deliveryApiStatus;
|
|
117
|
-
const client = Client.create(baseConfig); // return client.entries.get(id, linkDepth);
|
|
118
|
-
|
|
119
|
-
return client.entries.get({
|
|
120
|
-
id,
|
|
121
|
-
linkDepth
|
|
122
|
-
});
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const deliveryApi = new DeliveryApi();
|
|
129
|
-
|
|
130
|
-
class CacheNode {
|
|
131
|
-
constructor(key, value) {
|
|
132
|
-
this.key = key;
|
|
133
|
-
this.value = value;
|
|
134
|
-
this.next = null;
|
|
135
|
-
this.prev = null;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
class LruCache {
|
|
141
|
-
constructor(limit = 100) {
|
|
142
|
-
this.map = {};
|
|
143
|
-
this.head = null;
|
|
144
|
-
this.tail = null;
|
|
145
|
-
this.limit = limit || 100;
|
|
146
|
-
this.size = 0;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
get(key) {
|
|
150
|
-
if (this.map[key]) {
|
|
151
|
-
let value = this.map[key].value;
|
|
152
|
-
let node = new CacheNode(key, value);
|
|
153
|
-
this.remove(key);
|
|
154
|
-
this.setHead(node);
|
|
155
|
-
return value;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
set(key, value) {
|
|
160
|
-
let node = new CacheNode(key, value);
|
|
161
|
-
|
|
162
|
-
if (this.map[key]) {
|
|
163
|
-
this.remove(key);
|
|
164
|
-
} else {
|
|
165
|
-
if (this.size >= this.limit) {
|
|
166
|
-
delete this.map[this.tail.key];
|
|
167
|
-
this.size--;
|
|
168
|
-
this.tail = this.tail.prev;
|
|
169
|
-
this.tail.next = null;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
this.setHead(node);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
setHead(node) {
|
|
177
|
-
node.next = this.head;
|
|
178
|
-
node.prev = null;
|
|
179
|
-
|
|
180
|
-
if (this.head) {
|
|
181
|
-
this.head.prev = node;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
this.head = node;
|
|
185
|
-
|
|
186
|
-
if (!this.tail) {
|
|
187
|
-
this.tail = node;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
this.size++;
|
|
191
|
-
this.map[node.key] = node;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
remove(key) {
|
|
195
|
-
let node = this.map[key];
|
|
196
|
-
if (!node) return; // This is sometimes null and crashes the container without this check
|
|
197
|
-
|
|
198
|
-
if (node.prev) {
|
|
199
|
-
node.prev.next = node.next;
|
|
200
|
-
} else {
|
|
201
|
-
this.head = node.next;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
if (node.next) {
|
|
205
|
-
node.next.prev = node.prev;
|
|
206
|
-
} else {
|
|
207
|
-
this.tail = node.prev;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
delete this.map[key];
|
|
211
|
-
this.size--;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
class CachedSearch {
|
|
217
|
-
constructor() {
|
|
218
|
-
this.cache = new LruCache();
|
|
219
|
-
this.taxonomyLookup = {};
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
search(query, linkDepth, project, env) {
|
|
223
|
-
const client = Client.create(getClientConfig(project));
|
|
224
|
-
return this.request(project + JSON.stringify(query) + linkDepth.toString(), () => client.entries.search(query, linkDepth));
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
searchUsingPost(query, linkDepth = 0, project = '', env) {
|
|
228
|
-
const client = Client.create(getClientConfig(project));
|
|
229
|
-
return this.request(project + JSON.stringify(query) + linkDepth.toString(), () => client.entries.searchUsingPost(query, linkDepth));
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
get(id, linkDepth, versionStatus, project, env) {
|
|
233
|
-
const client = Client.create(getClientConfig(project));
|
|
234
|
-
client.clientConfig.versionStatus = versionStatus;
|
|
235
|
-
return this.request(id, () => client.entries.get({
|
|
236
|
-
id,
|
|
237
|
-
linkDepth
|
|
238
|
-
}));
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
getContentType(id, project, env) {
|
|
242
|
-
const client = Client.create(getClientConfig(project));
|
|
243
|
-
return this.request(`[CONTENT TYPE] ${id} ${project}`, () => client.contentTypes.get(id));
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
getTaxonomyNode(key, project, env) {
|
|
247
|
-
const client = Client.create(getClientConfig(project));
|
|
248
|
-
return this.request(`[TAXONOMY NODE] ${key}`, () => client.taxonomy.resolveChildren(key).then(node => this.extendTaxonomyNode(node)));
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
getRootNode(options, project, env) {
|
|
252
|
-
const client = Client.create(getClientConfig(project));
|
|
253
|
-
return this.request(`${project} / ${JSON.stringify(options)}`, () => client.nodes.getRoot(options));
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
getNode(options, project, env) {
|
|
257
|
-
const client = Client.create(getClientConfig(project));
|
|
258
|
-
return this.request(`${project} ${options && options.path || options} ${JSON.stringify(options)}`, () => client.nodes.get(options));
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
getAncestors(options, project, env) {
|
|
262
|
-
const client = Client.create(getClientConfig(project));
|
|
263
|
-
return this.request(`${project} [A] ${options && options.id || options} ${JSON.stringify(options)}`, () => client.nodes.getAncestors(options));
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
getChildren(options, project, env) {
|
|
267
|
-
const client = Client.create(getClientConfig(project));
|
|
268
|
-
return this.request(`${project} [C] ${options && options.id || options} ${JSON.stringify(options)}`, () => client.nodes.getChildren(options));
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
getSiblings(options, project, env) {
|
|
272
|
-
const client = Client.create(getClientConfig(project));
|
|
273
|
-
return this.request(`${project} [S] ${options && options.id || options} ${JSON.stringify(options)}`, () => client.nodes.getSiblings(options));
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
request(key, execute) {
|
|
277
|
-
if (!this.cache.get(key) || typeof window == 'undefined') {
|
|
278
|
-
let promise = execute();
|
|
279
|
-
this.cache.set(key, promise);
|
|
280
|
-
promise.catch(() => {
|
|
281
|
-
this.cache.remove(key);
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
return this.cache.get(key);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
const cachedSearch = new CachedSearch();
|
|
16
|
+
import 'query-string';
|
|
17
|
+
import { R as RouteLoader } from './RouteLoader-6eac364e.js';
|
|
291
18
|
|
|
19
|
+
// Create a history depending on the environment
|
|
292
20
|
const selectedHistory = typeof window !== 'undefined' ? createBrowserHistory : createMemoryHistory;
|
|
293
21
|
const history = (options = {}) => selectedHistory(options);
|
|
294
22
|
const browserHistory = selectedHistory();
|
|
@@ -296,15 +24,14 @@ const browserHistory = selectedHistory();
|
|
|
296
24
|
const navigationSagas = [takeEvery(GET_NODE_TREE, ensureNodeTreeSaga)];
|
|
297
25
|
function* ensureNodeTreeSaga(action) {
|
|
298
26
|
const state = yield select();
|
|
299
|
-
|
|
300
27
|
try {
|
|
301
28
|
if (!hasNavigationTree(state)) {
|
|
302
29
|
const deliveryApiVersionStatus = yield select(selectVersionStatus);
|
|
303
30
|
const project = yield select(selectCurrentProject);
|
|
304
31
|
const nodes = yield deliveryApi.getClient(deliveryApiVersionStatus, project).nodes.getRoot({
|
|
305
|
-
depth: action.treeDepth || 0
|
|
32
|
+
depth: action.treeDepth || 0,
|
|
33
|
+
language: action.language
|
|
306
34
|
});
|
|
307
|
-
|
|
308
35
|
if (nodes) {
|
|
309
36
|
yield put({
|
|
310
37
|
type: SET_NODE_TREE,
|
|
@@ -351,7 +78,6 @@ const fieldExpression = (field, value, operator = 'equalTo', weight = null) => {
|
|
|
351
78
|
const defaultExpressions = versionStatus => {
|
|
352
79
|
return [Op.equalTo(Fields.sys.versionStatus, versionStatus)];
|
|
353
80
|
};
|
|
354
|
-
|
|
355
81
|
const equalToOrIn = (field, arr, operator = 'equalTo') => arr.length === 0 ? [] : arr.length === 1 ? [Op[operator](field, arr[0])] : [Op.in(field, ...arr)];
|
|
356
82
|
|
|
357
83
|
const routeEntryByFieldsQuery = (id, language = 'en-GB', fields = [], versionStatus = 'published') => {
|
|
@@ -361,11 +87,11 @@ const routeEntryByFieldsQuery = (id, language = 'en-GB', fields = [], versionSta
|
|
|
361
87
|
};
|
|
362
88
|
|
|
363
89
|
const routingSagas = [takeEvery(SET_NAVIGATION_PATH, getRouteSaga), takeEvery(SET_ROUTE, setRouteSaga)];
|
|
90
|
+
|
|
364
91
|
/**
|
|
365
92
|
* To navigate / push a specific route via redux middleware
|
|
366
93
|
* @param {path, state} action
|
|
367
94
|
*/
|
|
368
|
-
|
|
369
95
|
function* setRouteSaga(action) {
|
|
370
96
|
yield put({
|
|
371
97
|
type: 'CALL_HISTORY_METHOD',
|
|
@@ -375,37 +101,35 @@ function* setRouteSaga(action) {
|
|
|
375
101
|
}
|
|
376
102
|
});
|
|
377
103
|
}
|
|
378
|
-
|
|
379
104
|
function* getRouteSaga(action) {
|
|
380
105
|
let entry = null;
|
|
381
|
-
|
|
382
106
|
try {
|
|
383
107
|
var _staticRoute$route, _staticRoute$route$pa, _staticRoute$route2, _staticRoute$route2$p, _pathNode2, _pathNode2$entry, _pathNode2$entry$sys, _pathNode3, _pathNode3$entry, _pathNode3$entry$sys;
|
|
384
|
-
|
|
385
108
|
const {
|
|
386
109
|
withEvents,
|
|
387
110
|
routes: {
|
|
388
111
|
ContentTypeMappings = {}
|
|
389
112
|
} = {},
|
|
390
113
|
staticRoute
|
|
391
|
-
} = action;
|
|
114
|
+
} = action;
|
|
392
115
|
|
|
393
|
-
|
|
116
|
+
// Inject redux { key, reducer, saga } provided by staticRoute
|
|
117
|
+
if (staticRoute && staticRoute.route.injectRedux) yield call(reduxInjectorSaga, staticRoute.route.injectRedux);
|
|
394
118
|
|
|
119
|
+
// Variables we will pass to setRouteEntry
|
|
395
120
|
let pathNode = null,
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
let contentTypeMapping = {};
|
|
400
|
-
// calls to withEvents.onRouteLoad and onRouteLoaded
|
|
121
|
+
ancestors = null,
|
|
122
|
+
children = [],
|
|
123
|
+
siblings = null;
|
|
124
|
+
let contentTypeMapping = {};
|
|
401
125
|
|
|
126
|
+
// These variables are the return values from
|
|
127
|
+
// calls to withEvents.onRouteLoad and onRouteLoaded
|
|
402
128
|
let appsays,
|
|
403
|
-
|
|
404
|
-
|
|
129
|
+
requireLogin = false;
|
|
405
130
|
if (withEvents && withEvents.onRouteLoad) {
|
|
406
131
|
appsays = yield withEvents.onRouteLoad(action);
|
|
407
132
|
}
|
|
408
|
-
|
|
409
133
|
const staticRouteLinkDepth = staticRoute === null || staticRoute === void 0 ? void 0 : (_staticRoute$route = staticRoute.route) === null || _staticRoute$route === void 0 ? void 0 : (_staticRoute$route$pa = _staticRoute$route.params) === null || _staticRoute$route$pa === void 0 ? void 0 : _staticRoute$route$pa.linkDepth;
|
|
410
134
|
const staticRouteFields = staticRoute === null || staticRoute === void 0 ? void 0 : (_staticRoute$route2 = staticRoute.route) === null || _staticRoute$route2 === void 0 ? void 0 : (_staticRoute$route2$p = _staticRoute$route2.params) === null || _staticRoute$route2$p === void 0 ? void 0 : _staticRoute$route2$p.fields;
|
|
411
135
|
const entryLinkDepth = appsays && appsays.entryLinkDepth !== undefined ? appsays.entryLinkDepth : 2;
|
|
@@ -414,46 +138,45 @@ function* getRouteSaga(action) {
|
|
|
414
138
|
const routeEntry = selectRouteEntry(state, 'js');
|
|
415
139
|
const routeNode = selectCurrentNode(state, 'js');
|
|
416
140
|
const currentPath = action.path; //selectCurrentPath(state);
|
|
417
|
-
|
|
418
141
|
const deliveryApiStatus = selectVersionStatus(state);
|
|
419
|
-
const project = selectCurrentProject(state);
|
|
420
|
-
|
|
142
|
+
const project = selectCurrentProject(state);
|
|
143
|
+
// const isHome = currentPath === '/';
|
|
421
144
|
const isPreview = currentPath && currentPath.startsWith('/preview/');
|
|
422
145
|
const defaultLang = appsays && appsays.defaultLang || 'en-GB';
|
|
423
|
-
|
|
424
146
|
if (!isPreview && (appsays && appsays.customRouting || staticRoute && !staticRoute.route.fetchNode || routeEntry && action.statePath === action.path && (appsays && appsays.refetchNode) !== true)) {
|
|
425
147
|
// To prevent erroneous 404s and wasted network calls, this covers
|
|
426
148
|
// - appsays customRouting and does SET_ENTRY etc. via the consuming app
|
|
427
149
|
// - all staticRoutes (where custom 'route.fetchNode' attribute is falsey)
|
|
428
150
|
// - standard Contensis SiteView Routing where we already have that entry in state
|
|
429
151
|
if (routeEntry && (!staticRoute || staticRoute.route && staticRoute.route.fetchNode)) {
|
|
430
|
-
pathNode = {
|
|
152
|
+
pathNode = {
|
|
153
|
+
...routeNode,
|
|
431
154
|
entry: null
|
|
432
155
|
};
|
|
433
|
-
pathNode.entry = entry = routeEntry;
|
|
156
|
+
pathNode.entry = entry = routeEntry;
|
|
157
|
+
//Do nothing, the entry is allready the right one.
|
|
434
158
|
// yield put({
|
|
435
159
|
// type: SET_ENTRY,
|
|
436
160
|
// entry,
|
|
437
161
|
// node: routeNode,
|
|
438
162
|
// isLoading: false,
|
|
439
163
|
// });
|
|
440
|
-
|
|
441
164
|
yield put({
|
|
442
165
|
type: UPDATE_LOADING_STATE,
|
|
443
166
|
isLoading: false
|
|
444
167
|
});
|
|
445
|
-
} else yield call(setRouteEntry, routeEntry, yield select(selectCurrentNode), yield select(selectCurrentAncestors), yield select(selectCurrentSiblings));
|
|
168
|
+
} else yield call(setRouteEntry, currentPath, routeEntry, yield select(selectCurrentNode), yield select(selectCurrentAncestors), yield select(selectCurrentSiblings));
|
|
446
169
|
} else {
|
|
447
170
|
// Handle preview routes
|
|
448
171
|
if (isPreview) {
|
|
449
172
|
let splitPath = currentPath.split('/');
|
|
450
173
|
let entryGuid = splitPath[2];
|
|
451
174
|
let language = defaultLang;
|
|
452
|
-
|
|
453
175
|
if (splitPath.length >= 3) {
|
|
454
176
|
//set lang key if available in the path, else use default lang
|
|
455
177
|
//assumes preview url on content type is: http://preview.ALIAS.contensis.cloud/preview/{GUID}/{LANG}
|
|
456
|
-
if (splitPath.length == 4) language = splitPath[3];
|
|
178
|
+
if (splitPath.length == 4) language = splitPath[3];
|
|
179
|
+
// According to product dev we cannot use Node API
|
|
457
180
|
// for previewing entries as it gives a response of []
|
|
458
181
|
// -- apparently it is not correct to request latest content
|
|
459
182
|
// with Node API
|
|
@@ -463,7 +186,6 @@ function* getRouteSaga(action) {
|
|
|
463
186
|
language,
|
|
464
187
|
linkDepth: entryLinkDepth
|
|
465
188
|
});
|
|
466
|
-
|
|
467
189
|
if (previewEntry) {
|
|
468
190
|
pathNode = {
|
|
469
191
|
entry: previewEntry
|
|
@@ -475,7 +197,6 @@ function* getRouteSaga(action) {
|
|
|
475
197
|
}
|
|
476
198
|
} else {
|
|
477
199
|
var _pathNode, _pathNode$entry, _pathNode$entry$sys;
|
|
478
|
-
|
|
479
200
|
// Handle all other routes
|
|
480
201
|
pathNode = yield cachedSearch.getNode({
|
|
481
202
|
depth: 0,
|
|
@@ -488,10 +209,8 @@ function* getRouteSaga(action) {
|
|
|
488
209
|
({
|
|
489
210
|
entry
|
|
490
211
|
} = pathNode || {});
|
|
491
|
-
|
|
492
212
|
if (setContentTypeLimits && (_pathNode = pathNode) !== null && _pathNode !== void 0 && (_pathNode$entry = _pathNode.entry) !== null && _pathNode$entry !== void 0 && (_pathNode$entry$sys = _pathNode$entry.sys) !== null && _pathNode$entry$sys !== void 0 && _pathNode$entry$sys.id) {
|
|
493
213
|
var _payload$items;
|
|
494
|
-
|
|
495
214
|
// Get fields[] and linkDepth from ContentTypeMapping to get the entry data
|
|
496
215
|
// and current node's ordinates at a specified depth with specified fields
|
|
497
216
|
contentTypeMapping = findContentTypeMapping(ContentTypeMappings, pathNode.entry.sys.contentTypeId) || {};
|
|
@@ -501,15 +220,14 @@ function* getRouteSaga(action) {
|
|
|
501
220
|
} = contentTypeMapping;
|
|
502
221
|
const query = routeEntryByFieldsQuery(pathNode.entry.sys.id, pathNode.entry.sys.language, fields, deliveryApiStatus);
|
|
503
222
|
const payload = yield cachedSearch.search(query, typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth || 0, project);
|
|
504
|
-
|
|
505
223
|
if ((payload === null || payload === void 0 ? void 0 : (_payload$items = payload.items) === null || _payload$items === void 0 ? void 0 : _payload$items.length) > 0) {
|
|
506
224
|
pathNode.entry = entry = payload.items[0];
|
|
507
225
|
}
|
|
508
226
|
}
|
|
509
|
-
}
|
|
510
|
-
// siblings or entire node tree
|
|
511
|
-
|
|
227
|
+
}
|
|
512
228
|
|
|
229
|
+
// make calls to fetch node ancestors, children,
|
|
230
|
+
// siblings or entire node tree
|
|
513
231
|
[ancestors, children, siblings] = yield call(resolveCurrentNodeOrdinates, {
|
|
514
232
|
appsays,
|
|
515
233
|
contentTypeMapping,
|
|
@@ -521,48 +239,44 @@ function* getRouteSaga(action) {
|
|
|
521
239
|
});
|
|
522
240
|
if (children) pathNode.children = children;
|
|
523
241
|
}
|
|
242
|
+
const resolvedContentTypeMapping = findContentTypeMapping(ContentTypeMappings, (_pathNode2 = pathNode) === null || _pathNode2 === void 0 ? void 0 : (_pathNode2$entry = _pathNode2.entry) === null || _pathNode2$entry === void 0 ? void 0 : (_pathNode2$entry$sys = _pathNode2$entry.sys) === null || _pathNode2$entry$sys === void 0 ? void 0 : _pathNode2$entry$sys.contentTypeId) || {};
|
|
524
243
|
|
|
525
|
-
|
|
526
|
-
|
|
244
|
+
// Inject redux { key, reducer, saga } provided by ContentTypeMapping
|
|
527
245
|
if (resolvedContentTypeMapping.injectRedux) yield call(reduxInjectorSaga, resolvedContentTypeMapping.injectRedux);
|
|
528
|
-
|
|
529
246
|
if (withEvents && withEvents.onRouteLoaded) {
|
|
530
247
|
// Check if the app has provided a requireLogin boolean flag or groups array
|
|
531
248
|
// in addition to checking if requireLogin is set in the route definition
|
|
532
249
|
({
|
|
533
250
|
requireLogin
|
|
534
|
-
} = (yield withEvents.onRouteLoaded({
|
|
251
|
+
} = (yield withEvents.onRouteLoaded({
|
|
252
|
+
...action,
|
|
535
253
|
entry
|
|
536
254
|
})) || {});
|
|
537
255
|
}
|
|
538
|
-
|
|
539
256
|
if (requireLogin !== false) {
|
|
540
257
|
// Do not call the login feature saga if requireLogin is false
|
|
541
|
-
yield call(handleRequiresLoginSaga, {
|
|
258
|
+
yield call(handleRequiresLoginSaga, {
|
|
259
|
+
...action,
|
|
542
260
|
entry,
|
|
543
261
|
requireLogin
|
|
544
262
|
});
|
|
545
263
|
}
|
|
546
|
-
|
|
547
264
|
if (!appsays || !appsays.preventScrollTop) {
|
|
548
265
|
// Scroll into View
|
|
549
266
|
if (typeof window !== 'undefined') window.scrollTo(0, 0);
|
|
550
267
|
}
|
|
551
|
-
|
|
552
268
|
if ((_pathNode3 = pathNode) !== null && _pathNode3 !== void 0 && (_pathNode3$entry = _pathNode3.entry) !== null && _pathNode3$entry !== void 0 && (_pathNode3$entry$sys = _pathNode3$entry.sys) !== null && _pathNode3$entry$sys !== void 0 && _pathNode3$entry$sys.id) {
|
|
553
269
|
var _staticRoute$route3, _staticRoute$route3$f, _appsays;
|
|
554
|
-
|
|
555
270
|
entry = pathNode.entry;
|
|
556
|
-
yield call(setRouteEntry, entry, pathNode, ancestors, siblings, (staticRoute === null || staticRoute === void 0 ? void 0 : (_staticRoute$route3 = staticRoute.route) === null || _staticRoute$route3 === void 0 ? void 0 : (_staticRoute$route3$f = _staticRoute$route3.fetchNode) === null || _staticRoute$route3$f === void 0 ? void 0 : _staticRoute$route3$f.entryMapper) || resolvedContentTypeMapping.entryMapper, false, (_appsays = appsays) === null || _appsays === void 0 ? void 0 : _appsays.refetchNode);
|
|
271
|
+
yield call(setRouteEntry, currentPath, entry, pathNode, ancestors, siblings, (staticRoute === null || staticRoute === void 0 ? void 0 : (_staticRoute$route3 = staticRoute.route) === null || _staticRoute$route3 === void 0 ? void 0 : (_staticRoute$route3$f = _staticRoute$route3.fetchNode) === null || _staticRoute$route3$f === void 0 ? void 0 : _staticRoute$route3$f.entryMapper) || resolvedContentTypeMapping.entryMapper, false, (_appsays = appsays) === null || _appsays === void 0 ? void 0 : _appsays.refetchNode);
|
|
557
272
|
} else {
|
|
558
|
-
if (staticRoute) yield call(setRouteEntry, null, pathNode, ancestors, siblings);else yield call(do404);
|
|
273
|
+
if (staticRoute) yield call(setRouteEntry, currentPath, null, pathNode, ancestors, siblings);else yield call(do404);
|
|
559
274
|
}
|
|
560
275
|
} catch (e) {
|
|
561
276
|
log.error(...['Error running route saga:', e, e.stack]);
|
|
562
277
|
yield call(do500, e);
|
|
563
278
|
}
|
|
564
279
|
}
|
|
565
|
-
|
|
566
280
|
function* resolveCurrentNodeOrdinates({
|
|
567
281
|
appsays,
|
|
568
282
|
contentTypeMapping,
|
|
@@ -572,10 +286,11 @@ function* resolveCurrentNodeOrdinates({
|
|
|
572
286
|
project,
|
|
573
287
|
versionStatus
|
|
574
288
|
}) {
|
|
575
|
-
const apiCall = [() => null, () => null, () => null, () => null];
|
|
289
|
+
const apiCall = [() => null, () => null, () => null, () => null];
|
|
290
|
+
|
|
291
|
+
// if appsays customNavigation: true, we will set doNavigation to false
|
|
576
292
|
// if appsays customNavigation: { ... }, we will set doNavigation to the customNavigation object and check for child elements
|
|
577
293
|
// if appsays nothing we will set doNavigation to true and continue to do navigation calls
|
|
578
|
-
|
|
579
294
|
const doNavigation = !appsays || ((appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) === true ? false : (appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) || true);
|
|
580
295
|
const {
|
|
581
296
|
entryLinkDepth = 0,
|
|
@@ -583,7 +298,6 @@ function* resolveCurrentNodeOrdinates({
|
|
|
583
298
|
linkDepth,
|
|
584
299
|
nodeOptions = {}
|
|
585
300
|
} = contentTypeMapping;
|
|
586
|
-
|
|
587
301
|
if (pathNode && pathNode.id) {
|
|
588
302
|
if (doNavigation === true || doNavigation.ancestors) {
|
|
589
303
|
apiCall[0] = function* getAncestors() {
|
|
@@ -599,12 +313,9 @@ function* resolveCurrentNodeOrdinates({
|
|
|
599
313
|
}
|
|
600
314
|
};
|
|
601
315
|
}
|
|
602
|
-
|
|
603
316
|
const childrenDepth = doNavigation === true || doNavigation.children === true ? 1 : doNavigation && doNavigation.children || 0;
|
|
604
|
-
|
|
605
317
|
if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.children) === 'undefined' && childrenDepth > 0 || nodeOptions.children) {
|
|
606
318
|
const childrenOptions = typeof nodeOptions.children === 'boolean' ? {} : nodeOptions.children;
|
|
607
|
-
|
|
608
319
|
apiCall[1] = function* getChildren() {
|
|
609
320
|
try {
|
|
610
321
|
return yield cachedSearch.getNode({
|
|
@@ -621,12 +332,10 @@ function* resolveCurrentNodeOrdinates({
|
|
|
621
332
|
}
|
|
622
333
|
};
|
|
623
334
|
}
|
|
624
|
-
|
|
625
335
|
if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.siblings) === 'undefined' && doNavigation.siblings || nodeOptions.siblings) {
|
|
626
336
|
apiCall[2] = function* getSiblings() {
|
|
627
337
|
try {
|
|
628
338
|
var _nodeOptions$siblings, _nodeOptions$siblings2;
|
|
629
|
-
|
|
630
339
|
return yield cachedSearch.getSiblings({
|
|
631
340
|
id: pathNode.id,
|
|
632
341
|
entryFields: (nodeOptions === null || nodeOptions === void 0 ? void 0 : (_nodeOptions$siblings = nodeOptions.siblings) === null || _nodeOptions$siblings === void 0 ? void 0 : _nodeOptions$siblings.fields) || fields || undefined,
|
|
@@ -642,18 +351,18 @@ function* resolveCurrentNodeOrdinates({
|
|
|
642
351
|
};
|
|
643
352
|
}
|
|
644
353
|
}
|
|
645
|
-
|
|
646
354
|
const isTreeLoaded = yield select(hasNavigationTree);
|
|
647
355
|
if (!isTreeLoaded && (doNavigation === true || doNavigation.tree)) apiCall[3] = function* getNodeTree() {
|
|
648
356
|
const treeDepth = doNavigation === true || !doNavigation.tree || doNavigation.tree === true ? 2 : doNavigation.tree;
|
|
649
|
-
|
|
650
357
|
if (typeof window !== 'undefined') {
|
|
651
358
|
return yield put({
|
|
652
359
|
type: GET_NODE_TREE,
|
|
360
|
+
language,
|
|
653
361
|
treeDepth
|
|
654
362
|
});
|
|
655
363
|
} else {
|
|
656
364
|
return yield call(ensureNodeTreeSaga, {
|
|
365
|
+
language,
|
|
657
366
|
treeDepth
|
|
658
367
|
});
|
|
659
368
|
}
|
|
@@ -662,12 +371,16 @@ function* resolveCurrentNodeOrdinates({
|
|
|
662
371
|
const [ancestors, nodeWithChildren, siblings] = yield all([loadAncestors(), loadChildren(), loadSiblings(), loadTree()]);
|
|
663
372
|
return [ancestors, nodeWithChildren === null || nodeWithChildren === void 0 ? void 0 : nodeWithChildren.children, siblings];
|
|
664
373
|
}
|
|
665
|
-
|
|
666
|
-
function* setRouteEntry(entry, node, ancestors, siblings, entryMapper, notFound = false, remapEntry = false) {
|
|
374
|
+
function* setRouteEntry(currentPath, entry, node, ancestors, siblings, entryMapper, notFound = false, remapEntry = false) {
|
|
667
375
|
const entrySys = entry && entry.sys || {};
|
|
376
|
+
|
|
377
|
+
// Update a window global to provide the preview toolbar
|
|
378
|
+
// an updated entry id in client-side navigation
|
|
379
|
+
if (typeof window !== 'undefined') window.ContensisEntryId = entrySys.id;
|
|
668
380
|
const currentEntryId = yield select(selectRouteEntryEntryId);
|
|
669
381
|
const currentEntryLang = yield select(selectRouteEntryLanguage);
|
|
670
|
-
const mappedEntry = currentEntryId === entrySys.id && currentEntryLang === entrySys.language && remapEntry === false ? (yield select(selectMappedEntry, 'js')) || {} : yield mapRouteEntry(entryMapper, {
|
|
382
|
+
const mappedEntry = currentEntryId === entrySys.id && currentEntryLang === entrySys.language && remapEntry === false ? (yield select(selectMappedEntry, 'js')) || {} : yield mapRouteEntry(entryMapper, {
|
|
383
|
+
...node,
|
|
671
384
|
entry,
|
|
672
385
|
ancestors,
|
|
673
386
|
siblings
|
|
@@ -675,6 +388,7 @@ function* setRouteEntry(entry, node, ancestors, siblings, entryMapper, notFound
|
|
|
675
388
|
yield all([put({
|
|
676
389
|
type: SET_ENTRY,
|
|
677
390
|
id: entrySys.id,
|
|
391
|
+
currentPath,
|
|
678
392
|
entry,
|
|
679
393
|
mappedEntry,
|
|
680
394
|
node,
|
|
@@ -687,7 +401,6 @@ function* setRouteEntry(entry, node, ancestors, siblings, entryMapper, notFound
|
|
|
687
401
|
siblings
|
|
688
402
|
})]);
|
|
689
403
|
}
|
|
690
|
-
|
|
691
404
|
function* mapRouteEntry(entryMapper, node) {
|
|
692
405
|
try {
|
|
693
406
|
if (typeof entryMapper === 'function') {
|
|
@@ -698,10 +411,8 @@ function* mapRouteEntry(entryMapper, node) {
|
|
|
698
411
|
} catch (e) {
|
|
699
412
|
log.error(...['Error running entryMapper:', e, e.stack]);
|
|
700
413
|
}
|
|
701
|
-
|
|
702
414
|
return;
|
|
703
415
|
}
|
|
704
|
-
|
|
705
416
|
function* do404() {
|
|
706
417
|
yield call(clientReloadHitServer);
|
|
707
418
|
yield put({
|
|
@@ -711,17 +422,16 @@ function* do404() {
|
|
|
711
422
|
notFound: true
|
|
712
423
|
});
|
|
713
424
|
}
|
|
714
|
-
|
|
715
425
|
function* clientReloadHitServer() {
|
|
716
|
-
const stateEntry = yield select(selectRouteEntry);
|
|
426
|
+
const stateEntry = yield select(selectRouteEntry);
|
|
427
|
+
|
|
428
|
+
// If in client and there is a stateEntry.sys field reload the page,
|
|
717
429
|
// on the 2nd load stateEntry.sys should be null at this point,
|
|
718
430
|
// we do not wish to reload again and get stuck in an infinite reloading loop
|
|
719
|
-
|
|
720
431
|
if (typeof window !== 'undefined' && (stateEntry !== null && stateEntry !== void 0 && stateEntry.sys || null)) {
|
|
721
432
|
window.location.reload();
|
|
722
433
|
}
|
|
723
434
|
}
|
|
724
|
-
|
|
725
435
|
function* do500(error) {
|
|
726
436
|
yield put({
|
|
727
437
|
type: SET_ENTRY,
|
|
@@ -733,7 +443,6 @@ function* do500(error) {
|
|
|
733
443
|
statusCode: error && error.status ? error.status : 500
|
|
734
444
|
});
|
|
735
445
|
}
|
|
736
|
-
|
|
737
446
|
function* reduxInjectorSaga(injectorFn) {
|
|
738
447
|
if (typeof injectorFn === 'function') {
|
|
739
448
|
const {
|
|
@@ -750,19 +459,18 @@ function* reduxInjectorSaga(injectorFn) {
|
|
|
750
459
|
}
|
|
751
460
|
|
|
752
461
|
const registerSagas = [takeEvery(REGISTER_USER, registerSaga), takeEvery(REGISTER_USER_SUCCESS, redirectSaga)];
|
|
753
|
-
|
|
754
462
|
function* registerSaga({
|
|
755
463
|
user,
|
|
756
464
|
mappers
|
|
757
465
|
}) {
|
|
758
|
-
let requestBody = user;
|
|
466
|
+
let requestBody = user;
|
|
467
|
+
// Allow use of request mapper to take a user object
|
|
759
468
|
// of any format and return the payload for the api request
|
|
760
|
-
|
|
761
469
|
if (mappers && mappers.request && typeof mappers.request === 'function') {
|
|
762
470
|
requestBody = yield mappers.request(user);
|
|
763
|
-
}
|
|
764
|
-
|
|
471
|
+
}
|
|
765
472
|
|
|
473
|
+
// Make POST call to register API
|
|
766
474
|
const response = yield fetch('/account/register', {
|
|
767
475
|
method: 'POST',
|
|
768
476
|
headers: {
|
|
@@ -771,19 +479,16 @@ function* registerSaga({
|
|
|
771
479
|
},
|
|
772
480
|
body: JSON.stringify(requestBody)
|
|
773
481
|
});
|
|
774
|
-
|
|
775
482
|
if (response.ok) {
|
|
776
483
|
let mappedResponse;
|
|
777
484
|
const [, responseBody] = yield to(response.json());
|
|
778
|
-
|
|
779
485
|
if (responseBody) {
|
|
780
486
|
// Allow use of response mapper to convert the successful user object
|
|
781
487
|
// from the api response body into a user object of any format
|
|
782
488
|
if (mappers && mappers.response && typeof mappers.response === 'function') {
|
|
783
489
|
mappedResponse = yield mappers.response(responseBody);
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
|
|
490
|
+
}
|
|
491
|
+
// Update user object with mappedResponse or responseBody
|
|
787
492
|
yield put({
|
|
788
493
|
type: REGISTER_USER_SUCCESS,
|
|
789
494
|
user: mappedResponse || responseBody
|
|
@@ -802,25 +507,24 @@ function* registerSaga({
|
|
|
802
507
|
// or status codes echoed from the responses received from
|
|
803
508
|
// management api when registering the user
|
|
804
509
|
const [, errorResponse] = yield to(response.json());
|
|
805
|
-
const error = errorResponse && errorResponse.error || errorResponse || {};
|
|
806
|
-
|
|
510
|
+
const error = errorResponse && errorResponse.error || errorResponse || {};
|
|
511
|
+
// Get something meaningful from the response if there is no message in the body
|
|
807
512
|
if (!error.message) {
|
|
808
513
|
error.message = `Registration service: ${response.statusText}`;
|
|
809
514
|
error.status = response.status;
|
|
810
515
|
}
|
|
811
|
-
|
|
812
516
|
yield put({
|
|
813
517
|
type: REGISTER_USER_FAILED,
|
|
814
518
|
error
|
|
815
519
|
});
|
|
816
520
|
}
|
|
817
521
|
}
|
|
818
|
-
|
|
819
522
|
function* redirectSaga() {
|
|
820
523
|
// Check if querystring contains a redirect_uri
|
|
821
524
|
const currentQs = queryParams(yield select(selectCurrentSearch));
|
|
822
|
-
const redirectUri = currentQs.redirect_uri || currentQs.redirect;
|
|
525
|
+
const redirectUri = currentQs.redirect_uri || currentQs.redirect;
|
|
823
526
|
|
|
527
|
+
// We must use redux based navigation to preserve the registration state
|
|
824
528
|
if (redirectUri) yield put(setRoute(redirectUri));
|
|
825
529
|
}
|
|
826
530
|
|
|
@@ -838,36 +542,36 @@ const BASE_OPTIONS = {
|
|
|
838
542
|
};
|
|
839
543
|
class UserHelper {
|
|
840
544
|
static async GetUsersEnvironments(securityToken) {
|
|
841
|
-
const options = {
|
|
545
|
+
const options = {
|
|
546
|
+
...BASE_OPTIONS,
|
|
842
547
|
headers: {
|
|
843
548
|
'x-security-token': securityToken
|
|
844
549
|
}
|
|
845
550
|
};
|
|
846
551
|
return await UserHelper.get(USER_ENVS_URL, options);
|
|
847
552
|
}
|
|
848
|
-
|
|
849
553
|
static async ResendUserVerification(userEmail) {
|
|
850
|
-
const options = {
|
|
554
|
+
const options = {
|
|
555
|
+
...BASE_OPTIONS
|
|
851
556
|
};
|
|
852
557
|
return await UserHelper.get(`/${USER_RESEND_VERIFICATION_URI}?user=${userEmail}`, options);
|
|
853
558
|
}
|
|
854
|
-
|
|
855
559
|
static async RequestPasswordReset(userEmailObject) {
|
|
856
|
-
const options = {
|
|
560
|
+
const options = {
|
|
561
|
+
...BASE_OPTIONS,
|
|
857
562
|
body: JSON.stringify(userEmailObject)
|
|
858
563
|
};
|
|
859
564
|
options.method = 'POST';
|
|
860
565
|
return await UserHelper.get(`/${USER_REQUEST_PASSWORD_RESET_URI}`, options);
|
|
861
566
|
}
|
|
862
|
-
|
|
863
567
|
static async ResetPassword(resetPasswordObject) {
|
|
864
|
-
const options = {
|
|
568
|
+
const options = {
|
|
569
|
+
...BASE_OPTIONS,
|
|
865
570
|
body: JSON.stringify(resetPasswordObject)
|
|
866
571
|
};
|
|
867
572
|
options.method = 'POST';
|
|
868
573
|
return await UserHelper.get(`/${USER_RESET_PASSWORD_URI}`, options);
|
|
869
574
|
}
|
|
870
|
-
|
|
871
575
|
static async get(url, options = BASE_OPTIONS) {
|
|
872
576
|
try {
|
|
873
577
|
const responseBody = await api(url, options);
|
|
@@ -880,9 +584,7 @@ class UserHelper {
|
|
|
880
584
|
};
|
|
881
585
|
}
|
|
882
586
|
}
|
|
883
|
-
|
|
884
587
|
}
|
|
885
|
-
|
|
886
588
|
async function api(url, options) {
|
|
887
589
|
return fetch(url, options).then(async response => {
|
|
888
590
|
return response.json().then(data => data);
|
|
@@ -892,17 +594,14 @@ async function api(url, options) {
|
|
|
892
594
|
}
|
|
893
595
|
|
|
894
596
|
const resetPasswordSagas = [takeEvery(REQUEST_USER_PASSWORD_RESET, requestPasswordResetSaga), takeEvery(RESET_USER_PASSWORD, resetPasswordSaga), takeEvery(CHANGE_USER_PASSWORD, changePasswordSaga)];
|
|
895
|
-
|
|
896
597
|
function* requestPasswordResetSaga(action) {
|
|
897
598
|
const userEmailObject = action.userEmailObject;
|
|
898
599
|
yield put({
|
|
899
600
|
type: REQUEST_USER_PASSWORD_RESET_SENDING
|
|
900
601
|
});
|
|
901
|
-
|
|
902
602
|
if (userEmailObject && userEmailObject.userEmail) {
|
|
903
603
|
try {
|
|
904
604
|
const passwordResetRequestResponse = yield UserHelper.RequestPasswordReset(userEmailObject);
|
|
905
|
-
|
|
906
605
|
if (passwordResetRequestResponse) {
|
|
907
606
|
if (!passwordResetRequestResponse.error) {
|
|
908
607
|
yield put({
|
|
@@ -933,17 +632,14 @@ function* requestPasswordResetSaga(action) {
|
|
|
933
632
|
});
|
|
934
633
|
}
|
|
935
634
|
}
|
|
936
|
-
|
|
937
635
|
function* resetPasswordSaga(action) {
|
|
938
636
|
const resetPasswordObject = action.resetPasswordObject;
|
|
939
637
|
yield put({
|
|
940
638
|
type: RESET_USER_PASSWORD_SENDING
|
|
941
639
|
});
|
|
942
|
-
|
|
943
640
|
if (resetPasswordObject.token && resetPasswordObject.password) {
|
|
944
641
|
try {
|
|
945
642
|
const resetPasswordResponse = yield UserHelper.ResetPassword(resetPasswordObject);
|
|
946
|
-
|
|
947
643
|
if (resetPasswordResponse) {
|
|
948
644
|
if (!resetPasswordResponse.error) {
|
|
949
645
|
yield put({
|
|
@@ -974,11 +670,11 @@ function* resetPasswordSaga(action) {
|
|
|
974
670
|
error: 'Invalid object'
|
|
975
671
|
});
|
|
976
672
|
}
|
|
977
|
-
}
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// userId
|
|
978
676
|
// existingPassword
|
|
979
677
|
// newPassword
|
|
980
|
-
|
|
981
|
-
|
|
982
678
|
function* changePasswordSaga(action) {
|
|
983
679
|
if (!action || !action.userId || !action.currentPassword || !action.newPassword) {
|
|
984
680
|
yield put({
|
|
@@ -987,7 +683,6 @@ function* changePasswordSaga(action) {
|
|
|
987
683
|
});
|
|
988
684
|
return;
|
|
989
685
|
}
|
|
990
|
-
|
|
991
686
|
try {
|
|
992
687
|
const changePasswordObject = {
|
|
993
688
|
userId: action.userId,
|
|
@@ -998,25 +693,24 @@ function* changePasswordSaga(action) {
|
|
|
998
693
|
type: CHANGE_USER_PASSWORD_SENDING
|
|
999
694
|
});
|
|
1000
695
|
const clientCredentials = yield select(selectClientCredentials, 'js');
|
|
1001
|
-
const client = yield getManagementApiClient({
|
|
696
|
+
const client = yield getManagementApiClient({
|
|
697
|
+
...clientCredentials
|
|
1002
698
|
});
|
|
1003
699
|
const [err, res] = yield to(client.security.users.updatePassword(changePasswordObject));
|
|
1004
|
-
|
|
1005
700
|
if (err) {
|
|
1006
701
|
var _err$data, _err$data$data, _err$data2;
|
|
1007
|
-
|
|
1008
702
|
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);
|
|
1009
703
|
yield put({
|
|
1010
704
|
type: CHANGE_USER_PASSWORD_ERROR,
|
|
1011
705
|
error
|
|
1012
706
|
});
|
|
1013
707
|
return;
|
|
1014
|
-
}
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
// // eslint-disable-next-line no-console
|
|
1015
711
|
// console.log(changePasswordObject);
|
|
1016
712
|
// // eslint-disable-next-line no-console
|
|
1017
713
|
// console.log(userCredentialsObject);
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
714
|
yield put({
|
|
1021
715
|
type: CHANGE_USER_PASSWORD_SUCCESS
|
|
1022
716
|
});
|
|
@@ -1038,35 +732,32 @@ function rootSaga (featureSagas = []) {
|
|
|
1038
732
|
};
|
|
1039
733
|
}
|
|
1040
734
|
|
|
1041
|
-
const servers = SERVERS;
|
|
1042
|
-
/* global SERVERS */
|
|
1043
|
-
|
|
735
|
+
const servers = SERVERS; /* global SERVERS */
|
|
1044
736
|
const alias = servers.alias.toLowerCase();
|
|
1045
|
-
const publicUri = PUBLIC_URI;
|
|
1046
|
-
/* global
|
|
737
|
+
const publicUri = PUBLIC_URI; /* global PUBLIC_URI */
|
|
738
|
+
const projects = PROJECTS; /* global PROJECTS */
|
|
1047
739
|
|
|
1048
|
-
const projects = PROJECTS;
|
|
1049
|
-
/* global PROJECTS */
|
|
1050
740
|
// return a projectId via the request hostname
|
|
1051
|
-
|
|
1052
741
|
const pickProject = (hostname, query) => {
|
|
1053
742
|
// if localhost we can only infer via a querystring, and take your word for it
|
|
1054
743
|
if (hostname == 'localhost') {
|
|
1055
744
|
return query && query.p || projects[0].id;
|
|
1056
|
-
}
|
|
1057
|
-
|
|
745
|
+
}
|
|
1058
746
|
|
|
747
|
+
// if hostname is the actual public uri we can return the first project from the list
|
|
1059
748
|
if (hostname == publicUri) {
|
|
1060
749
|
return projects[0].id;
|
|
1061
750
|
}
|
|
751
|
+
let project = 'unknown';
|
|
1062
752
|
|
|
1063
|
-
|
|
753
|
+
// // go through all the defined projects
|
|
1064
754
|
// Object.entries(projects).map(([, p]) => {
|
|
755
|
+
const p = projects[0];
|
|
1065
756
|
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
if (hostname.includes(p.publicUri)) project = p.id; // the url structure is different for website (we don't prefix)
|
|
757
|
+
// check if we're accessing via the project's public uri
|
|
758
|
+
if (hostname.includes(p.publicUri)) project = p.id;
|
|
1069
759
|
|
|
760
|
+
// the url structure is different for website (we don't prefix)
|
|
1070
761
|
if (p.id.startsWith('website')) {
|
|
1071
762
|
// check for internal and external hostnames
|
|
1072
763
|
// we check live and preview distinctly so our rule does not clash with
|
|
@@ -1075,9 +766,8 @@ const pickProject = (hostname, query) => {
|
|
|
1075
766
|
} else {
|
|
1076
767
|
// check for internal and external hostnames, prefixed with the projectId
|
|
1077
768
|
if (hostname.includes(`${p.id.toLowerCase()}-${alias}.cloud.contensis.com`) || hostname.includes(`${p.id.toLowerCase()}.${alias}.contensis.cloud`)) project = p.id;
|
|
1078
|
-
}
|
|
1079
|
-
|
|
1080
|
-
|
|
769
|
+
}
|
|
770
|
+
// });
|
|
1081
771
|
return project === 'unknown' ? p.id : project;
|
|
1082
772
|
};
|
|
1083
773
|
|
|
@@ -1085,5 +775,5 @@ const AppRoot = props => {
|
|
|
1085
775
|
return /*#__PURE__*/React.createElement(RouteLoader, props);
|
|
1086
776
|
};
|
|
1087
777
|
|
|
1088
|
-
export { AppRoot as A, browserHistory as b,
|
|
1089
|
-
//# sourceMappingURL=App-
|
|
778
|
+
export { AppRoot as A, browserHistory as b, history as h, pickProject as p, rootSaga as r };
|
|
779
|
+
//# sourceMappingURL=App-2af18a99.js.map
|