@zengenti/contensis-react-base 3.0.2-beta.4 → 3.0.2-beta.6
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-a2783f8b.js → App-2a7a16ad.js} +110 -429
- package/cjs/App-2a7a16ad.js.map +1 -0
- package/cjs/ContensisDeliveryApi-de88df2a.js +231 -0
- package/cjs/ContensisDeliveryApi-de88df2a.js.map +1 -0
- package/cjs/{RouteLoader-3aa6456e.js → RouteLoader-47d70a26.js} +23 -37
- package/{esm/RouteLoader-5171c63f.js.map → cjs/RouteLoader-47d70a26.js.map} +1 -1
- package/cjs/{ToJs-a9a8522b.js → ToJs-61c03582.js} +3 -4
- package/cjs/{ToJs-a9a8522b.js.map → ToJs-61c03582.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 +11 -153
- 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-e711a19e.js → login-2ea569cc.js} +60 -112
- package/cjs/{login-e711a19e.js.map → login-2ea569cc.js.map} +1 -1
- package/cjs/{reducers-73a03ef4.js → reducers-9afb5f89.js} +10 -31
- package/{esm/reducers-aa8cef1e.js.map → cjs/reducers-9afb5f89.js.map} +1 -1
- 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-6d12e7ca.js} +182 -282
- package/{esm/sagas-e576b6f6.js.map → cjs/sagas-6d12e7ca.js.map} +1 -1
- package/cjs/search.js +56 -82
- package/cjs/search.js.map +1 -1
- package/cjs/{selectors-656da4b7.js → selectors-c76c2676.js} +84 -7
- package/cjs/selectors-c76c2676.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-bf9ef45e.js → version-38afaf2a.js} +45 -158
- package/cjs/version-38afaf2a.js.map +1 -0
- package/cjs/version-886f49d8.js +98 -0
- package/cjs/version-886f49d8.js.map +1 -0
- package/esm/{App-17d1ac3c.js → App-4fb1fc44.js} +92 -409
- package/esm/App-4fb1fc44.js.map +1 -0
- package/esm/ContensisDeliveryApi-ad06857d.js +227 -0
- package/esm/ContensisDeliveryApi-ad06857d.js.map +1 -0
- package/esm/{RouteLoader-5171c63f.js → RouteLoader-f5d5f733.js} +22 -36
- package/{cjs/RouteLoader-3aa6456e.js.map → esm/RouteLoader-f5d5f733.js.map} +1 -1
- package/esm/{ToJs-4e02a04d.js → ToJs-0066e629.js} +3 -4
- package/esm/{ToJs-4e02a04d.js.map → ToJs-0066e629.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 +11 -153
- 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-551d243a.js → login-bffb081f.js} +59 -111
- package/esm/{login-551d243a.js.map → login-bffb081f.js.map} +1 -1
- package/esm/{reducers-aa8cef1e.js → reducers-3d5c37d1.js} +10 -31
- package/{cjs/reducers-73a03ef4.js.map → esm/reducers-3d5c37d1.js.map} +1 -1
- 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-53d2aefb.js} +134 -235
- package/{cjs/sagas-8a20e424.js.map → esm/sagas-53d2aefb.js.map} +1 -1
- package/esm/search.js +57 -83
- package/esm/search.js.map +1 -1
- package/esm/{selectors-a5e5835b.js → selectors-3f0d804d.js} +70 -7
- package/esm/selectors-3f0d804d.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-72ca17f3.js → version-dd31c7f0.js} +32 -141
- package/esm/version-dd31c7f0.js.map +1 -0
- package/esm/version-f4629693.js +87 -0
- package/esm/version-f4629693.js.map +1 -0
- package/models/app/pages/VersionInfo/components/VersionInfo.styled.d.ts +2 -1
- package/models/user/components.styled/Login.styled.d.ts +1 -1
- package/models/user/components.styled/LoginForm.styled.d.ts +1 -1
- package/models/util/ContensisDeliveryApi.d.ts +6 -0
- package/models/util/index.d.ts +1 -0
- package/package.json +2 -2
- package/cjs/App-a2783f8b.js.map +0 -1
- package/cjs/actions-8dc9e8de.js +0 -87
- package/cjs/actions-8dc9e8de.js.map +0 -1
- package/cjs/selectors-656da4b7.js.map +0 -1
- package/cjs/version-bf9ef45e.js.map +0 -1
- package/cjs/version-eba6d09b.js +0 -20
- package/cjs/version-eba6d09b.js.map +0 -1
- package/esm/App-17d1ac3c.js.map +0 -1
- package/esm/actions-180948dd.js +0 -72
- package/esm/actions-180948dd.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-72ca17f3.js.map +0 -1
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
var history$1 = require('history');
|
|
4
4
|
var effects = require('@redux-saga/core/effects');
|
|
5
5
|
var log = require('loglevel');
|
|
6
|
+
var ContensisDeliveryApi = require('./ContensisDeliveryApi-de88df2a.js');
|
|
7
|
+
var version = require('./version-38afaf2a.js');
|
|
8
|
+
var version$1 = require('./version-886f49d8.js');
|
|
9
|
+
var selectors = require('./selectors-c76c2676.js');
|
|
10
|
+
var login = require('./login-2ea569cc.js');
|
|
6
11
|
var contensisDeliveryApi = require('contensis-delivery-api');
|
|
7
|
-
var queryString = require('query-string');
|
|
8
|
-
var actions = require('./actions-8dc9e8de.js');
|
|
9
|
-
var version = require('./version-bf9ef45e.js');
|
|
10
|
-
var version$1 = require('./version-eba6d09b.js');
|
|
11
|
-
var selectors = require('./selectors-656da4b7.js');
|
|
12
|
-
var login = require('./login-e711a19e.js');
|
|
13
12
|
var awaitToJs = require('await-to-js');
|
|
14
|
-
var reducers = require('./reducers-
|
|
15
|
-
var ToJs = require('./ToJs-
|
|
13
|
+
var reducers = require('./reducers-9afb5f89.js');
|
|
14
|
+
var ToJs = require('./ToJs-61c03582.js');
|
|
16
15
|
var React = require('react');
|
|
17
16
|
require('react-hot-loader');
|
|
18
17
|
require('jsonpath-mapper');
|
|
19
|
-
|
|
18
|
+
require('query-string');
|
|
19
|
+
var RouteLoader = require('./RouteLoader-47d70a26.js');
|
|
20
20
|
|
|
21
21
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
22
22
|
|
|
@@ -41,279 +41,7 @@ function _interopNamespace(e) {
|
|
|
41
41
|
var log__namespace = /*#__PURE__*/_interopNamespace(log);
|
|
42
42
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
const keys = response.headers.get ? response.headers.get('surrogate-key') : response.headers.map['surrogate-key'];
|
|
46
|
-
if (keys) version.reduxStore === null || version.reduxStore === void 0 ? void 0 : version.reduxStore.dispatch(actions.setSurrogateKeys(keys, response.url));
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const getClientConfig = project => {
|
|
50
|
-
let config = DELIVERY_API_CONFIG;
|
|
51
|
-
/* global DELIVERY_API_CONFIG */
|
|
52
|
-
|
|
53
|
-
config.responseHandler = {};
|
|
54
|
-
|
|
55
|
-
if (project) {
|
|
56
|
-
config.projectId = project;
|
|
57
|
-
} // we only want the surrogate key header in a server context
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (typeof window === 'undefined') {
|
|
61
|
-
config.defaultHeaders = {
|
|
62
|
-
'x-require-surrogate-key': true
|
|
63
|
-
};
|
|
64
|
-
config.responseHandler[200] = storeSurrogateKeys;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (typeof window !== 'undefined' && PROXY_DELIVERY_API
|
|
68
|
-
/* global PROXY_DELIVERY_API */
|
|
69
|
-
) {
|
|
70
|
-
// ensure a relative url is used to bypass the need for CORS (separate OPTIONS calls)
|
|
71
|
-
config.rootUrl = '';
|
|
72
|
-
|
|
73
|
-
config.responseHandler[404] = () => null;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return config;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
class DeliveryApi {
|
|
80
|
-
constructor() {
|
|
81
|
-
this.getClientSideVersionStatus = () => {
|
|
82
|
-
if (typeof window !== 'undefined') {
|
|
83
|
-
// Allow overriding versionStatus with the querystring
|
|
84
|
-
const {
|
|
85
|
-
versionStatus
|
|
86
|
-
} = queryString.parse(window.location.search);
|
|
87
|
-
if (versionStatus) return versionStatus; // Client-side we will have a global variable set if rendered by SSR in production
|
|
88
|
-
|
|
89
|
-
if (typeof window.versionStatus !== 'undefined') return window.versionStatus; // For localhost development we can only work out versionStatus from the current hostname
|
|
90
|
-
|
|
91
|
-
const currentHostname = window.location.hostname;
|
|
92
|
-
return this.getVersionStatusFromHostname(currentHostname);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return null;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
this.getServerSideVersionStatus = request => request.query.versionStatus || deliveryApi.getVersionStatusFromHeaders(request.headers) || deliveryApi.getVersionStatusFromHostname(request.hostname);
|
|
99
|
-
|
|
100
|
-
this.getVersionStatusFromHeaders = headers => {
|
|
101
|
-
const versionStatusHeader = headers['x-entry-versionstatus'];
|
|
102
|
-
if (typeof versionStatusHeader !== 'undefined') return versionStatusHeader;
|
|
103
|
-
return null;
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
this.getVersionStatusFromHostname = currentHostname => {
|
|
107
|
-
if (currentHostname.indexOf('localhost') > -1) return 'latest';
|
|
108
|
-
|
|
109
|
-
if (currentHostname.endsWith('contensis.cloud')) {
|
|
110
|
-
if (currentHostname.indexOf('preview.') > -1) {
|
|
111
|
-
return 'latest';
|
|
112
|
-
} else {
|
|
113
|
-
return 'published';
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (currentHostname.endsWith('cloud.contensis.com')) {
|
|
118
|
-
if (currentHostname.indexOf('preview-') > -1) {
|
|
119
|
-
return 'latest';
|
|
120
|
-
} else {
|
|
121
|
-
return 'published';
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return 'published';
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
this.search = (query, linkDepth, project, env) => {
|
|
129
|
-
const client = contensisDeliveryApi.Client.create(getClientConfig(project));
|
|
130
|
-
return client.entries.search(query, typeof linkDepth !== 'undefined' ? linkDepth : 1);
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
this.getClient = (deliveryApiStatus = 'published', project, env) => {
|
|
134
|
-
const baseConfig = getClientConfig(project);
|
|
135
|
-
baseConfig.versionStatus = deliveryApiStatus;
|
|
136
|
-
return contensisDeliveryApi.Client.create(baseConfig);
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
this.getEntry = (id, linkDepth = 0, deliveryApiStatus = 'published', project, env) => {
|
|
140
|
-
const baseConfig = getClientConfig(project);
|
|
141
|
-
baseConfig.versionStatus = deliveryApiStatus;
|
|
142
|
-
const client = contensisDeliveryApi.Client.create(baseConfig); // return client.entries.get(id, linkDepth);
|
|
143
|
-
|
|
144
|
-
return client.entries.get({
|
|
145
|
-
id,
|
|
146
|
-
linkDepth
|
|
147
|
-
});
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const deliveryApi = new DeliveryApi();
|
|
154
|
-
|
|
155
|
-
class CacheNode {
|
|
156
|
-
constructor(key, value) {
|
|
157
|
-
this.key = key;
|
|
158
|
-
this.value = value;
|
|
159
|
-
this.next = null;
|
|
160
|
-
this.prev = null;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
class LruCache {
|
|
166
|
-
constructor(limit = 100) {
|
|
167
|
-
this.map = {};
|
|
168
|
-
this.head = null;
|
|
169
|
-
this.tail = null;
|
|
170
|
-
this.limit = limit || 100;
|
|
171
|
-
this.size = 0;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
get(key) {
|
|
175
|
-
if (this.map[key]) {
|
|
176
|
-
let value = this.map[key].value;
|
|
177
|
-
let node = new CacheNode(key, value);
|
|
178
|
-
this.remove(key);
|
|
179
|
-
this.setHead(node);
|
|
180
|
-
return value;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
set(key, value) {
|
|
185
|
-
let node = new CacheNode(key, value);
|
|
186
|
-
|
|
187
|
-
if (this.map[key]) {
|
|
188
|
-
this.remove(key);
|
|
189
|
-
} else {
|
|
190
|
-
if (this.size >= this.limit) {
|
|
191
|
-
delete this.map[this.tail.key];
|
|
192
|
-
this.size--;
|
|
193
|
-
this.tail = this.tail.prev;
|
|
194
|
-
this.tail.next = null;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
this.setHead(node);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
setHead(node) {
|
|
202
|
-
node.next = this.head;
|
|
203
|
-
node.prev = null;
|
|
204
|
-
|
|
205
|
-
if (this.head) {
|
|
206
|
-
this.head.prev = node;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
this.head = node;
|
|
210
|
-
|
|
211
|
-
if (!this.tail) {
|
|
212
|
-
this.tail = node;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
this.size++;
|
|
216
|
-
this.map[node.key] = node;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
remove(key) {
|
|
220
|
-
let node = this.map[key];
|
|
221
|
-
if (!node) return; // This is sometimes null and crashes the container without this check
|
|
222
|
-
|
|
223
|
-
if (node.prev) {
|
|
224
|
-
node.prev.next = node.next;
|
|
225
|
-
} else {
|
|
226
|
-
this.head = node.next;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
if (node.next) {
|
|
230
|
-
node.next.prev = node.prev;
|
|
231
|
-
} else {
|
|
232
|
-
this.tail = node.prev;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
delete this.map[key];
|
|
236
|
-
this.size--;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
class CachedSearch {
|
|
242
|
-
constructor() {
|
|
243
|
-
this.cache = new LruCache();
|
|
244
|
-
this.taxonomyLookup = {};
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
search(query, linkDepth, project, env) {
|
|
248
|
-
const client = contensisDeliveryApi.Client.create(getClientConfig(project));
|
|
249
|
-
return this.request(project + JSON.stringify(query) + linkDepth.toString(), () => client.entries.search(query, linkDepth));
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
searchUsingPost(query, linkDepth = 0, project = '', env) {
|
|
253
|
-
const client = contensisDeliveryApi.Client.create(getClientConfig(project));
|
|
254
|
-
return this.request(project + JSON.stringify(query) + linkDepth.toString(), () => client.entries.searchUsingPost(query, linkDepth));
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
get(id, linkDepth, versionStatus, project, env) {
|
|
258
|
-
const client = contensisDeliveryApi.Client.create(getClientConfig(project));
|
|
259
|
-
client.clientConfig.versionStatus = versionStatus;
|
|
260
|
-
return this.request(id, () => client.entries.get({
|
|
261
|
-
id,
|
|
262
|
-
linkDepth
|
|
263
|
-
}));
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
getContentType(id, project, env) {
|
|
267
|
-
const client = contensisDeliveryApi.Client.create(getClientConfig(project));
|
|
268
|
-
return this.request(`[CONTENT TYPE] ${id} ${project}`, () => client.contentTypes.get(id));
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
getTaxonomyNode(key, project, env) {
|
|
272
|
-
const client = contensisDeliveryApi.Client.create(getClientConfig(project));
|
|
273
|
-
return this.request(`[TAXONOMY NODE] ${key}`, () => client.taxonomy.resolveChildren(key).then(node => this.extendTaxonomyNode(node)));
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
getRootNode(options, project, env) {
|
|
277
|
-
const client = contensisDeliveryApi.Client.create(getClientConfig(project));
|
|
278
|
-
return this.request(`${project} / ${JSON.stringify(options)}`, () => client.nodes.getRoot(options));
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
getNode(options, project, env) {
|
|
282
|
-
const client = contensisDeliveryApi.Client.create(getClientConfig(project));
|
|
283
|
-
return this.request(`${project} ${options && options.path || options} ${JSON.stringify(options)}`, () => client.nodes.get(options));
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
getAncestors(options, project, env) {
|
|
287
|
-
const client = contensisDeliveryApi.Client.create(getClientConfig(project));
|
|
288
|
-
return this.request(`${project} [A] ${options && options.id || options} ${JSON.stringify(options)}`, () => client.nodes.getAncestors(options));
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
getChildren(options, project, env) {
|
|
292
|
-
const client = contensisDeliveryApi.Client.create(getClientConfig(project));
|
|
293
|
-
return this.request(`${project} [C] ${options && options.id || options} ${JSON.stringify(options)}`, () => client.nodes.getChildren(options));
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
getSiblings(options, project, env) {
|
|
297
|
-
const client = contensisDeliveryApi.Client.create(getClientConfig(project));
|
|
298
|
-
return this.request(`${project} [S] ${options && options.id || options} ${JSON.stringify(options)}`, () => client.nodes.getSiblings(options));
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
request(key, execute) {
|
|
302
|
-
if (!this.cache.get(key) || typeof window == 'undefined') {
|
|
303
|
-
let promise = execute();
|
|
304
|
-
this.cache.set(key, promise);
|
|
305
|
-
promise.catch(() => {
|
|
306
|
-
this.cache.remove(key);
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
return this.cache.get(key);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
const cachedSearch = new CachedSearch();
|
|
316
|
-
|
|
44
|
+
// Create a history depending on the environment
|
|
317
45
|
const selectedHistory = typeof window !== 'undefined' ? history$1.createBrowserHistory : history$1.createMemoryHistory;
|
|
318
46
|
const history = (options = {}) => selectedHistory(options);
|
|
319
47
|
const browserHistory = selectedHistory();
|
|
@@ -321,15 +49,13 @@ const browserHistory = selectedHistory();
|
|
|
321
49
|
const navigationSagas = [effects.takeEvery(version.GET_NODE_TREE, ensureNodeTreeSaga)];
|
|
322
50
|
function* ensureNodeTreeSaga(action) {
|
|
323
51
|
const state = yield effects.select();
|
|
324
|
-
|
|
325
52
|
try {
|
|
326
|
-
if (!version.hasNavigationTree(state)) {
|
|
327
|
-
const deliveryApiVersionStatus = yield effects.select(version
|
|
53
|
+
if (!version$1.hasNavigationTree(state)) {
|
|
54
|
+
const deliveryApiVersionStatus = yield effects.select(version.selectVersionStatus);
|
|
328
55
|
const project = yield effects.select(selectors.selectCurrentProject);
|
|
329
|
-
const nodes = yield deliveryApi.getClient(deliveryApiVersionStatus, project).nodes.getRoot({
|
|
56
|
+
const nodes = yield ContensisDeliveryApi.deliveryApi.getClient(deliveryApiVersionStatus, project).nodes.getRoot({
|
|
330
57
|
depth: action.treeDepth || 0
|
|
331
58
|
});
|
|
332
|
-
|
|
333
59
|
if (nodes) {
|
|
334
60
|
yield effects.put({
|
|
335
61
|
type: version.SET_NODE_TREE,
|
|
@@ -376,7 +102,6 @@ const fieldExpression = (field, value, operator = 'equalTo', weight = null) => {
|
|
|
376
102
|
const defaultExpressions = versionStatus => {
|
|
377
103
|
return [contensisDeliveryApi.Op.equalTo(Fields.sys.versionStatus, versionStatus)];
|
|
378
104
|
};
|
|
379
|
-
|
|
380
105
|
const equalToOrIn = (field, arr, operator = 'equalTo') => arr.length === 0 ? [] : arr.length === 1 ? [contensisDeliveryApi.Op[operator](field, arr[0])] : [contensisDeliveryApi.Op.in(field, ...arr)];
|
|
381
106
|
|
|
382
107
|
const routeEntryByFieldsQuery = (id, language = 'en-GB', fields = [], versionStatus = 'published') => {
|
|
@@ -385,12 +110,12 @@ const routeEntryByFieldsQuery = (id, language = 'en-GB', fields = [], versionSta
|
|
|
385
110
|
return query;
|
|
386
111
|
};
|
|
387
112
|
|
|
388
|
-
const routingSagas = [effects.takeEvery(
|
|
113
|
+
const routingSagas = [effects.takeEvery(selectors.SET_NAVIGATION_PATH, getRouteSaga), effects.takeEvery(selectors.SET_ROUTE, setRouteSaga)];
|
|
114
|
+
|
|
389
115
|
/**
|
|
390
116
|
* To navigate / push a specific route via redux middleware
|
|
391
117
|
* @param {path, state} action
|
|
392
118
|
*/
|
|
393
|
-
|
|
394
119
|
function* setRouteSaga(action) {
|
|
395
120
|
yield effects.put({
|
|
396
121
|
type: 'CALL_HISTORY_METHOD',
|
|
@@ -400,37 +125,35 @@ function* setRouteSaga(action) {
|
|
|
400
125
|
}
|
|
401
126
|
});
|
|
402
127
|
}
|
|
403
|
-
|
|
404
128
|
function* getRouteSaga(action) {
|
|
405
129
|
let entry = null;
|
|
406
|
-
|
|
407
130
|
try {
|
|
408
131
|
var _staticRoute$route, _staticRoute$route$pa, _staticRoute$route2, _staticRoute$route2$p, _pathNode2, _pathNode2$entry, _pathNode2$entry$sys, _pathNode3, _pathNode3$entry, _pathNode3$entry$sys;
|
|
409
|
-
|
|
410
132
|
const {
|
|
411
133
|
withEvents,
|
|
412
134
|
routes: {
|
|
413
135
|
ContentTypeMappings = {}
|
|
414
136
|
} = {},
|
|
415
137
|
staticRoute
|
|
416
|
-
} = action;
|
|
138
|
+
} = action;
|
|
417
139
|
|
|
418
|
-
|
|
140
|
+
// Inject redux { key, reducer, saga } provided by staticRoute
|
|
141
|
+
if (staticRoute && staticRoute.route.injectRedux) yield effects.call(reduxInjectorSaga, staticRoute.route.injectRedux);
|
|
419
142
|
|
|
143
|
+
// Variables we will pass to setRouteEntry
|
|
420
144
|
let pathNode = null,
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
let contentTypeMapping = {};
|
|
425
|
-
// calls to withEvents.onRouteLoad and onRouteLoaded
|
|
145
|
+
ancestors = null,
|
|
146
|
+
children = [],
|
|
147
|
+
siblings = null;
|
|
148
|
+
let contentTypeMapping = {};
|
|
426
149
|
|
|
150
|
+
// These variables are the return values from
|
|
151
|
+
// calls to withEvents.onRouteLoad and onRouteLoaded
|
|
427
152
|
let appsays,
|
|
428
|
-
|
|
429
|
-
|
|
153
|
+
requireLogin = false;
|
|
430
154
|
if (withEvents && withEvents.onRouteLoad) {
|
|
431
155
|
appsays = yield withEvents.onRouteLoad(action);
|
|
432
156
|
}
|
|
433
|
-
|
|
434
157
|
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;
|
|
435
158
|
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;
|
|
436
159
|
const entryLinkDepth = appsays && appsays.entryLinkDepth !== undefined ? appsays.entryLinkDepth : 2;
|
|
@@ -439,32 +162,31 @@ function* getRouteSaga(action) {
|
|
|
439
162
|
const routeEntry = selectors.selectRouteEntry(state, 'js');
|
|
440
163
|
const routeNode = selectors.selectCurrentNode(state, 'js');
|
|
441
164
|
const currentPath = action.path; //selectCurrentPath(state);
|
|
442
|
-
|
|
443
|
-
const
|
|
444
|
-
|
|
445
|
-
|
|
165
|
+
const deliveryApiStatus = version.selectVersionStatus(state);
|
|
166
|
+
const project = selectors.selectCurrentProject(state);
|
|
167
|
+
// const isHome = currentPath === '/';
|
|
446
168
|
const isPreview = currentPath && currentPath.startsWith('/preview/');
|
|
447
169
|
const defaultLang = appsays && appsays.defaultLang || 'en-GB';
|
|
448
|
-
|
|
449
170
|
if (!isPreview && (appsays && appsays.customRouting || staticRoute && !staticRoute.route.fetchNode || routeEntry && action.statePath === action.path && (appsays && appsays.refetchNode) !== true)) {
|
|
450
171
|
// To prevent erroneous 404s and wasted network calls, this covers
|
|
451
172
|
// - appsays customRouting and does SET_ENTRY etc. via the consuming app
|
|
452
173
|
// - all staticRoutes (where custom 'route.fetchNode' attribute is falsey)
|
|
453
174
|
// - standard Contensis SiteView Routing where we already have that entry in state
|
|
454
175
|
if (routeEntry && (!staticRoute || staticRoute.route && staticRoute.route.fetchNode)) {
|
|
455
|
-
pathNode = {
|
|
176
|
+
pathNode = {
|
|
177
|
+
...routeNode,
|
|
456
178
|
entry: null
|
|
457
179
|
};
|
|
458
|
-
pathNode.entry = entry = routeEntry;
|
|
180
|
+
pathNode.entry = entry = routeEntry;
|
|
181
|
+
//Do nothing, the entry is allready the right one.
|
|
459
182
|
// yield put({
|
|
460
183
|
// type: SET_ENTRY,
|
|
461
184
|
// entry,
|
|
462
185
|
// node: routeNode,
|
|
463
186
|
// isLoading: false,
|
|
464
187
|
// });
|
|
465
|
-
|
|
466
188
|
yield effects.put({
|
|
467
|
-
type:
|
|
189
|
+
type: selectors.UPDATE_LOADING_STATE,
|
|
468
190
|
isLoading: false
|
|
469
191
|
});
|
|
470
192
|
} else yield effects.call(setRouteEntry, routeEntry, yield effects.select(selectors.selectCurrentNode), yield effects.select(selectors.selectCurrentAncestors), yield effects.select(selectors.selectCurrentSiblings));
|
|
@@ -474,21 +196,20 @@ function* getRouteSaga(action) {
|
|
|
474
196
|
let splitPath = currentPath.split('/');
|
|
475
197
|
let entryGuid = splitPath[2];
|
|
476
198
|
let language = defaultLang;
|
|
477
|
-
|
|
478
199
|
if (splitPath.length >= 3) {
|
|
479
200
|
//set lang key if available in the path, else use default lang
|
|
480
201
|
//assumes preview url on content type is: http://preview.ALIAS.contensis.cloud/preview/{GUID}/{LANG}
|
|
481
|
-
if (splitPath.length == 4) language = splitPath[3];
|
|
202
|
+
if (splitPath.length == 4) language = splitPath[3];
|
|
203
|
+
// According to product dev we cannot use Node API
|
|
482
204
|
// for previewing entries as it gives a response of []
|
|
483
205
|
// -- apparently it is not correct to request latest content
|
|
484
206
|
// with Node API
|
|
485
207
|
|
|
486
|
-
let previewEntry = yield deliveryApi.getClient(deliveryApiStatus, project).entries.get({
|
|
208
|
+
let previewEntry = yield ContensisDeliveryApi.deliveryApi.getClient(deliveryApiStatus, project).entries.get({
|
|
487
209
|
id: entryGuid,
|
|
488
210
|
language,
|
|
489
211
|
linkDepth: entryLinkDepth
|
|
490
212
|
});
|
|
491
|
-
|
|
492
213
|
if (previewEntry) {
|
|
493
214
|
pathNode = {
|
|
494
215
|
entry: previewEntry
|
|
@@ -500,9 +221,8 @@ function* getRouteSaga(action) {
|
|
|
500
221
|
}
|
|
501
222
|
} else {
|
|
502
223
|
var _pathNode, _pathNode$entry, _pathNode$entry$sys;
|
|
503
|
-
|
|
504
224
|
// Handle all other routes
|
|
505
|
-
pathNode = yield cachedSearch.getNode({
|
|
225
|
+
pathNode = yield ContensisDeliveryApi.cachedSearch.getNode({
|
|
506
226
|
depth: 0,
|
|
507
227
|
path: currentPath,
|
|
508
228
|
entryFields: setContentTypeLimits ? ['sys.contentTypeId', 'sys.id'] : staticRouteFields || '*',
|
|
@@ -513,10 +233,8 @@ function* getRouteSaga(action) {
|
|
|
513
233
|
({
|
|
514
234
|
entry
|
|
515
235
|
} = pathNode || {});
|
|
516
|
-
|
|
517
236
|
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) {
|
|
518
237
|
var _payload$items;
|
|
519
|
-
|
|
520
238
|
// Get fields[] and linkDepth from ContentTypeMapping to get the entry data
|
|
521
239
|
// and current node's ordinates at a specified depth with specified fields
|
|
522
240
|
contentTypeMapping = login.findContentTypeMapping(ContentTypeMappings, pathNode.entry.sys.contentTypeId) || {};
|
|
@@ -525,16 +243,15 @@ function* getRouteSaga(action) {
|
|
|
525
243
|
linkDepth
|
|
526
244
|
} = contentTypeMapping;
|
|
527
245
|
const query = routeEntryByFieldsQuery(pathNode.entry.sys.id, pathNode.entry.sys.language, fields, deliveryApiStatus);
|
|
528
|
-
const payload = yield cachedSearch.search(query, typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth || 0, project);
|
|
529
|
-
|
|
246
|
+
const payload = yield ContensisDeliveryApi.cachedSearch.search(query, typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth || 0, project);
|
|
530
247
|
if ((payload === null || payload === void 0 ? void 0 : (_payload$items = payload.items) === null || _payload$items === void 0 ? void 0 : _payload$items.length) > 0) {
|
|
531
248
|
pathNode.entry = entry = payload.items[0];
|
|
532
249
|
}
|
|
533
250
|
}
|
|
534
|
-
}
|
|
535
|
-
// siblings or entire node tree
|
|
536
|
-
|
|
251
|
+
}
|
|
537
252
|
|
|
253
|
+
// make calls to fetch node ancestors, children,
|
|
254
|
+
// siblings or entire node tree
|
|
538
255
|
[ancestors, children, siblings] = yield effects.call(resolveCurrentNodeOrdinates, {
|
|
539
256
|
appsays,
|
|
540
257
|
contentTypeMapping,
|
|
@@ -546,37 +263,34 @@ function* getRouteSaga(action) {
|
|
|
546
263
|
});
|
|
547
264
|
if (children) pathNode.children = children;
|
|
548
265
|
}
|
|
266
|
+
const resolvedContentTypeMapping = login.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) || {};
|
|
549
267
|
|
|
550
|
-
|
|
551
|
-
|
|
268
|
+
// Inject redux { key, reducer, saga } provided by ContentTypeMapping
|
|
552
269
|
if (resolvedContentTypeMapping.injectRedux) yield effects.call(reduxInjectorSaga, resolvedContentTypeMapping.injectRedux);
|
|
553
|
-
|
|
554
270
|
if (withEvents && withEvents.onRouteLoaded) {
|
|
555
271
|
// Check if the app has provided a requireLogin boolean flag or groups array
|
|
556
272
|
// in addition to checking if requireLogin is set in the route definition
|
|
557
273
|
({
|
|
558
274
|
requireLogin
|
|
559
|
-
} = (yield withEvents.onRouteLoaded({
|
|
275
|
+
} = (yield withEvents.onRouteLoaded({
|
|
276
|
+
...action,
|
|
560
277
|
entry
|
|
561
278
|
})) || {});
|
|
562
279
|
}
|
|
563
|
-
|
|
564
280
|
if (requireLogin !== false) {
|
|
565
281
|
// Do not call the login feature saga if requireLogin is false
|
|
566
|
-
yield effects.call(login.handleRequiresLoginSaga, {
|
|
282
|
+
yield effects.call(login.handleRequiresLoginSaga, {
|
|
283
|
+
...action,
|
|
567
284
|
entry,
|
|
568
285
|
requireLogin
|
|
569
286
|
});
|
|
570
287
|
}
|
|
571
|
-
|
|
572
288
|
if (!appsays || !appsays.preventScrollTop) {
|
|
573
289
|
// Scroll into View
|
|
574
290
|
if (typeof window !== 'undefined') window.scrollTo(0, 0);
|
|
575
291
|
}
|
|
576
|
-
|
|
577
292
|
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) {
|
|
578
293
|
var _staticRoute$route3, _staticRoute$route3$f, _appsays;
|
|
579
|
-
|
|
580
294
|
entry = pathNode.entry;
|
|
581
295
|
yield effects.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);
|
|
582
296
|
} else {
|
|
@@ -587,7 +301,6 @@ function* getRouteSaga(action) {
|
|
|
587
301
|
yield effects.call(do500, e);
|
|
588
302
|
}
|
|
589
303
|
}
|
|
590
|
-
|
|
591
304
|
function* resolveCurrentNodeOrdinates({
|
|
592
305
|
appsays,
|
|
593
306
|
contentTypeMapping,
|
|
@@ -597,10 +310,11 @@ function* resolveCurrentNodeOrdinates({
|
|
|
597
310
|
project,
|
|
598
311
|
versionStatus
|
|
599
312
|
}) {
|
|
600
|
-
const apiCall = [() => null, () => null, () => null, () => null];
|
|
313
|
+
const apiCall = [() => null, () => null, () => null, () => null];
|
|
314
|
+
|
|
315
|
+
// if appsays customNavigation: true, we will set doNavigation to false
|
|
601
316
|
// if appsays customNavigation: { ... }, we will set doNavigation to the customNavigation object and check for child elements
|
|
602
317
|
// if appsays nothing we will set doNavigation to true and continue to do navigation calls
|
|
603
|
-
|
|
604
318
|
const doNavigation = !appsays || ((appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) === true ? false : (appsays === null || appsays === void 0 ? void 0 : appsays.customNavigation) || true);
|
|
605
319
|
const {
|
|
606
320
|
entryLinkDepth = 0,
|
|
@@ -608,12 +322,11 @@ function* resolveCurrentNodeOrdinates({
|
|
|
608
322
|
linkDepth,
|
|
609
323
|
nodeOptions = {}
|
|
610
324
|
} = contentTypeMapping;
|
|
611
|
-
|
|
612
325
|
if (pathNode && pathNode.id) {
|
|
613
326
|
if (doNavigation === true || doNavigation.ancestors) {
|
|
614
327
|
apiCall[0] = function* getAncestors() {
|
|
615
328
|
try {
|
|
616
|
-
return yield cachedSearch.getAncestors({
|
|
329
|
+
return yield ContensisDeliveryApi.cachedSearch.getAncestors({
|
|
617
330
|
id: pathNode.id,
|
|
618
331
|
language,
|
|
619
332
|
versionStatus
|
|
@@ -624,15 +337,12 @@ function* resolveCurrentNodeOrdinates({
|
|
|
624
337
|
}
|
|
625
338
|
};
|
|
626
339
|
}
|
|
627
|
-
|
|
628
340
|
const childrenDepth = doNavigation === true || doNavigation.children === true ? 1 : doNavigation && doNavigation.children || 0;
|
|
629
|
-
|
|
630
341
|
if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.children) === 'undefined' && childrenDepth > 0 || nodeOptions.children) {
|
|
631
342
|
const childrenOptions = typeof nodeOptions.children === 'boolean' ? {} : nodeOptions.children;
|
|
632
|
-
|
|
633
343
|
apiCall[1] = function* getChildren() {
|
|
634
344
|
try {
|
|
635
|
-
return yield cachedSearch.getNode({
|
|
345
|
+
return yield ContensisDeliveryApi.cachedSearch.getNode({
|
|
636
346
|
depth: childrenOptions.depth !== undefined ? childrenOptions.depth : childrenDepth,
|
|
637
347
|
path,
|
|
638
348
|
entryFields: childrenOptions.fields || fields || undefined,
|
|
@@ -646,13 +356,11 @@ function* resolveCurrentNodeOrdinates({
|
|
|
646
356
|
}
|
|
647
357
|
};
|
|
648
358
|
}
|
|
649
|
-
|
|
650
359
|
if (typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : nodeOptions.siblings) === 'undefined' && doNavigation.siblings || nodeOptions.siblings) {
|
|
651
360
|
apiCall[2] = function* getSiblings() {
|
|
652
361
|
try {
|
|
653
362
|
var _nodeOptions$siblings, _nodeOptions$siblings2;
|
|
654
|
-
|
|
655
|
-
return yield cachedSearch.getSiblings({
|
|
363
|
+
return yield ContensisDeliveryApi.cachedSearch.getSiblings({
|
|
656
364
|
id: pathNode.id,
|
|
657
365
|
entryFields: (nodeOptions === null || nodeOptions === void 0 ? void 0 : (_nodeOptions$siblings = nodeOptions.siblings) === null || _nodeOptions$siblings === void 0 ? void 0 : _nodeOptions$siblings.fields) || fields || undefined,
|
|
658
366
|
entryLinkDepth: typeof (nodeOptions === null || nodeOptions === void 0 ? void 0 : (_nodeOptions$siblings2 = nodeOptions.siblings) === null || _nodeOptions$siblings2 === void 0 ? void 0 : _nodeOptions$siblings2.linkDepth) !== 'undefined' ? nodeOptions.siblings.linkDepth : typeof linkDepth !== 'undefined' ? linkDepth : entryLinkDepth,
|
|
@@ -667,11 +375,9 @@ function* resolveCurrentNodeOrdinates({
|
|
|
667
375
|
};
|
|
668
376
|
}
|
|
669
377
|
}
|
|
670
|
-
|
|
671
|
-
const isTreeLoaded = yield effects.select(version.hasNavigationTree);
|
|
378
|
+
const isTreeLoaded = yield effects.select(version$1.hasNavigationTree);
|
|
672
379
|
if (!isTreeLoaded && (doNavigation === true || doNavigation.tree)) apiCall[3] = function* getNodeTree() {
|
|
673
380
|
const treeDepth = doNavigation === true || !doNavigation.tree || doNavigation.tree === true ? 2 : doNavigation.tree;
|
|
674
|
-
|
|
675
381
|
if (typeof window !== 'undefined') {
|
|
676
382
|
return yield effects.put({
|
|
677
383
|
type: version.GET_NODE_TREE,
|
|
@@ -687,35 +393,35 @@ function* resolveCurrentNodeOrdinates({
|
|
|
687
393
|
const [ancestors, nodeWithChildren, siblings] = yield effects.all([loadAncestors(), loadChildren(), loadSiblings(), loadTree()]);
|
|
688
394
|
return [ancestors, nodeWithChildren === null || nodeWithChildren === void 0 ? void 0 : nodeWithChildren.children, siblings];
|
|
689
395
|
}
|
|
690
|
-
|
|
691
396
|
function* setRouteEntry(entry, node, ancestors, siblings, entryMapper, notFound = false, remapEntry = false) {
|
|
692
|
-
const entrySys = entry && entry.sys || {};
|
|
693
|
-
// an updated entry id in client-side navigation
|
|
397
|
+
const entrySys = entry && entry.sys || {};
|
|
694
398
|
|
|
399
|
+
// Update a window global to provide the preview toolbar
|
|
400
|
+
// an updated entry id in client-side navigation
|
|
695
401
|
if (typeof window !== 'undefined') window.ContensisEntryId = entrySys.id;
|
|
696
402
|
const currentEntryId = yield effects.select(selectors.selectRouteEntryEntryId);
|
|
697
403
|
const currentEntryLang = yield effects.select(selectors.selectRouteEntryLanguage);
|
|
698
|
-
const mappedEntry = currentEntryId === entrySys.id && currentEntryLang === entrySys.language && remapEntry === false ? (yield effects.select(selectors.selectMappedEntry, 'js')) || {} : yield mapRouteEntry(entryMapper, {
|
|
404
|
+
const mappedEntry = currentEntryId === entrySys.id && currentEntryLang === entrySys.language && remapEntry === false ? (yield effects.select(selectors.selectMappedEntry, 'js')) || {} : yield mapRouteEntry(entryMapper, {
|
|
405
|
+
...node,
|
|
699
406
|
entry,
|
|
700
407
|
ancestors,
|
|
701
408
|
siblings
|
|
702
409
|
});
|
|
703
410
|
yield effects.all([effects.put({
|
|
704
|
-
type:
|
|
411
|
+
type: selectors.SET_ENTRY,
|
|
705
412
|
id: entrySys.id,
|
|
706
413
|
entry,
|
|
707
414
|
mappedEntry,
|
|
708
415
|
node,
|
|
709
416
|
notFound
|
|
710
417
|
}), ancestors && effects.put({
|
|
711
|
-
type:
|
|
418
|
+
type: selectors.SET_ANCESTORS,
|
|
712
419
|
ancestors
|
|
713
420
|
}), siblings && effects.put({
|
|
714
|
-
type:
|
|
421
|
+
type: selectors.SET_SIBLINGS,
|
|
715
422
|
siblings
|
|
716
423
|
})]);
|
|
717
424
|
}
|
|
718
|
-
|
|
719
425
|
function* mapRouteEntry(entryMapper, node) {
|
|
720
426
|
try {
|
|
721
427
|
if (typeof entryMapper === 'function') {
|
|
@@ -726,33 +432,30 @@ function* mapRouteEntry(entryMapper, node) {
|
|
|
726
432
|
} catch (e) {
|
|
727
433
|
log__namespace.error(...['Error running entryMapper:', e, e.stack]);
|
|
728
434
|
}
|
|
729
|
-
|
|
730
435
|
return;
|
|
731
436
|
}
|
|
732
|
-
|
|
733
437
|
function* do404() {
|
|
734
438
|
yield effects.call(clientReloadHitServer);
|
|
735
439
|
yield effects.put({
|
|
736
|
-
type:
|
|
440
|
+
type: selectors.SET_ENTRY,
|
|
737
441
|
id: null,
|
|
738
442
|
entry: null,
|
|
739
443
|
notFound: true
|
|
740
444
|
});
|
|
741
445
|
}
|
|
742
|
-
|
|
743
446
|
function* clientReloadHitServer() {
|
|
744
|
-
const stateEntry = yield effects.select(selectors.selectRouteEntry);
|
|
447
|
+
const stateEntry = yield effects.select(selectors.selectRouteEntry);
|
|
448
|
+
|
|
449
|
+
// If in client and there is a stateEntry.sys field reload the page,
|
|
745
450
|
// on the 2nd load stateEntry.sys should be null at this point,
|
|
746
451
|
// we do not wish to reload again and get stuck in an infinite reloading loop
|
|
747
|
-
|
|
748
452
|
if (typeof window !== 'undefined' && (stateEntry !== null && stateEntry !== void 0 && stateEntry.sys || null)) {
|
|
749
453
|
window.location.reload();
|
|
750
454
|
}
|
|
751
455
|
}
|
|
752
|
-
|
|
753
456
|
function* do500(error) {
|
|
754
457
|
yield effects.put({
|
|
755
|
-
type:
|
|
458
|
+
type: selectors.SET_ENTRY,
|
|
756
459
|
id: null,
|
|
757
460
|
entry: null,
|
|
758
461
|
notFound: true,
|
|
@@ -761,7 +464,6 @@ function* do500(error) {
|
|
|
761
464
|
statusCode: error && error.status ? error.status : 500
|
|
762
465
|
});
|
|
763
466
|
}
|
|
764
|
-
|
|
765
467
|
function* reduxInjectorSaga(injectorFn) {
|
|
766
468
|
if (typeof injectorFn === 'function') {
|
|
767
469
|
const {
|
|
@@ -769,7 +471,7 @@ function* reduxInjectorSaga(injectorFn) {
|
|
|
769
471
|
reducer,
|
|
770
472
|
saga
|
|
771
473
|
} = yield injectorFn();
|
|
772
|
-
version.injectRedux({
|
|
474
|
+
version$1.injectRedux({
|
|
773
475
|
key,
|
|
774
476
|
reducer,
|
|
775
477
|
saga
|
|
@@ -778,19 +480,18 @@ function* reduxInjectorSaga(injectorFn) {
|
|
|
778
480
|
}
|
|
779
481
|
|
|
780
482
|
const registerSagas = [effects.takeEvery(reducers.REGISTER_USER, registerSaga), effects.takeEvery(reducers.REGISTER_USER_SUCCESS, redirectSaga)];
|
|
781
|
-
|
|
782
483
|
function* registerSaga({
|
|
783
484
|
user,
|
|
784
485
|
mappers
|
|
785
486
|
}) {
|
|
786
|
-
let requestBody = user;
|
|
487
|
+
let requestBody = user;
|
|
488
|
+
// Allow use of request mapper to take a user object
|
|
787
489
|
// of any format and return the payload for the api request
|
|
788
|
-
|
|
789
490
|
if (mappers && mappers.request && typeof mappers.request === 'function') {
|
|
790
491
|
requestBody = yield mappers.request(user);
|
|
791
|
-
}
|
|
792
|
-
|
|
492
|
+
}
|
|
793
493
|
|
|
494
|
+
// Make POST call to register API
|
|
794
495
|
const response = yield fetch('/account/register', {
|
|
795
496
|
method: 'POST',
|
|
796
497
|
headers: {
|
|
@@ -799,19 +500,16 @@ function* registerSaga({
|
|
|
799
500
|
},
|
|
800
501
|
body: JSON.stringify(requestBody)
|
|
801
502
|
});
|
|
802
|
-
|
|
803
503
|
if (response.ok) {
|
|
804
504
|
let mappedResponse;
|
|
805
505
|
const [, responseBody] = yield awaitToJs.to(response.json());
|
|
806
|
-
|
|
807
506
|
if (responseBody) {
|
|
808
507
|
// Allow use of response mapper to convert the successful user object
|
|
809
508
|
// from the api response body into a user object of any format
|
|
810
509
|
if (mappers && mappers.response && typeof mappers.response === 'function') {
|
|
811
510
|
mappedResponse = yield mappers.response(responseBody);
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
|
|
511
|
+
}
|
|
512
|
+
// Update user object with mappedResponse or responseBody
|
|
815
513
|
yield effects.put({
|
|
816
514
|
type: reducers.REGISTER_USER_SUCCESS,
|
|
817
515
|
user: mappedResponse || responseBody
|
|
@@ -830,26 +528,25 @@ function* registerSaga({
|
|
|
830
528
|
// or status codes echoed from the responses received from
|
|
831
529
|
// management api when registering the user
|
|
832
530
|
const [, errorResponse] = yield awaitToJs.to(response.json());
|
|
833
|
-
const error = errorResponse && errorResponse.error || errorResponse || {};
|
|
834
|
-
|
|
531
|
+
const error = errorResponse && errorResponse.error || errorResponse || {};
|
|
532
|
+
// Get something meaningful from the response if there is no message in the body
|
|
835
533
|
if (!error.message) {
|
|
836
534
|
error.message = `Registration service: ${response.statusText}`;
|
|
837
535
|
error.status = response.status;
|
|
838
536
|
}
|
|
839
|
-
|
|
840
537
|
yield effects.put({
|
|
841
538
|
type: reducers.REGISTER_USER_FAILED,
|
|
842
539
|
error
|
|
843
540
|
});
|
|
844
541
|
}
|
|
845
542
|
}
|
|
846
|
-
|
|
847
543
|
function* redirectSaga() {
|
|
848
544
|
// Check if querystring contains a redirect_uri
|
|
849
545
|
const currentQs = selectors.queryParams(yield effects.select(selectors.selectCurrentSearch));
|
|
850
|
-
const redirectUri = currentQs.redirect_uri || currentQs.redirect;
|
|
546
|
+
const redirectUri = currentQs.redirect_uri || currentQs.redirect;
|
|
851
547
|
|
|
852
|
-
|
|
548
|
+
// We must use redux based navigation to preserve the registration state
|
|
549
|
+
if (redirectUri) yield effects.put(selectors.setRoute(redirectUri));
|
|
853
550
|
}
|
|
854
551
|
|
|
855
552
|
const PAP_URL = 'https://pap.zengenti.com';
|
|
@@ -866,36 +563,36 @@ const BASE_OPTIONS = {
|
|
|
866
563
|
};
|
|
867
564
|
class UserHelper {
|
|
868
565
|
static async GetUsersEnvironments(securityToken) {
|
|
869
|
-
const options = {
|
|
566
|
+
const options = {
|
|
567
|
+
...BASE_OPTIONS,
|
|
870
568
|
headers: {
|
|
871
569
|
'x-security-token': securityToken
|
|
872
570
|
}
|
|
873
571
|
};
|
|
874
572
|
return await UserHelper.get(USER_ENVS_URL, options);
|
|
875
573
|
}
|
|
876
|
-
|
|
877
574
|
static async ResendUserVerification(userEmail) {
|
|
878
|
-
const options = {
|
|
575
|
+
const options = {
|
|
576
|
+
...BASE_OPTIONS
|
|
879
577
|
};
|
|
880
578
|
return await UserHelper.get(`/${USER_RESEND_VERIFICATION_URI}?user=${userEmail}`, options);
|
|
881
579
|
}
|
|
882
|
-
|
|
883
580
|
static async RequestPasswordReset(userEmailObject) {
|
|
884
|
-
const options = {
|
|
581
|
+
const options = {
|
|
582
|
+
...BASE_OPTIONS,
|
|
885
583
|
body: JSON.stringify(userEmailObject)
|
|
886
584
|
};
|
|
887
585
|
options.method = 'POST';
|
|
888
586
|
return await UserHelper.get(`/${USER_REQUEST_PASSWORD_RESET_URI}`, options);
|
|
889
587
|
}
|
|
890
|
-
|
|
891
588
|
static async ResetPassword(resetPasswordObject) {
|
|
892
|
-
const options = {
|
|
589
|
+
const options = {
|
|
590
|
+
...BASE_OPTIONS,
|
|
893
591
|
body: JSON.stringify(resetPasswordObject)
|
|
894
592
|
};
|
|
895
593
|
options.method = 'POST';
|
|
896
594
|
return await UserHelper.get(`/${USER_RESET_PASSWORD_URI}`, options);
|
|
897
595
|
}
|
|
898
|
-
|
|
899
596
|
static async get(url, options = BASE_OPTIONS) {
|
|
900
597
|
try {
|
|
901
598
|
const responseBody = await api(url, options);
|
|
@@ -908,9 +605,7 @@ class UserHelper {
|
|
|
908
605
|
};
|
|
909
606
|
}
|
|
910
607
|
}
|
|
911
|
-
|
|
912
608
|
}
|
|
913
|
-
|
|
914
609
|
async function api(url, options) {
|
|
915
610
|
return fetch(url, options).then(async response => {
|
|
916
611
|
return response.json().then(data => data);
|
|
@@ -920,17 +615,14 @@ async function api(url, options) {
|
|
|
920
615
|
}
|
|
921
616
|
|
|
922
617
|
const resetPasswordSagas = [effects.takeEvery(reducers.REQUEST_USER_PASSWORD_RESET, requestPasswordResetSaga), effects.takeEvery(reducers.RESET_USER_PASSWORD, resetPasswordSaga), effects.takeEvery(reducers.CHANGE_USER_PASSWORD, changePasswordSaga)];
|
|
923
|
-
|
|
924
618
|
function* requestPasswordResetSaga(action) {
|
|
925
619
|
const userEmailObject = action.userEmailObject;
|
|
926
620
|
yield effects.put({
|
|
927
621
|
type: reducers.REQUEST_USER_PASSWORD_RESET_SENDING
|
|
928
622
|
});
|
|
929
|
-
|
|
930
623
|
if (userEmailObject && userEmailObject.userEmail) {
|
|
931
624
|
try {
|
|
932
625
|
const passwordResetRequestResponse = yield UserHelper.RequestPasswordReset(userEmailObject);
|
|
933
|
-
|
|
934
626
|
if (passwordResetRequestResponse) {
|
|
935
627
|
if (!passwordResetRequestResponse.error) {
|
|
936
628
|
yield effects.put({
|
|
@@ -961,17 +653,14 @@ function* requestPasswordResetSaga(action) {
|
|
|
961
653
|
});
|
|
962
654
|
}
|
|
963
655
|
}
|
|
964
|
-
|
|
965
656
|
function* resetPasswordSaga(action) {
|
|
966
657
|
const resetPasswordObject = action.resetPasswordObject;
|
|
967
658
|
yield effects.put({
|
|
968
659
|
type: reducers.RESET_USER_PASSWORD_SENDING
|
|
969
660
|
});
|
|
970
|
-
|
|
971
661
|
if (resetPasswordObject.token && resetPasswordObject.password) {
|
|
972
662
|
try {
|
|
973
663
|
const resetPasswordResponse = yield UserHelper.ResetPassword(resetPasswordObject);
|
|
974
|
-
|
|
975
664
|
if (resetPasswordResponse) {
|
|
976
665
|
if (!resetPasswordResponse.error) {
|
|
977
666
|
yield effects.put({
|
|
@@ -1002,11 +691,11 @@ function* resetPasswordSaga(action) {
|
|
|
1002
691
|
error: 'Invalid object'
|
|
1003
692
|
});
|
|
1004
693
|
}
|
|
1005
|
-
}
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
// userId
|
|
1006
697
|
// existingPassword
|
|
1007
698
|
// newPassword
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
699
|
function* changePasswordSaga(action) {
|
|
1011
700
|
if (!action || !action.userId || !action.currentPassword || !action.newPassword) {
|
|
1012
701
|
yield effects.put({
|
|
@@ -1015,7 +704,6 @@ function* changePasswordSaga(action) {
|
|
|
1015
704
|
});
|
|
1016
705
|
return;
|
|
1017
706
|
}
|
|
1018
|
-
|
|
1019
707
|
try {
|
|
1020
708
|
const changePasswordObject = {
|
|
1021
709
|
userId: action.userId,
|
|
@@ -1026,25 +714,24 @@ function* changePasswordSaga(action) {
|
|
|
1026
714
|
type: reducers.CHANGE_USER_PASSWORD_SENDING
|
|
1027
715
|
});
|
|
1028
716
|
const clientCredentials = yield effects.select(ToJs.selectClientCredentials, 'js');
|
|
1029
|
-
const client = yield login.getManagementApiClient({
|
|
717
|
+
const client = yield login.getManagementApiClient({
|
|
718
|
+
...clientCredentials
|
|
1030
719
|
});
|
|
1031
720
|
const [err, res] = yield awaitToJs.to(client.security.users.updatePassword(changePasswordObject));
|
|
1032
|
-
|
|
1033
721
|
if (err) {
|
|
1034
722
|
var _err$data, _err$data$data, _err$data2;
|
|
1035
|
-
|
|
1036
723
|
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);
|
|
1037
724
|
yield effects.put({
|
|
1038
725
|
type: reducers.CHANGE_USER_PASSWORD_ERROR,
|
|
1039
726
|
error
|
|
1040
727
|
});
|
|
1041
728
|
return;
|
|
1042
|
-
}
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
// // eslint-disable-next-line no-console
|
|
1043
732
|
// console.log(changePasswordObject);
|
|
1044
733
|
// // eslint-disable-next-line no-console
|
|
1045
734
|
// console.log(userCredentialsObject);
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
735
|
yield effects.put({
|
|
1049
736
|
type: reducers.CHANGE_USER_PASSWORD_SUCCESS
|
|
1050
737
|
});
|
|
@@ -1066,35 +753,32 @@ function rootSaga (featureSagas = []) {
|
|
|
1066
753
|
};
|
|
1067
754
|
}
|
|
1068
755
|
|
|
1069
|
-
const servers = SERVERS;
|
|
1070
|
-
/* global SERVERS */
|
|
1071
|
-
|
|
756
|
+
const servers = SERVERS; /* global SERVERS */
|
|
1072
757
|
const alias = servers.alias.toLowerCase();
|
|
1073
|
-
const publicUri = PUBLIC_URI;
|
|
1074
|
-
/* global
|
|
758
|
+
const publicUri = PUBLIC_URI; /* global PUBLIC_URI */
|
|
759
|
+
const projects = PROJECTS; /* global PROJECTS */
|
|
1075
760
|
|
|
1076
|
-
const projects = PROJECTS;
|
|
1077
|
-
/* global PROJECTS */
|
|
1078
761
|
// return a projectId via the request hostname
|
|
1079
|
-
|
|
1080
762
|
const pickProject = (hostname, query) => {
|
|
1081
763
|
// if localhost we can only infer via a querystring, and take your word for it
|
|
1082
764
|
if (hostname == 'localhost') {
|
|
1083
765
|
return query && query.p || projects[0].id;
|
|
1084
|
-
}
|
|
1085
|
-
|
|
766
|
+
}
|
|
1086
767
|
|
|
768
|
+
// if hostname is the actual public uri we can return the first project from the list
|
|
1087
769
|
if (hostname == publicUri) {
|
|
1088
770
|
return projects[0].id;
|
|
1089
771
|
}
|
|
772
|
+
let project = 'unknown';
|
|
1090
773
|
|
|
1091
|
-
|
|
774
|
+
// // go through all the defined projects
|
|
1092
775
|
// Object.entries(projects).map(([, p]) => {
|
|
776
|
+
const p = projects[0];
|
|
1093
777
|
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
if (hostname.includes(p.publicUri)) project = p.id; // the url structure is different for website (we don't prefix)
|
|
778
|
+
// check if we're accessing via the project's public uri
|
|
779
|
+
if (hostname.includes(p.publicUri)) project = p.id;
|
|
1097
780
|
|
|
781
|
+
// the url structure is different for website (we don't prefix)
|
|
1098
782
|
if (p.id.startsWith('website')) {
|
|
1099
783
|
// check for internal and external hostnames
|
|
1100
784
|
// we check live and preview distinctly so our rule does not clash with
|
|
@@ -1103,9 +787,8 @@ const pickProject = (hostname, query) => {
|
|
|
1103
787
|
} else {
|
|
1104
788
|
// check for internal and external hostnames, prefixed with the projectId
|
|
1105
789
|
if (hostname.includes(`${p.id.toLowerCase()}-${alias}.cloud.contensis.com`) || hostname.includes(`${p.id.toLowerCase()}.${alias}.contensis.cloud`)) project = p.id;
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
|
|
790
|
+
}
|
|
791
|
+
// });
|
|
1109
792
|
return project === 'unknown' ? p.id : project;
|
|
1110
793
|
};
|
|
1111
794
|
|
|
@@ -1115,9 +798,7 @@ const AppRoot = props => {
|
|
|
1115
798
|
|
|
1116
799
|
exports.AppRoot = AppRoot;
|
|
1117
800
|
exports.browserHistory = browserHistory;
|
|
1118
|
-
exports.cachedSearch = cachedSearch;
|
|
1119
|
-
exports.deliveryApi = deliveryApi;
|
|
1120
801
|
exports.history = history;
|
|
1121
802
|
exports.pickProject = pickProject;
|
|
1122
803
|
exports.rootSaga = rootSaga;
|
|
1123
|
-
//# sourceMappingURL=App-
|
|
804
|
+
//# sourceMappingURL=App-2a7a16ad.js.map
|