-
Notifications
You must be signed in to change notification settings - Fork 159
/
common.ts
58 lines (53 loc) · 1.52 KB
/
common.ts
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
import { RouteComponents } from './router'
import { RouteLocationNamedRaw, RouteRecordRaw } from 'vue-router'
import { createLocation, $gettext, isLocationActiveDirector } from './utils'
type commonTypes = 'files-common-favorites' | 'files-common-search'
export const createLocationCommon = (name: commonTypes, location = {}): RouteLocationNamedRaw =>
createLocation(name, location)
export const locationFavorites = createLocationCommon('files-common-favorites')
export const locationSearch = createLocationCommon('files-common-search')
export const isLocationCommonActive = isLocationActiveDirector<commonTypes>(
locationFavorites,
locationSearch
)
export const buildRoutes = (components: RouteComponents): RouteRecordRaw[] => [
{
path: '/search',
component: components.App,
children: [
{
name: locationSearch.name,
path: 'list/:page?',
component: components.SearchResults,
meta: {
authContext: 'user',
title: $gettext('Search results'),
contextQueryItems: [
'term',
'provider',
'q_tags',
'q_lastModified',
'q_fullText',
'scope',
'useScope'
]
}
}
]
},
{
path: '/favorites',
component: components.App,
children: [
{
name: locationFavorites.name,
path: '',
component: components.Favorites,
meta: {
authContext: 'user',
title: $gettext('Favorite files')
}
}
]
}
]