-
Notifications
You must be signed in to change notification settings - Fork 59
/
routes.js
835 lines (774 loc) · 26.1 KB
/
routes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
/*
Copyright 2020 ODK Central Developers
See the NOTICE file at the top-level directory of this distribution and at
https://github.com/getodk/central-frontend/blob/master/NOTICE.
This file is part of ODK Central. It is subject to the license terms in
the LICENSE file found in the top-level directory of this distribution and at
https://www.apache.org/licenses/LICENSE-2.0. No part of ODK Central,
including this file, may be copied, modified, propagated, or distributed
except according to the terms contained in the LICENSE file.
*/
import { always, equals } from 'ramda';
import AccountLogin from './components/account/login.vue';
import AsyncRoute from './components/async-route.vue';
import { routeProps } from './util/router';
export default (container) => {
/* eslint-disable indent */ // TODO/vue3
/*
Lazy-Loading Routes
-------------------
We lazy-load all routes except for /login. We show a loading message while the
async component is loading and an alert if there is a load error. Note that
while Vue provides similar loading-state functionality for async components, Vue
Router does not support it directly: see
https://github.com/vuejs/vue-router/pull/2140. Instead, we use a wrapper
component, AsyncRoute, that will load and render the async component.
Every navigation is asynchronous, but because we use a wrapper component, the
navigation should be completed almost instantly, as a microtask. For example, if
a user clicks a link to /users but has not loaded the UserList component yet,
they will navigate to /users almost instantly, where they will see a loading
message; they will not stay at the previous route while UserList loads. This
approach should make it easier to reason about navigation. However, one downside
is that an async component cannot use an in-component navigation guard.
Route Names
-----------
All bottom-level routes should have a name. When lazy-loading routes, a
bottom-level route is automatically given the same name as its component by
default. Only bottom-level routes should have a name: otherwise, Vue Router will
log a warning (see https://github.com/vuejs/vue-router/issues/629).
In general, we try not to use route names to drive behavior. We use routes names
with the preserveData meta field below, but outside this file, we prefer route
paths to route names where possible.
Route Meta Fields
-----------------
The following meta fields are supported for bottom-level routes:
Login
-----
- restoreSession (default: true). The router looks to restoreSession right
after the user has navigated to Frontend, when the router is navigating to
the first route. If restoreSession is `true` for the first route, the router
will attempt to restore the user's session before navigating to the route.
Note that even if restoreSession is `false`, the router will not delete any
cookie that is set. That means that if the user navigates to a route for
which `restoreSession` is `false`, then opens a new tab and navigates to a
route for which `restoreSession` is `true`, the user's session may be
restored in the second tab.
- requireLogin (default: true). Indicates whether the user must be logged in
in order to navigate to the route. If an anonymous user (a user who is
logged out) navigates to the route, they will be redirected to login.
- requireAnonymity (default: false)
Indicates whether the user must be anonymous (logged out) in order to
navigate to the route. If a user is logged in and navigates to the route,
they will be redirected to the root page.
In almost all cases, a route either requires login or requires anonymity.
However, NotFound requires neither: a user can navigate to NotFound whether
they are logged in or anonymous.
requestData
-----------
- preserveData (optional). By default, whenever the route changes, all
app-wide requestData resources are cleared. preserveData specifies
exceptions to that rule. preserveData holds an array of functions, each of
which can preserve one or more app-wide resources. Each function is passed
the new and old routes and should return either an array of resources to
preserve or a boolean. If a function returns `true`, all app-wide resources
will be preserved. preserveData meta fields are set in a section below.
preserveData does not affect local resources, which are tied to the
lifecycle of the component, not the route.
- validateData (optional)
Some routes can be navigated to only if certain conditions are met. For
example, the user may have to be able to perform certain verbs sitewide.
validateData checks that conditions about requestData are met. (Perhaps more
precisely, it checks that no condition is violated.) Here is an example
value:
{
// Specifies a condition for currentUser: the user must be able to
// user.list sitewide.
currentUser: () => currentUser.can('user.list'),
// Specifies a condition for `project`: the user must be able to
// assignment.list for the project.
project: () => project.permits('assignment.list')
}
Before the user navigates to the route, any data that will be preserved
after the route change is checked for whether it meets the specified
conditions. If any condition is violated, the user is redirected to /.
There may be data that will be cleared after the route change or that has
never been requested, but will be requested after the component is created.
That data can't be checked in a navigation guard, so a watcher is also added
for each condition; the watcher will check the associated data as soon as it
exists. The watcher will also continue watching the data, checking that it
continues to meet the condition.
Responsive Document Titles
--------------------------
- title
The router updates the document title (text that appears in the browser tab
and history) after a route is changed. It looks at the current route and
calls that route's `title` function, which returns an array of strings to
combine to build the full document title.
The `title` function likely uses the i18n translations (specified in
`src/locales/en.json5`). It may also use fields of a particular resource
(e.g. `project.name`).
The IMPORTANT thing to note is that most resources are loaded asynchronously
after the page is loaded, so the Project, Form, User, etc. resource may not
have data right away. Because of that, the `title` function should account
for the possibility of a resource that does not have data yet. (Note that
the array that the `title` function returns may contain `null` elements.)
The result of the `title` function will be watched, and the document title
will be updated once the resource has data. If a resource already has data,
from viewing different pages about the same project or form for example, the
proper title will be set immediately after the navigation is confirmed.
Here is an example `title` function with
* i18n
* fetching information from a resource that might not have data
() => [
i18n.t('title.project.appUsers'),
project.name // project.name may be `null`
]
Other
-----
- fullWidth (default: false). If fullWidth is `true`, and the route renders a
PageBody component, then the PageBody will use the full width of the page.
By default, PageBody has a max width.
- standalone (default: false): If standalone is `true` then application layout
elements like navigation bar, background color, etc are not rendered.
*/
/*
asyncRoute() returns a config for a route that is lazy-loaded. Specify a
standard route config to asyncRoute() with the following additions:
- component. Instead of component options, specify the component name.
- loading. Indicates how to render the loading message, which depends on how
the component fits into the larger page structure. Specify 'page' if the
component renders a page; specify 'tab' if it renders a tab pane.
- key (optional)
The `key` option determines whether a component is re-rendered after a route
update, for example, after a param change.
By default, we use a mechanism similar to the `key` attribute to re-render
the component whenever the route path changes. In other words, we opt out of
the default Vue Router behavior, which reuses the component instance.
Re-rendering the component simplifies component code and makes it easier to
reason about component state.
However, when using nested routes, we may wish to reuse a parent component
instance while re-rendering a child component. To reuse a component instance
associated with a route, specify a function that returns a value for the
`key` attribute. If the value does not change after the route update, the
component instance will be reused. For example, to reuse a component
instance associated with a parent route, you can specify a function that
returns the part of the path that corresponds to the parent route. See the
routes below for specific examples.
*/
const asyncRoute = (options) => {
const { component, props, loading, key, ...config } = options;
config.component = AsyncRoute;
// Props for AsyncRoute
config.props = (route) => ({
componentName: component,
// Props for the async component
props: routeProps(route, props),
loading,
k: key != null ? key(route.params) : route.path
});
if (config.name == null && config.children == null) config.name = component;
if (config.meta == null) config.meta = {};
config.meta.asyncRoute = { componentName: component };
return config;
};
const { i18n, requestData, config } = container;
const { currentUser, project, form, formDraft, attachments, dataset } = requestData;
const routes = [
asyncRoute({
path: '/load-error',
component: 'ConfigError',
loading: 'page',
meta: {
requireLogin: false,
requireAnonymity: true,
title: () => [i18n.t('common.error')]
},
beforeEnter: () => (config.loadError == null ? '/login' : true)
}),
{
path: '/login',
name: 'AccountLogin',
component: AccountLogin,
meta: {
requireLogin: false,
requireAnonymity: true,
title: () => [i18n.t('action.logIn')]
}
},
asyncRoute({
path: '/reset-password',
component: 'AccountResetPassword',
loading: 'page',
meta: {
requireLogin: false,
requireAnonymity: true,
title: () => [i18n.t('title.resetPassword')]
},
beforeEnter: () => (config.oidcEnabled ? '/404' : true)
}),
asyncRoute({
path: '/account/claim',
component: 'AccountClaim',
loading: 'page',
meta: {
restoreSession: false,
requireLogin: false,
requireAnonymity: true,
title: () => [i18n.t('title.setPassword')]
},
beforeEnter: () => (config.oidcEnabled ? '/404' : true)
}),
asyncRoute({
path: '/',
component: 'Home',
loading: 'page',
meta: {
title: () => [i18n.t('resource.projects')]
}
}),
asyncRoute({
path: '/projects/:projectId([1-9]\\d*)',
component: 'ProjectShow',
props: true,
loading: 'page',
key: ({ projectId }) => `/projects/${projectId}`,
children: [
asyncRoute({
path: '',
component: 'ProjectOverview',
props: true,
loading: 'tab',
meta: {
validateData: {
project: () => project.permits('form.list') || project.permits('open_form.list')
},
title: () => [i18n.t('resource.forms'), project.name]
}
}),
asyncRoute({
path: 'users',
component: 'ProjectUserList',
props: true,
loading: 'tab',
meta: {
validateData: {
project: () => project.permits([
'assignment.list',
'assignment.create',
'assignment.delete'
])
},
title: () => [i18n.t('resource.projectRoles'), project.name]
}
}),
asyncRoute({
path: 'app-users',
component: 'FieldKeyList',
props: true,
loading: 'tab',
meta: {
validateData: {
project: () => project.permits([
'field_key.list',
'field_key.create',
'session.end'
])
},
title: () => [i18n.t('resource.appUsers'), project.name]
}
}),
asyncRoute({
path: 'form-access',
component: 'ProjectFormAccess',
props: true,
loading: 'tab',
meta: {
validateData: {
project: () => project.permits([
'form.list',
'field_key.list',
'assignment.list',
'project.update',
'form.update',
'assignment.create',
'assignment.delete'
])
},
title: () => [i18n.t('projectShow.tab.formAccess'), project.name],
fullWidth: true
}
}),
asyncRoute({
path: 'entity-lists',
component: 'DatasetList',
props: true,
loading: 'tab',
meta: {
validateData: {
project: () => project.permits(['dataset.list', 'entity.list'])
},
title: () => [i18n.t('resource.entities'), project.name]
}
}),
asyncRoute({
path: 'settings',
component: 'ProjectSettings',
loading: 'tab',
meta: {
validateData: {
project: () => project.permits(['project.update'])
},
title: () => [i18n.t('common.tab.settings'), project.name]
}
})
]
}),
// Note the unlikely possibility that
// form.publishedAt == null && formDraft.isEmpty(). In that case, the user
// will be unable to navigate to a form route.
asyncRoute({
path: '/projects/:projectId([1-9]\\d*)/forms/:xmlFormId',
component: 'FormShow',
props: true,
loading: 'page',
key: ({ projectId, xmlFormId }) =>
`/projects/${projectId}/forms/${encodeURIComponent(xmlFormId)}`,
children: [
asyncRoute({
path: '',
component: 'FormOverview',
props: true,
loading: 'tab',
meta: {
validateData: {
// Including form.update in order to exclude project viewers and
// Data Collectors.
project: () => project.permits(['form.read', 'form.update', 'dataset.list']),
form: () => form.publishedAt != null
},
title: () => [form.nameOrId],
fullWidth: true
}
}),
asyncRoute({
path: 'versions',
component: 'FormVersionList',
props: true,
loading: 'tab',
meta: {
validateData: {
// Including submission.list in order to exclude Data Collectors.
project: () => project.permits(['form.read', 'submission.list']),
form: () => form.publishedAt != null
},
title: () => [i18n.t('formHead.tab.versions'), form.nameOrId]
}
}),
asyncRoute({
path: 'submissions',
component: 'FormSubmissions',
props: true,
loading: 'tab',
meta: {
validateData: {
project: () => project.permits([
'form.read',
'submission.list',
'submission.read'
]),
form: () => form.publishedAt != null
},
title: () => [i18n.t('resource.submissions'), form.nameOrId],
fullWidth: true
}
}),
asyncRoute({
path: 'public-links',
component: 'PublicLinkList',
props: true,
loading: 'tab',
meta: {
validateData: {
project: () => project.permits([
'form.read',
'public_link.list',
'public_link.create',
'session.end'
]),
form: () => form.publishedAt != null
},
title: () => [i18n.t('formHead.tab.publicAccess'), form.nameOrId]
}
}),
asyncRoute({
path: 'settings',
component: 'FormSettings',
loading: 'tab',
meta: {
validateData: {
project: () => project.permits([
'form.read',
'form.update',
'form.delete'
]),
form: () => form.publishedAt != null
},
title: () => [i18n.t('common.tab.settings'), form.nameOrId]
}
}),
asyncRoute({
path: 'draft',
component: 'FormDraftStatus',
props: true,
loading: 'tab',
meta: {
validateData: {
project: () => project.permits([
'form.read',
'form.update',
'form.delete',
'dataset.list'
]),
formDraft: () => formDraft.isDefined()
},
title: () => [i18n.t('common.status'), form.nameOrId]
}
}),
asyncRoute({
path: 'draft/attachments',
component: 'FormAttachmentList',
loading: 'tab',
props: true,
meta: {
validateData: {
project: () => project.permits([
'form.read',
'form.update',
'dataset.list',
'entity.list'
]),
attachments: () => attachments.isDefined() &&
attachments.get().size !== 0
},
title: () => [i18n.t('resource.formAttachments'), form.nameOrId]
}
}),
asyncRoute({
path: 'draft/testing',
component: 'FormDraftTesting',
props: true,
loading: 'tab',
meta: {
validateData: {
project: () => project.permits([
'form.read',
'submission.list',
'submission.read'
]),
formDraft: () => formDraft.isDefined()
},
title: () => [
i18n.t('formHead.draftNav.tab.testing'),
form.nameOrId
],
fullWidth: true
}
})
]
}),
asyncRoute({
path: '/projects/:projectId([1-9]\\d*)/forms/:xmlFormId/submissions/:instanceId',
component: 'SubmissionShow',
props: true,
loading: 'page',
meta: {
validateData: {
project: () => project.permits('submission.read')
}
}
}),
asyncRoute({
path: '/projects/:projectId([1-9]\\d*)/forms/:xmlFormId/preview',
component: 'FormPreview',
props: (route) => ({
...route.params,
draft: false
}),
loading: 'page',
meta: {
standalone: true,
title: () => [`✨ ${i18n.t('resource.formPreview')}`, form.nameOrId ?? '']
}
}),
asyncRoute({
path: '/projects/:projectId([1-9]\\d*)/forms/:xmlFormId/draft/preview',
name: 'DraftFormPreview',
component: 'FormPreview',
props: (route) => ({
...route.params,
draft: true
}),
loading: 'page',
meta: {
standalone: true,
title: () => [`✨ ${i18n.t('resource.formPreview')}`, form.nameOrId ? `${form.nameOrId} (${i18n.t('resource.draft')})` : '']
}
}),
asyncRoute({
path: '/projects/:projectId([1-9]\\d*)/entity-lists/:datasetName',
component: 'DatasetShow',
props: true,
loading: 'page',
key: ({ projectId, datasetName }) =>
`/projects/${projectId}/entity-lists/${encodeURIComponent(datasetName)}`,
children: [
asyncRoute({
path: '',
component: 'DatasetOverview',
props: true,
loading: 'tab',
meta: {
title: () => [dataset.name],
validateData: {
project: () => project.permits('dataset.read')
}
}
}),
asyncRoute({
path: 'entities',
component: 'DatasetEntities',
props: true,
loading: 'tab',
meta: {
title: () => [i18n.t('common.data'), dataset.name],
validateData: {
project: () => project.permits(['dataset.read', 'entity.list'])
},
fullWidth: true
}
}),
asyncRoute({
path: 'settings',
component: 'DatasetSettings',
props: true,
loading: 'tab',
meta: {
title: () => [i18n.t('common.tab.settings'), dataset.name],
validateData: {
project: () => project.permits(['dataset.read', 'dataset.update', 'entity.list'])
}
}
})
]
}),
asyncRoute({
// We don't validate that :uuid is a valid UUID (and it isn't in tests), but
// we do validate that it doesn't need to be URL-encoded (for example, in
// requests to Backend).
path: '/projects/:projectId([1-9]\\d*)/entity-lists/:datasetName/entities/:uuid([0-9a-f-]+)',
component: 'EntityShow',
props: true,
loading: 'page',
meta: {
validateData: {
project: () => project.permits(['dataset.read', 'entity.read'])
}
}
}),
asyncRoute({
path: '/users',
component: 'UserHome',
loading: 'page',
key: () => '/users',
children: [
asyncRoute({
path: '',
component: 'UserList',
loading: 'tab',
meta: {
validateData: {
currentUser: () => currentUser.can([
'user.list',
'assignment.list',
'user.create',
'assignment.create',
'assignment.delete',
'user.password.invalidate',
'user.delete'
])
},
title: () => [i18n.t('resource.webUsers')]
}
})
]
}),
asyncRoute({
path: '/users/:id([1-9]\\d*)/edit',
component: 'UserEdit',
props: true,
loading: 'page',
meta: {
validateData: {
currentUser: () => currentUser.can(['user.read', 'user.update'])
}
}
}),
asyncRoute({
path: '/account/edit',
component: 'AccountEdit',
loading: 'page',
meta: {
title: () => [i18n.t('title.editProfile')]
}
}),
asyncRoute({
path: '/system',
component: 'SystemHome',
loading: 'page',
key: () => '/system',
children: [
asyncRoute({
path: 'audits',
component: 'AuditList',
loading: 'tab',
meta: {
validateData: {
currentUser: () => currentUser.can('audit.read')
},
title: () => [i18n.t('systemHome.tab.audits'), i18n.t('systemHome.title')],
fullWidth: true
}
}),
asyncRoute({
path: 'analytics',
component: 'AnalyticsList',
loading: 'tab',
meta: {
validateData: {
currentUser: () => currentUser.can([
'config.read',
'config.set',
'analytics.read'
])
},
title: () => [
i18n.t('systemHome.tab.analytics'),
i18n.t('systemHome.title')
],
fullWidth: true
},
beforeEnter: () => (config.showsAnalytics ? true : '/404')
})
]
}),
asyncRoute({
path: '/dl/projects/:projectId([1-9]\\d*)/forms/:xmlFormId/submissions/:instanceId/attachments/:attachmentName',
component: 'Download',
props: true,
loading: 'page',
meta: {
title: () => [i18n.t('title.download')]
}
}),
asyncRoute({
path: '/:_(.*)',
component: 'NotFound',
loading: 'page',
meta: {
restoreSession: false,
requireLogin: false,
title: () => [i18n.t('title.pageNotFound')]
}
})
];
////////////////////////////////////////////////////////////////////////////////
// TRAVERSE ROUTES
const routesByName = new Map();
{
// Normalizes the values of meta fields, including by setting defaults.
const normalizeMeta = (meta) => ({
restoreSession: true,
requireLogin: true,
requireAnonymity: false,
preserveData: [],
fullWidth: false,
standalone: false,
...meta,
validateData: meta == null || meta.validateData == null
? []
: Object.entries(meta.validateData)
.map(([name, validator]) => [requestData[name], validator])
});
const stack = [...routes];
while (stack.length !== 0) {
const route = stack.pop();
if (route.children != null) {
if (route.meta == null) route.meta = {};
for (const child of route.children)
stack.push(child);
} else {
route.meta = normalizeMeta(route.meta);
routesByName.set(route.name, route);
}
}
}
/* eslint-enable indent */ // TODO/vue3
//////////////////////////////////////////////////////////////////////////////
// PRESERVE DATA
// Data that is always preserved after navigation
const alwaysPreserve = always([
requestData.session,
currentUser,
config,
requestData.centralVersion,
requestData.analyticsConfig,
requestData.roles
]);
for (const route of routesByName.values())
route.meta.preserveData.push(alwaysPreserve);
// Preserves data when navigating from one of the specified routes to another.
const preserveDataBetweenRoutes = (routeNames, f) => {
const nameSet = new Set(routeNames);
const preserve = (to, from) => nameSet.has(from.name) && f(to, from);
for (const name of nameSet)
routesByName.get(name).meta.preserveData.push(preserve);
};
// Preserve data when navigating between tabs.
const preserveBetweenTabs = (to, from) => equals(to.params, from.params);
const projectRoutes = [
'ProjectOverview',
'ProjectUserList',
'FieldKeyList',
'ProjectFormAccess',
'DatasetList',
'ProjectSettings'
];
const formRoutes = [
'FormOverview',
'FormVersionList',
'FormSubmissions',
'PublicLinkList',
'FormSettings',
'FormDraftStatus',
'FormAttachmentList',
'FormDraftTesting'
];
const datasetRoutes = [
'DatasetEntities',
'DatasetOverview',
'DatasetSettings'
];
preserveDataBetweenRoutes(projectRoutes, preserveBetweenTabs);
preserveDataBetweenRoutes(formRoutes, preserveBetweenTabs);
preserveDataBetweenRoutes(datasetRoutes, preserveBetweenTabs);
// Preserve requestData.project.
preserveDataBetweenRoutes(
[...projectRoutes, ...formRoutes, 'SubmissionShow', ...datasetRoutes, 'EntityShow'],
(to, from) => (to.params.projectId === from.params.projectId
? [project]
: false)
);
//////////////////////////////////////////////////////////////////////////////
// RETURN
return routes;
};