@entur-partner/app-shell 3.0.12 → 4.0.1
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/dist/AppShell.d.ts +2 -2
- package/dist/EnvironmentBanner.d.ts +3 -2
- package/dist/OrganisationSelector.d.ts +1 -1
- package/dist/UserTypes.d.ts +2 -2
- package/dist/app-shell.cjs.development.js +214 -404
- package/dist/app-shell.cjs.development.js.map +1 -1
- package/dist/app-shell.cjs.production.min.js.map +1 -1
- package/dist/app-shell.esm.js +214 -404
- package/dist/app-shell.esm.js.map +1 -1
- package/dist/authReducer.d.ts +3 -3
- package/package.json +4 -4
package/dist/app-shell.esm.js
CHANGED
|
@@ -8,20 +8,16 @@ import { getColorForEnvironment, Environment, OrganisationDropDown } from '@entu
|
|
|
8
8
|
import createAuth0Client from '@auth0/auth0-spa-js';
|
|
9
9
|
|
|
10
10
|
function _regeneratorRuntime() {
|
|
11
|
-
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
12
|
-
|
|
13
11
|
_regeneratorRuntime = function () {
|
|
14
12
|
return exports;
|
|
15
13
|
};
|
|
16
|
-
|
|
17
14
|
var exports = {},
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
Op = Object.prototype,
|
|
16
|
+
hasOwn = Op.hasOwnProperty,
|
|
17
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
18
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
19
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
20
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
25
21
|
function define(obj, key, value) {
|
|
26
22
|
return Object.defineProperty(obj, key, {
|
|
27
23
|
value: value,
|
|
@@ -30,7 +26,6 @@ function _regeneratorRuntime() {
|
|
|
30
26
|
writable: !0
|
|
31
27
|
}), obj[key];
|
|
32
28
|
}
|
|
33
|
-
|
|
34
29
|
try {
|
|
35
30
|
define({}, "");
|
|
36
31
|
} catch (err) {
|
|
@@ -38,40 +33,33 @@ function _regeneratorRuntime() {
|
|
|
38
33
|
return obj[key] = value;
|
|
39
34
|
};
|
|
40
35
|
}
|
|
41
|
-
|
|
42
36
|
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
43
37
|
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
generator = Object.create(protoGenerator.prototype),
|
|
39
|
+
context = new Context(tryLocsList || []);
|
|
46
40
|
return generator._invoke = function (innerFn, self, context) {
|
|
47
41
|
var state = "suspendedStart";
|
|
48
42
|
return function (method, arg) {
|
|
49
43
|
if ("executing" === state) throw new Error("Generator is already running");
|
|
50
|
-
|
|
51
44
|
if ("completed" === state) {
|
|
52
45
|
if ("throw" === method) throw arg;
|
|
53
46
|
return doneResult();
|
|
54
47
|
}
|
|
55
|
-
|
|
56
48
|
for (context.method = method, context.arg = arg;;) {
|
|
57
49
|
var delegate = context.delegate;
|
|
58
|
-
|
|
59
50
|
if (delegate) {
|
|
60
51
|
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
61
|
-
|
|
62
52
|
if (delegateResult) {
|
|
63
53
|
if (delegateResult === ContinueSentinel) continue;
|
|
64
54
|
return delegateResult;
|
|
65
55
|
}
|
|
66
56
|
}
|
|
67
|
-
|
|
68
57
|
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
69
58
|
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
70
59
|
context.dispatchException(context.arg);
|
|
71
60
|
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
72
61
|
state = "executing";
|
|
73
62
|
var record = tryCatch(innerFn, self, context);
|
|
74
|
-
|
|
75
63
|
if ("normal" === record.type) {
|
|
76
64
|
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
77
65
|
return {
|
|
@@ -79,13 +67,11 @@ function _regeneratorRuntime() {
|
|
|
79
67
|
done: context.done
|
|
80
68
|
};
|
|
81
69
|
}
|
|
82
|
-
|
|
83
70
|
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
84
71
|
}
|
|
85
72
|
};
|
|
86
73
|
}(innerFn, self, context), generator;
|
|
87
74
|
}
|
|
88
|
-
|
|
89
75
|
function tryCatch(fn, obj, arg) {
|
|
90
76
|
try {
|
|
91
77
|
return {
|
|
@@ -99,25 +85,19 @@ function _regeneratorRuntime() {
|
|
|
99
85
|
};
|
|
100
86
|
}
|
|
101
87
|
}
|
|
102
|
-
|
|
103
88
|
exports.wrap = wrap;
|
|
104
89
|
var ContinueSentinel = {};
|
|
105
|
-
|
|
106
90
|
function Generator() {}
|
|
107
|
-
|
|
108
91
|
function GeneratorFunction() {}
|
|
109
|
-
|
|
110
92
|
function GeneratorFunctionPrototype() {}
|
|
111
|
-
|
|
112
93
|
var IteratorPrototype = {};
|
|
113
94
|
define(IteratorPrototype, iteratorSymbol, function () {
|
|
114
95
|
return this;
|
|
115
96
|
});
|
|
116
97
|
var getProto = Object.getPrototypeOf,
|
|
117
|
-
|
|
98
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
118
99
|
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
119
100
|
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
120
|
-
|
|
121
101
|
function defineIteratorMethods(prototype) {
|
|
122
102
|
["next", "throw", "return"].forEach(function (method) {
|
|
123
103
|
define(prototype, method, function (arg) {
|
|
@@ -125,14 +105,12 @@ function _regeneratorRuntime() {
|
|
|
125
105
|
});
|
|
126
106
|
});
|
|
127
107
|
}
|
|
128
|
-
|
|
129
108
|
function AsyncIterator(generator, PromiseImpl) {
|
|
130
109
|
function invoke(method, arg, resolve, reject) {
|
|
131
110
|
var record = tryCatch(generator[method], generator, arg);
|
|
132
|
-
|
|
133
111
|
if ("throw" !== record.type) {
|
|
134
112
|
var result = record.arg,
|
|
135
|
-
|
|
113
|
+
value = result.value;
|
|
136
114
|
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
137
115
|
invoke("next", value, resolve, reject);
|
|
138
116
|
}, function (err) {
|
|
@@ -143,89 +121,71 @@ function _regeneratorRuntime() {
|
|
|
143
121
|
return invoke("throw", error, resolve, reject);
|
|
144
122
|
});
|
|
145
123
|
}
|
|
146
|
-
|
|
147
124
|
reject(record.arg);
|
|
148
125
|
}
|
|
149
|
-
|
|
150
126
|
var previousPromise;
|
|
151
|
-
|
|
152
127
|
this._invoke = function (method, arg) {
|
|
153
128
|
function callInvokeWithMethodAndArg() {
|
|
154
129
|
return new PromiseImpl(function (resolve, reject) {
|
|
155
130
|
invoke(method, arg, resolve, reject);
|
|
156
131
|
});
|
|
157
132
|
}
|
|
158
|
-
|
|
159
133
|
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
160
134
|
};
|
|
161
135
|
}
|
|
162
|
-
|
|
163
136
|
function maybeInvokeDelegate(delegate, context) {
|
|
164
137
|
var method = delegate.iterator[context.method];
|
|
165
|
-
|
|
166
138
|
if (undefined === method) {
|
|
167
139
|
if (context.delegate = null, "throw" === context.method) {
|
|
168
140
|
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
169
141
|
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
170
142
|
}
|
|
171
|
-
|
|
172
143
|
return ContinueSentinel;
|
|
173
144
|
}
|
|
174
|
-
|
|
175
145
|
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
176
146
|
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
177
147
|
var info = record.arg;
|
|
178
148
|
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
|
179
149
|
}
|
|
180
|
-
|
|
181
150
|
function pushTryEntry(locs) {
|
|
182
151
|
var entry = {
|
|
183
152
|
tryLoc: locs[0]
|
|
184
153
|
};
|
|
185
154
|
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
186
155
|
}
|
|
187
|
-
|
|
188
156
|
function resetTryEntry(entry) {
|
|
189
157
|
var record = entry.completion || {};
|
|
190
158
|
record.type = "normal", delete record.arg, entry.completion = record;
|
|
191
159
|
}
|
|
192
|
-
|
|
193
160
|
function Context(tryLocsList) {
|
|
194
161
|
this.tryEntries = [{
|
|
195
162
|
tryLoc: "root"
|
|
196
163
|
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
197
164
|
}
|
|
198
|
-
|
|
199
165
|
function values(iterable) {
|
|
200
166
|
if (iterable) {
|
|
201
167
|
var iteratorMethod = iterable[iteratorSymbol];
|
|
202
168
|
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
203
169
|
if ("function" == typeof iterable.next) return iterable;
|
|
204
|
-
|
|
205
170
|
if (!isNaN(iterable.length)) {
|
|
206
171
|
var i = -1,
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
};
|
|
212
|
-
|
|
172
|
+
next = function next() {
|
|
173
|
+
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
174
|
+
return next.value = undefined, next.done = !0, next;
|
|
175
|
+
};
|
|
213
176
|
return next.next = next;
|
|
214
177
|
}
|
|
215
178
|
}
|
|
216
|
-
|
|
217
179
|
return {
|
|
218
180
|
next: doneResult
|
|
219
181
|
};
|
|
220
182
|
}
|
|
221
|
-
|
|
222
183
|
function doneResult() {
|
|
223
184
|
return {
|
|
224
185
|
value: undefined,
|
|
225
186
|
done: !0
|
|
226
187
|
};
|
|
227
188
|
}
|
|
228
|
-
|
|
229
189
|
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
230
190
|
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
231
191
|
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
@@ -249,15 +209,12 @@ function _regeneratorRuntime() {
|
|
|
249
209
|
return "[object Generator]";
|
|
250
210
|
}), exports.keys = function (object) {
|
|
251
211
|
var keys = [];
|
|
252
|
-
|
|
253
212
|
for (var key in object) keys.push(key);
|
|
254
|
-
|
|
255
213
|
return keys.reverse(), function next() {
|
|
256
214
|
for (; keys.length;) {
|
|
257
215
|
var key = keys.pop();
|
|
258
216
|
if (key in object) return next.value = key, next.done = !1, next;
|
|
259
217
|
}
|
|
260
|
-
|
|
261
218
|
return next.done = !0, next;
|
|
262
219
|
};
|
|
263
220
|
}, exports.values = values, Context.prototype = {
|
|
@@ -274,20 +231,16 @@ function _regeneratorRuntime() {
|
|
|
274
231
|
dispatchException: function (exception) {
|
|
275
232
|
if (this.done) throw exception;
|
|
276
233
|
var context = this;
|
|
277
|
-
|
|
278
234
|
function handle(loc, caught) {
|
|
279
235
|
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
280
236
|
}
|
|
281
|
-
|
|
282
237
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
283
238
|
var entry = this.tryEntries[i],
|
|
284
|
-
|
|
239
|
+
record = entry.completion;
|
|
285
240
|
if ("root" === entry.tryLoc) return handle("end");
|
|
286
|
-
|
|
287
241
|
if (entry.tryLoc <= this.prev) {
|
|
288
242
|
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
289
|
-
|
|
290
|
-
|
|
243
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
291
244
|
if (hasCatch && hasFinally) {
|
|
292
245
|
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
293
246
|
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
@@ -303,13 +256,11 @@ function _regeneratorRuntime() {
|
|
|
303
256
|
abrupt: function (type, arg) {
|
|
304
257
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
305
258
|
var entry = this.tryEntries[i];
|
|
306
|
-
|
|
307
259
|
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
308
260
|
var finallyEntry = entry;
|
|
309
261
|
break;
|
|
310
262
|
}
|
|
311
263
|
}
|
|
312
|
-
|
|
313
264
|
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
314
265
|
var record = finallyEntry ? finallyEntry.completion : {};
|
|
315
266
|
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
@@ -327,19 +278,15 @@ function _regeneratorRuntime() {
|
|
|
327
278
|
catch: function (tryLoc) {
|
|
328
279
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
329
280
|
var entry = this.tryEntries[i];
|
|
330
|
-
|
|
331
281
|
if (entry.tryLoc === tryLoc) {
|
|
332
282
|
var record = entry.completion;
|
|
333
|
-
|
|
334
283
|
if ("throw" === record.type) {
|
|
335
284
|
var thrown = record.arg;
|
|
336
285
|
resetTryEntry(entry);
|
|
337
286
|
}
|
|
338
|
-
|
|
339
287
|
return thrown;
|
|
340
288
|
}
|
|
341
289
|
}
|
|
342
|
-
|
|
343
290
|
throw new Error("illegal catch attempt");
|
|
344
291
|
},
|
|
345
292
|
delegateYield: function (iterable, resultName, nextLoc) {
|
|
@@ -351,7 +298,6 @@ function _regeneratorRuntime() {
|
|
|
351
298
|
}
|
|
352
299
|
}, exports;
|
|
353
300
|
}
|
|
354
|
-
|
|
355
301
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
356
302
|
try {
|
|
357
303
|
var info = gen[key](arg);
|
|
@@ -360,65 +306,53 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
360
306
|
reject(error);
|
|
361
307
|
return;
|
|
362
308
|
}
|
|
363
|
-
|
|
364
309
|
if (info.done) {
|
|
365
310
|
resolve(value);
|
|
366
311
|
} else {
|
|
367
312
|
Promise.resolve(value).then(_next, _throw);
|
|
368
313
|
}
|
|
369
314
|
}
|
|
370
|
-
|
|
371
315
|
function _asyncToGenerator(fn) {
|
|
372
316
|
return function () {
|
|
373
317
|
var self = this,
|
|
374
|
-
|
|
318
|
+
args = arguments;
|
|
375
319
|
return new Promise(function (resolve, reject) {
|
|
376
320
|
var gen = fn.apply(self, args);
|
|
377
|
-
|
|
378
321
|
function _next(value) {
|
|
379
322
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
380
323
|
}
|
|
381
|
-
|
|
382
324
|
function _throw(err) {
|
|
383
325
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
384
326
|
}
|
|
385
|
-
|
|
386
327
|
_next(undefined);
|
|
387
328
|
});
|
|
388
329
|
};
|
|
389
330
|
}
|
|
390
|
-
|
|
391
331
|
function _extends() {
|
|
392
332
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
393
333
|
for (var i = 1; i < arguments.length; i++) {
|
|
394
334
|
var source = arguments[i];
|
|
395
|
-
|
|
396
335
|
for (var key in source) {
|
|
397
336
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
398
337
|
target[key] = source[key];
|
|
399
338
|
}
|
|
400
339
|
}
|
|
401
340
|
}
|
|
402
|
-
|
|
403
341
|
return target;
|
|
404
342
|
};
|
|
405
343
|
return _extends.apply(this, arguments);
|
|
406
344
|
}
|
|
407
|
-
|
|
408
345
|
function _inheritsLoose(subClass, superClass) {
|
|
409
346
|
subClass.prototype = Object.create(superClass.prototype);
|
|
410
347
|
subClass.prototype.constructor = subClass;
|
|
411
|
-
|
|
412
348
|
_setPrototypeOf(subClass, superClass);
|
|
413
349
|
}
|
|
414
|
-
|
|
415
350
|
function _getPrototypeOf(o) {
|
|
416
351
|
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
417
352
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
418
353
|
};
|
|
419
354
|
return _getPrototypeOf(o);
|
|
420
355
|
}
|
|
421
|
-
|
|
422
356
|
function _setPrototypeOf(o, p) {
|
|
423
357
|
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
424
358
|
o.__proto__ = p;
|
|
@@ -426,12 +360,10 @@ function _setPrototypeOf(o, p) {
|
|
|
426
360
|
};
|
|
427
361
|
return _setPrototypeOf(o, p);
|
|
428
362
|
}
|
|
429
|
-
|
|
430
363
|
function _isNativeReflectConstruct() {
|
|
431
364
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
432
365
|
if (Reflect.construct.sham) return false;
|
|
433
366
|
if (typeof Proxy === "function") return true;
|
|
434
|
-
|
|
435
367
|
try {
|
|
436
368
|
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
437
369
|
return true;
|
|
@@ -439,7 +371,6 @@ function _isNativeReflectConstruct() {
|
|
|
439
371
|
return false;
|
|
440
372
|
}
|
|
441
373
|
}
|
|
442
|
-
|
|
443
374
|
function _construct(Parent, args, Class) {
|
|
444
375
|
if (_isNativeReflectConstruct()) {
|
|
445
376
|
_construct = Reflect.construct.bind();
|
|
@@ -453,34 +384,25 @@ function _construct(Parent, args, Class) {
|
|
|
453
384
|
return instance;
|
|
454
385
|
};
|
|
455
386
|
}
|
|
456
|
-
|
|
457
387
|
return _construct.apply(null, arguments);
|
|
458
388
|
}
|
|
459
|
-
|
|
460
389
|
function _isNativeFunction(fn) {
|
|
461
390
|
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
462
391
|
}
|
|
463
|
-
|
|
464
392
|
function _wrapNativeSuper(Class) {
|
|
465
393
|
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
466
|
-
|
|
467
394
|
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
468
395
|
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
469
|
-
|
|
470
396
|
if (typeof Class !== "function") {
|
|
471
397
|
throw new TypeError("Super expression must either be null or a function");
|
|
472
398
|
}
|
|
473
|
-
|
|
474
399
|
if (typeof _cache !== "undefined") {
|
|
475
400
|
if (_cache.has(Class)) return _cache.get(Class);
|
|
476
|
-
|
|
477
401
|
_cache.set(Class, Wrapper);
|
|
478
402
|
}
|
|
479
|
-
|
|
480
403
|
function Wrapper() {
|
|
481
404
|
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
482
405
|
}
|
|
483
|
-
|
|
484
406
|
Wrapper.prototype = Object.create(Class.prototype, {
|
|
485
407
|
constructor: {
|
|
486
408
|
value: Wrapper,
|
|
@@ -491,22 +413,18 @@ function _wrapNativeSuper(Class) {
|
|
|
491
413
|
});
|
|
492
414
|
return _setPrototypeOf(Wrapper, Class);
|
|
493
415
|
};
|
|
494
|
-
|
|
495
416
|
return _wrapNativeSuper(Class);
|
|
496
417
|
}
|
|
497
|
-
|
|
498
418
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
499
419
|
if (source == null) return {};
|
|
500
420
|
var target = {};
|
|
501
421
|
var sourceKeys = Object.keys(source);
|
|
502
422
|
var key, i;
|
|
503
|
-
|
|
504
423
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
505
424
|
key = sourceKeys[i];
|
|
506
425
|
if (excluded.indexOf(key) >= 0) continue;
|
|
507
426
|
target[key] = source[key];
|
|
508
427
|
}
|
|
509
|
-
|
|
510
428
|
return target;
|
|
511
429
|
}
|
|
512
430
|
|
|
@@ -520,21 +438,17 @@ function authReducer(state, event) {
|
|
|
520
438
|
status: 'AUTHENTICATED',
|
|
521
439
|
user: event.data.user
|
|
522
440
|
};
|
|
523
|
-
|
|
524
441
|
case 'LOGOUT':
|
|
525
442
|
return initialState$1;
|
|
526
|
-
|
|
527
443
|
case 'ERROR':
|
|
528
444
|
return {
|
|
529
445
|
error: event.error,
|
|
530
446
|
status: 'ERROR'
|
|
531
447
|
};
|
|
532
|
-
|
|
533
448
|
case 'NOT_AUTHENTICATED':
|
|
534
449
|
return _extends({}, state, {
|
|
535
450
|
status: 'NOT_AUTHENTICATED'
|
|
536
451
|
});
|
|
537
|
-
|
|
538
452
|
default:
|
|
539
453
|
return state;
|
|
540
454
|
}
|
|
@@ -543,16 +457,12 @@ function authReducer(state, event) {
|
|
|
543
457
|
var _excluded$2 = ["children", "decorateUser"];
|
|
544
458
|
var POST_LOGIN_ROUTE_KEY = '@entur-partner:post-login-route';
|
|
545
459
|
var LOGIN_LAST_RETRY = '@entur-partner:last-login-retry';
|
|
546
|
-
|
|
547
460
|
var redirect = function redirect(pathname) {
|
|
548
461
|
if (pathname === void 0) {
|
|
549
462
|
pathname = '/';
|
|
550
463
|
}
|
|
551
|
-
|
|
552
464
|
return window.history.replaceState({}, document.title, pathname);
|
|
553
465
|
}; // TODO: replace with react-router history
|
|
554
|
-
|
|
555
|
-
|
|
556
466
|
var Auth0Context = /*#__PURE__*/React.createContext(undefined);
|
|
557
467
|
var useAuth = function useAuth() {
|
|
558
468
|
var auth = useContext(Auth0Context);
|
|
@@ -564,222 +474,178 @@ var initialState = {
|
|
|
564
474
|
};
|
|
565
475
|
var AuthProvider = function AuthProvider(_ref) {
|
|
566
476
|
var children = _ref.children,
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
477
|
+
decorateUser = _ref.decorateUser,
|
|
478
|
+
initOptions = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
570
479
|
var _useReducer = useReducer(authReducer, initialState),
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
480
|
+
state = _useReducer[0],
|
|
481
|
+
dispatch = _useReducer[1];
|
|
574
482
|
var _useState = useState(),
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
483
|
+
auth0Client = _useState[0],
|
|
484
|
+
setAuth0 = _useState[1];
|
|
578
485
|
useEffect(function () {
|
|
579
486
|
var initAuth0 = /*#__PURE__*/function () {
|
|
580
487
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
581
488
|
var client, route, postLoginRoute, isAuthenticated, auth0User, token, user;
|
|
582
489
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
583
|
-
while (1) {
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
if (!window.location.search.includes('code=')) {
|
|
594
|
-
_context.next = 11;
|
|
595
|
-
break;
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
_context.next = 7;
|
|
599
|
-
return client.handleRedirectCallback();
|
|
600
|
-
|
|
601
|
-
case 7:
|
|
602
|
-
route = localStorage.getItem(POST_LOGIN_ROUTE_KEY);
|
|
603
|
-
localStorage.removeItem(POST_LOGIN_ROUTE_KEY);
|
|
604
|
-
postLoginRoute = route || '/';
|
|
605
|
-
redirect(postLoginRoute);
|
|
606
|
-
|
|
607
|
-
case 11:
|
|
608
|
-
_context.next = 13;
|
|
609
|
-
return client.isAuthenticated();
|
|
610
|
-
|
|
611
|
-
case 13:
|
|
612
|
-
isAuthenticated = _context.sent;
|
|
613
|
-
|
|
614
|
-
if (!isAuthenticated) {
|
|
615
|
-
_context.next = 27;
|
|
616
|
-
break;
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
_context.next = 17;
|
|
620
|
-
return client.getUser();
|
|
621
|
-
|
|
622
|
-
case 17:
|
|
623
|
-
auth0User = _context.sent;
|
|
624
|
-
_context.next = 20;
|
|
625
|
-
return client.getTokenSilently();
|
|
626
|
-
|
|
627
|
-
case 20:
|
|
628
|
-
token = _context.sent;
|
|
629
|
-
_context.next = 23;
|
|
630
|
-
return decorateUser(auth0User, token);
|
|
631
|
-
|
|
632
|
-
case 23:
|
|
633
|
-
user = _context.sent;
|
|
634
|
-
dispatch({
|
|
635
|
-
type: 'AUTHENTICATED',
|
|
636
|
-
data: {
|
|
637
|
-
user: user
|
|
638
|
-
}
|
|
639
|
-
});
|
|
640
|
-
_context.next = 28;
|
|
490
|
+
while (1) switch (_context.prev = _context.next) {
|
|
491
|
+
case 0:
|
|
492
|
+
_context.next = 2;
|
|
493
|
+
return createAuth0Client(initOptions);
|
|
494
|
+
case 2:
|
|
495
|
+
client = _context.sent;
|
|
496
|
+
setAuth0(client);
|
|
497
|
+
if (!window.location.search.includes('code=')) {
|
|
498
|
+
_context.next = 11;
|
|
641
499
|
break;
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
500
|
+
}
|
|
501
|
+
_context.next = 7;
|
|
502
|
+
return client.handleRedirectCallback();
|
|
503
|
+
case 7:
|
|
504
|
+
route = localStorage.getItem(POST_LOGIN_ROUTE_KEY);
|
|
505
|
+
localStorage.removeItem(POST_LOGIN_ROUTE_KEY);
|
|
506
|
+
postLoginRoute = route || '/';
|
|
507
|
+
redirect(postLoginRoute);
|
|
508
|
+
case 11:
|
|
509
|
+
_context.next = 13;
|
|
510
|
+
return client.isAuthenticated();
|
|
511
|
+
case 13:
|
|
512
|
+
isAuthenticated = _context.sent;
|
|
513
|
+
if (!isAuthenticated) {
|
|
514
|
+
_context.next = 27;
|
|
515
|
+
break;
|
|
516
|
+
}
|
|
517
|
+
_context.next = 17;
|
|
518
|
+
return client.getUser();
|
|
519
|
+
case 17:
|
|
520
|
+
auth0User = _context.sent;
|
|
521
|
+
_context.next = 20;
|
|
522
|
+
return client.getTokenSilently();
|
|
523
|
+
case 20:
|
|
524
|
+
token = _context.sent;
|
|
525
|
+
_context.next = 23;
|
|
526
|
+
return decorateUser(auth0User, token);
|
|
527
|
+
case 23:
|
|
528
|
+
user = _context.sent;
|
|
529
|
+
dispatch({
|
|
530
|
+
type: 'AUTHENTICATED',
|
|
531
|
+
data: {
|
|
532
|
+
user: user
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
_context.next = 28;
|
|
536
|
+
break;
|
|
537
|
+
case 27:
|
|
538
|
+
dispatch({
|
|
539
|
+
type: 'NOT_AUTHENTICATED'
|
|
540
|
+
});
|
|
541
|
+
case 28:
|
|
542
|
+
case "end":
|
|
543
|
+
return _context.stop();
|
|
652
544
|
}
|
|
653
545
|
}, _callee);
|
|
654
546
|
}));
|
|
655
|
-
|
|
656
547
|
return function initAuth0() {
|
|
657
548
|
return _ref2.apply(this, arguments);
|
|
658
549
|
};
|
|
659
550
|
}();
|
|
660
|
-
|
|
661
551
|
initAuth0()["catch"]( /*#__PURE__*/function () {
|
|
662
552
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(error) {
|
|
663
553
|
var _localStorage$getItem, lastRetryEpochSeconds, nowEpochSeconds, timeSinceLastRetry, minimumTimeForRetry;
|
|
664
|
-
|
|
665
554
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
666
|
-
while (1) {
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
if (!(timeSinceLastRetry >= minimumTimeForRetry)) {
|
|
676
|
-
_context2.next = 12;
|
|
677
|
-
break;
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
localStorage.setItem(LOGIN_LAST_RETRY, nowEpochSeconds.toString());
|
|
681
|
-
redirect('/');
|
|
682
|
-
_context2.next = 10;
|
|
683
|
-
return initAuth0();
|
|
684
|
-
|
|
685
|
-
case 10:
|
|
686
|
-
_context2.next = 13;
|
|
687
|
-
break;
|
|
688
|
-
|
|
689
|
-
case 12:
|
|
690
|
-
throw error;
|
|
691
|
-
|
|
692
|
-
case 13:
|
|
693
|
-
_context2.next = 18;
|
|
555
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
556
|
+
case 0:
|
|
557
|
+
_context2.prev = 0;
|
|
558
|
+
lastRetryEpochSeconds = parseInt((_localStorage$getItem = localStorage.getItem(LOGIN_LAST_RETRY)) != null ? _localStorage$getItem : '0');
|
|
559
|
+
nowEpochSeconds = Math.floor(Date.now() / 1000);
|
|
560
|
+
timeSinceLastRetry = nowEpochSeconds - lastRetryEpochSeconds;
|
|
561
|
+
minimumTimeForRetry = 120; // Has there been more than x seconds since last retry?
|
|
562
|
+
if (!(timeSinceLastRetry >= minimumTimeForRetry)) {
|
|
563
|
+
_context2.next = 12;
|
|
694
564
|
break;
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
565
|
+
}
|
|
566
|
+
localStorage.setItem(LOGIN_LAST_RETRY, nowEpochSeconds.toString());
|
|
567
|
+
redirect('/');
|
|
568
|
+
_context2.next = 10;
|
|
569
|
+
return initAuth0();
|
|
570
|
+
case 10:
|
|
571
|
+
_context2.next = 13;
|
|
572
|
+
break;
|
|
573
|
+
case 12:
|
|
574
|
+
throw error;
|
|
575
|
+
case 13:
|
|
576
|
+
_context2.next = 18;
|
|
577
|
+
break;
|
|
578
|
+
case 15:
|
|
579
|
+
_context2.prev = 15;
|
|
580
|
+
_context2.t0 = _context2["catch"](0);
|
|
581
|
+
dispatch({
|
|
582
|
+
type: 'ERROR',
|
|
583
|
+
error: error
|
|
584
|
+
});
|
|
585
|
+
case 18:
|
|
586
|
+
case "end":
|
|
587
|
+
return _context2.stop();
|
|
708
588
|
}
|
|
709
589
|
}, _callee2, null, [[0, 15]]);
|
|
710
590
|
}));
|
|
711
|
-
|
|
712
591
|
return function (_x) {
|
|
713
592
|
return _ref3.apply(this, arguments);
|
|
714
593
|
};
|
|
715
|
-
}());
|
|
594
|
+
}());
|
|
595
|
+
// eslint-disable-next-line
|
|
716
596
|
}, []);
|
|
717
|
-
|
|
718
597
|
var logout = function logout() {
|
|
719
598
|
assertIsDefined(auth0Client);
|
|
720
599
|
var _window$location = window.location,
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
600
|
+
protocol = _window$location.protocol,
|
|
601
|
+
hostname = _window$location.hostname,
|
|
602
|
+
port = _window$location.port;
|
|
724
603
|
auth0Client.logout({
|
|
725
604
|
returnTo: protocol + "//" + hostname + ":" + port
|
|
726
605
|
});
|
|
727
606
|
};
|
|
728
|
-
|
|
729
607
|
var login = /*#__PURE__*/function () {
|
|
730
608
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(redirectUri) {
|
|
731
609
|
var _window, location;
|
|
732
|
-
|
|
733
610
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
734
|
-
while (1) {
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
case 5:
|
|
749
|
-
case "end":
|
|
750
|
-
return _context3.stop();
|
|
751
|
-
}
|
|
611
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
612
|
+
case 0:
|
|
613
|
+
if (redirectUri === void 0) {
|
|
614
|
+
redirectUri = window.location.origin;
|
|
615
|
+
}
|
|
616
|
+
assertIsDefined(auth0Client);
|
|
617
|
+
_window = window, location = _window.location;
|
|
618
|
+
localStorage.setItem(POST_LOGIN_ROUTE_KEY, "" + location.pathname + location.search);
|
|
619
|
+
auth0Client.loginWithRedirect({
|
|
620
|
+
redirect_uri: redirectUri
|
|
621
|
+
});
|
|
622
|
+
case 5:
|
|
623
|
+
case "end":
|
|
624
|
+
return _context3.stop();
|
|
752
625
|
}
|
|
753
626
|
}, _callee3);
|
|
754
627
|
}));
|
|
755
|
-
|
|
756
628
|
return function login(_x2) {
|
|
757
629
|
return _ref4.apply(this, arguments);
|
|
758
630
|
};
|
|
759
631
|
}();
|
|
760
|
-
|
|
761
632
|
var getToken = /*#__PURE__*/function () {
|
|
762
633
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(options) {
|
|
763
634
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
764
|
-
while (1) {
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
case "end":
|
|
772
|
-
return _context4.stop();
|
|
773
|
-
}
|
|
635
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
636
|
+
case 0:
|
|
637
|
+
assertIsDefined(auth0Client);
|
|
638
|
+
return _context4.abrupt("return", auth0Client.getTokenSilently(options));
|
|
639
|
+
case 2:
|
|
640
|
+
case "end":
|
|
641
|
+
return _context4.stop();
|
|
774
642
|
}
|
|
775
643
|
}, _callee4);
|
|
776
644
|
}));
|
|
777
|
-
|
|
778
645
|
return function getToken(_x3) {
|
|
779
646
|
return _ref5.apply(this, arguments);
|
|
780
647
|
};
|
|
781
648
|
}();
|
|
782
|
-
|
|
783
649
|
return React.createElement(Auth0Context.Provider, {
|
|
784
650
|
value: _extends({}, state, {
|
|
785
651
|
auth0Client: auth0Client,
|
|
@@ -809,33 +675,27 @@ var EnvironmentBanner = function EnvironmentBanner(_ref) {
|
|
|
809
675
|
|
|
810
676
|
var Login = function Login(_ref) {
|
|
811
677
|
var redirectUri = _ref.redirectUri;
|
|
812
|
-
|
|
813
678
|
var _useAuth = useAuth(),
|
|
814
|
-
|
|
815
|
-
|
|
679
|
+
login = _useAuth.login;
|
|
816
680
|
useEffect(function () {
|
|
817
681
|
login(redirectUri);
|
|
818
682
|
}, [login, redirectUri]);
|
|
819
683
|
return null;
|
|
820
684
|
};
|
|
821
|
-
|
|
822
685
|
var Authenticate = function Authenticate(_ref2) {
|
|
823
686
|
var children = _ref2.children,
|
|
824
|
-
|
|
825
|
-
|
|
687
|
+
redirectUri = _ref2.redirectUri;
|
|
826
688
|
var _useAuth2 = useAuth(),
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
689
|
+
status = _useAuth2.status,
|
|
690
|
+
user = _useAuth2.user,
|
|
691
|
+
error = _useAuth2.error,
|
|
692
|
+
logout = _useAuth2.logout,
|
|
693
|
+
getToken = _useAuth2.getToken;
|
|
833
694
|
switch (status) {
|
|
834
695
|
case 'NOT_AUTHENTICATED':
|
|
835
696
|
return React.createElement(Login, {
|
|
836
697
|
redirectUri: redirectUri
|
|
837
698
|
});
|
|
838
|
-
|
|
839
699
|
case 'AUTHENTICATED':
|
|
840
700
|
assertIsDefined(user);
|
|
841
701
|
return React.createElement(React.Fragment, null, children({
|
|
@@ -843,14 +703,12 @@ var Authenticate = function Authenticate(_ref2) {
|
|
|
843
703
|
logout: logout,
|
|
844
704
|
getToken: getToken
|
|
845
705
|
}));
|
|
846
|
-
|
|
847
706
|
case 'AUTHENTICATING':
|
|
848
707
|
return React.createElement(Loader, {
|
|
849
708
|
style: {
|
|
850
709
|
marginTop: space.extraLarge9
|
|
851
710
|
}
|
|
852
711
|
}, "Authenticating");
|
|
853
|
-
|
|
854
712
|
case 'ERROR':
|
|
855
713
|
process.env.NODE_ENV !== 'production' && console.error(error);
|
|
856
714
|
return React.createElement(BannerAlertBox, {
|
|
@@ -863,20 +721,18 @@ var Authenticate = function Authenticate(_ref2) {
|
|
|
863
721
|
}, React.createElement(Paragraph, null, "Something went wrong while trying to authenticate you. If the problem persists you should contact", ' ', React.createElement(Link, {
|
|
864
722
|
href: "mailto:support@entur.org"
|
|
865
723
|
}, "support@entur.org"), " to get it resolved."), React.createElement(Paragraph, null, "Authentication failed with: ", React.createElement(CodeText, null, error == null ? void 0 : error.toString())));
|
|
866
|
-
|
|
867
724
|
default:
|
|
868
725
|
return null;
|
|
869
726
|
}
|
|
870
727
|
};
|
|
871
|
-
|
|
872
728
|
var AppShell = function AppShell(_ref3) {
|
|
873
729
|
var children = _ref3.children,
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
730
|
+
audience = _ref3.audience,
|
|
731
|
+
domain = _ref3.domain,
|
|
732
|
+
clientId = _ref3.clientId,
|
|
733
|
+
redirectUri = _ref3.redirectUri,
|
|
734
|
+
decorateUser = _ref3.decorateUser,
|
|
735
|
+
environment = _ref3.environment;
|
|
880
736
|
return React.createElement(AuthProvider, {
|
|
881
737
|
audience: audience,
|
|
882
738
|
domain: domain,
|
|
@@ -892,18 +748,15 @@ var AppShell = function AppShell(_ref3) {
|
|
|
892
748
|
};
|
|
893
749
|
|
|
894
750
|
var _excluded$1 = ["navigate", "children", "onClick", "target"];
|
|
895
|
-
|
|
896
751
|
function isModifiedEvent(event) {
|
|
897
752
|
return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
|
|
898
753
|
}
|
|
899
|
-
|
|
900
754
|
var MicroFrontendLink = function MicroFrontendLink(_ref) {
|
|
901
755
|
var navigate = _ref.navigate,
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
756
|
+
children = _ref.children,
|
|
757
|
+
_onClick = _ref.onClick,
|
|
758
|
+
target = _ref.target,
|
|
759
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
907
760
|
return React.createElement("a", _extends({
|
|
908
761
|
onClick: function onClick(event) {
|
|
909
762
|
try {
|
|
@@ -912,10 +765,12 @@ var MicroFrontendLink = function MicroFrontendLink(_ref) {
|
|
|
912
765
|
event.preventDefault();
|
|
913
766
|
throw ex;
|
|
914
767
|
}
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
event.button === 0 && (
|
|
918
|
-
|
|
768
|
+
if (!event.defaultPrevented &&
|
|
769
|
+
// onClick prevented default
|
|
770
|
+
event.button === 0 && (
|
|
771
|
+
// ignore everything but right clicks
|
|
772
|
+
!target || target === '_self') &&
|
|
773
|
+
// let browser handle "target=_blank" etc.
|
|
919
774
|
!isModifiedEvent(event) // ignore clicks with modifier keys
|
|
920
775
|
) {
|
|
921
776
|
event.preventDefault();
|
|
@@ -945,47 +800,37 @@ var useMenu = function useMenu() {
|
|
|
945
800
|
};
|
|
946
801
|
var useMFNavigation = function useMFNavigation(path) {
|
|
947
802
|
var _useMenu = useMenu(),
|
|
948
|
-
|
|
949
|
-
|
|
803
|
+
getMFNavigate = _useMenu.getMFNavigate;
|
|
950
804
|
return getMFNavigate(path);
|
|
951
805
|
};
|
|
952
806
|
var MenuProvider = function MenuProvider(_ref) {
|
|
953
807
|
var children = _ref.children;
|
|
954
|
-
|
|
955
808
|
var _useState = useState({}),
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
809
|
+
groups = _useState[0],
|
|
810
|
+
setGroups = _useState[1];
|
|
959
811
|
var _useState2 = useState({}),
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
812
|
+
navFuncs = _useState2[0],
|
|
813
|
+
setNavFuncs = _useState2[1];
|
|
963
814
|
var addItems = useCallback(function (newItems, path) {
|
|
964
815
|
setGroups(function (prevState) {
|
|
965
816
|
var _extends2;
|
|
966
|
-
|
|
967
817
|
return _extends({}, prevState, (_extends2 = {}, _extends2[path] = newItems, _extends2));
|
|
968
818
|
});
|
|
969
819
|
}, [setGroups]);
|
|
970
|
-
|
|
971
820
|
var getMFNavigate = function getMFNavigate(path) {
|
|
972
821
|
return navFuncs[path];
|
|
973
822
|
};
|
|
974
|
-
|
|
975
823
|
var setMFNavigate = function setMFNavigate(path, navigation) {
|
|
976
824
|
return setNavFuncs(function (prev) {
|
|
977
825
|
var _extends3;
|
|
978
|
-
|
|
979
826
|
return _extends({}, prev, (_extends3 = {}, _extends3[path] = navigation, _extends3));
|
|
980
827
|
});
|
|
981
828
|
};
|
|
982
|
-
|
|
983
829
|
return React.createElement(MenuContext.Provider, {
|
|
984
830
|
value: {
|
|
985
831
|
addItems: addItems,
|
|
986
832
|
getItemsForPath: function getItemsForPath(path) {
|
|
987
833
|
var _groups$path;
|
|
988
|
-
|
|
989
834
|
return (_groups$path = groups[path]) != null ? _groups$path : [];
|
|
990
835
|
},
|
|
991
836
|
getMFNavigate: getMFNavigate,
|
|
@@ -1024,26 +869,21 @@ var useOrganisationId = function useOrganisationId() {
|
|
|
1024
869
|
assertIsDefined(context);
|
|
1025
870
|
return context.organisationId;
|
|
1026
871
|
};
|
|
1027
|
-
|
|
1028
872
|
var useOrganisationState = function useOrganisationState(initialOrganisationId) {
|
|
1029
873
|
var _useState = useState(Number(initialOrganisationId)),
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
874
|
+
organisationId = _useState[0],
|
|
875
|
+
setOrganisationId = _useState[1];
|
|
1033
876
|
useEffect(function () {
|
|
1034
877
|
organisationStorage.set(organisationId.toString());
|
|
1035
878
|
}, [organisationId]);
|
|
1036
879
|
return [organisationId, setOrganisationId];
|
|
1037
880
|
};
|
|
1038
|
-
|
|
1039
881
|
var OrganisationProvider = function OrganisationProvider(_ref) {
|
|
1040
882
|
var children = _ref.children,
|
|
1041
|
-
|
|
1042
|
-
|
|
883
|
+
organisationId = _ref.organisationId;
|
|
1043
884
|
var _useOrganisationState = useOrganisationState(organisationId),
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
885
|
+
orgId = _useOrganisationState[0],
|
|
886
|
+
setOrganisationId = _useOrganisationState[1];
|
|
1047
887
|
return React.createElement(OrganisationContext.Provider, {
|
|
1048
888
|
value: {
|
|
1049
889
|
organisationId: orgId,
|
|
@@ -1053,18 +893,15 @@ var OrganisationProvider = function OrganisationProvider(_ref) {
|
|
|
1053
893
|
};
|
|
1054
894
|
|
|
1055
895
|
var LanguageContext = /*#__PURE__*/React.createContext(undefined);
|
|
1056
|
-
|
|
1057
896
|
var useLanguageState = function useLanguageState(language) {
|
|
1058
897
|
var _useState = useState(language),
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
898
|
+
activeLanguage = _useState[0],
|
|
899
|
+
setLanguage = _useState[1];
|
|
1062
900
|
useEffect(function () {
|
|
1063
901
|
languageStorage.set(activeLanguage);
|
|
1064
902
|
}, [activeLanguage]);
|
|
1065
903
|
return [activeLanguage, setLanguage];
|
|
1066
904
|
};
|
|
1067
|
-
|
|
1068
905
|
var useLanguage = function useLanguage() {
|
|
1069
906
|
var context = useContext(LanguageContext);
|
|
1070
907
|
assertIsDefined(context);
|
|
@@ -1072,12 +909,10 @@ var useLanguage = function useLanguage() {
|
|
|
1072
909
|
};
|
|
1073
910
|
var LanguageProvider = function LanguageProvider(_ref) {
|
|
1074
911
|
var children = _ref.children,
|
|
1075
|
-
|
|
1076
|
-
|
|
912
|
+
language = _ref.language;
|
|
1077
913
|
var _useLanguageState = useLanguageState(language),
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
914
|
+
activeLanguage = _useLanguageState[0],
|
|
915
|
+
setLanguage = _useLanguageState[1];
|
|
1081
916
|
return React.createElement(LanguageContext.Provider, {
|
|
1082
917
|
value: {
|
|
1083
918
|
language: activeLanguage,
|
|
@@ -1088,108 +923,86 @@ var LanguageProvider = function LanguageProvider(_ref) {
|
|
|
1088
923
|
|
|
1089
924
|
var OrganisationsError = /*#__PURE__*/function (_Error) {
|
|
1090
925
|
_inheritsLoose(OrganisationsError, _Error);
|
|
1091
|
-
|
|
1092
926
|
function OrganisationsError() {
|
|
1093
927
|
var _this;
|
|
1094
|
-
|
|
1095
928
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1096
929
|
args[_key] = arguments[_key];
|
|
1097
930
|
}
|
|
1098
|
-
|
|
1099
931
|
_this = _Error.call.apply(_Error, [this].concat(args)) || this;
|
|
1100
932
|
_this.message = 'Failed fetching organisations';
|
|
1101
933
|
return _this;
|
|
1102
934
|
}
|
|
1103
|
-
|
|
1104
935
|
return OrganisationsError;
|
|
1105
936
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
1106
937
|
|
|
1107
938
|
var _excluded = ["getToken", "getOrganisations", "value", "onChange"];
|
|
1108
939
|
var OrganisationSelector = function OrganisationSelector(_ref) {
|
|
1109
940
|
var getToken = _ref.getToken,
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
941
|
+
getOrganisations = _ref.getOrganisations,
|
|
942
|
+
value = _ref.value,
|
|
943
|
+
onChange = _ref.onChange,
|
|
944
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
1115
945
|
var _useState = useState([]),
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
946
|
+
organisations = _useState[0],
|
|
947
|
+
setOrganisations = _useState[1];
|
|
1119
948
|
var _useLanguage = useLanguage(),
|
|
1120
|
-
|
|
1121
|
-
|
|
949
|
+
language = _useLanguage.language;
|
|
1122
950
|
var _useState2 = useState('LOADING'),
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
951
|
+
status = _useState2[0],
|
|
952
|
+
setStatus = _useState2[1];
|
|
1126
953
|
useEffect(function () {
|
|
1127
954
|
var fetchOrganisations = /*#__PURE__*/function () {
|
|
1128
955
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1129
956
|
var token, organisations;
|
|
1130
957
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1131
|
-
while (1) {
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
if (!(typeof getOrganisations === 'string')) {
|
|
1141
|
-
_context.next = 9;
|
|
1142
|
-
break;
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
_context.next = 6;
|
|
1146
|
-
return fetch(getOrganisations, {
|
|
1147
|
-
headers: {
|
|
1148
|
-
Authorization: "Bearer " + token,
|
|
1149
|
-
Accept: 'application/json'
|
|
1150
|
-
}
|
|
1151
|
-
}).then(function (response) {
|
|
1152
|
-
return response.json();
|
|
1153
|
-
});
|
|
1154
|
-
|
|
1155
|
-
case 6:
|
|
1156
|
-
organisations = _context.sent;
|
|
1157
|
-
_context.next = 12;
|
|
958
|
+
while (1) switch (_context.prev = _context.next) {
|
|
959
|
+
case 0:
|
|
960
|
+
_context.next = 2;
|
|
961
|
+
return getToken();
|
|
962
|
+
case 2:
|
|
963
|
+
token = _context.sent;
|
|
964
|
+
if (!(typeof getOrganisations === 'string')) {
|
|
965
|
+
_context.next = 9;
|
|
1158
966
|
break;
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
967
|
+
}
|
|
968
|
+
_context.next = 6;
|
|
969
|
+
return fetch(getOrganisations, {
|
|
970
|
+
headers: {
|
|
971
|
+
Authorization: "Bearer " + token,
|
|
972
|
+
Accept: 'application/json'
|
|
973
|
+
}
|
|
974
|
+
}).then(function (response) {
|
|
975
|
+
return response.json();
|
|
976
|
+
});
|
|
977
|
+
case 6:
|
|
978
|
+
organisations = _context.sent;
|
|
979
|
+
_context.next = 12;
|
|
980
|
+
break;
|
|
981
|
+
case 9:
|
|
982
|
+
_context.next = 11;
|
|
983
|
+
return getOrganisations(token);
|
|
984
|
+
case 11:
|
|
985
|
+
organisations = _context.sent;
|
|
986
|
+
case 12:
|
|
987
|
+
setOrganisations(organisations);
|
|
988
|
+
setStatus('SUCCESS');
|
|
989
|
+
case 14:
|
|
990
|
+
case "end":
|
|
991
|
+
return _context.stop();
|
|
1175
992
|
}
|
|
1176
993
|
}, _callee);
|
|
1177
994
|
}));
|
|
1178
|
-
|
|
1179
995
|
return function fetchOrganisations() {
|
|
1180
996
|
return _ref2.apply(this, arguments);
|
|
1181
997
|
};
|
|
1182
998
|
}();
|
|
1183
|
-
|
|
1184
999
|
fetchOrganisations()["catch"](function (error) {
|
|
1185
1000
|
if (process.env.NODE_ENV === 'development') {
|
|
1186
1001
|
console.error(error);
|
|
1187
1002
|
}
|
|
1188
|
-
|
|
1189
1003
|
setStatus('ERROR');
|
|
1190
1004
|
});
|
|
1191
1005
|
}, [getOrganisations, getToken]);
|
|
1192
|
-
|
|
1193
1006
|
switch (status) {
|
|
1194
1007
|
case 'LOADING':
|
|
1195
1008
|
return React.createElement("div", {
|
|
@@ -1199,7 +1012,6 @@ var OrganisationSelector = function OrganisationSelector(_ref) {
|
|
|
1199
1012
|
height: '2.4rem'
|
|
1200
1013
|
}
|
|
1201
1014
|
}));
|
|
1202
|
-
|
|
1203
1015
|
case 'SUCCESS':
|
|
1204
1016
|
return React.createElement(OrganisationDropDown, _extends({
|
|
1205
1017
|
label: language === 'nb' ? 'Organisasjon' : 'Organisation',
|
|
@@ -1207,10 +1019,8 @@ var OrganisationSelector = function OrganisationSelector(_ref) {
|
|
|
1207
1019
|
organisations: organisations,
|
|
1208
1020
|
onChange: onChange
|
|
1209
1021
|
}, rest));
|
|
1210
|
-
|
|
1211
1022
|
case 'ERROR':
|
|
1212
1023
|
throw new OrganisationsError();
|
|
1213
|
-
|
|
1214
1024
|
default:
|
|
1215
1025
|
return null;
|
|
1216
1026
|
}
|