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