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