Newer
Older
piotr.kupczyk@id.ethz.ch
committed
import UserBrowserConsts from '@src/js/components/users/browser/UserBrowserConsts.js'
piotr.kupczyk@id.ethz.ch
committed
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
import openbis from '@src/js/services/openbis.js'
import objectType from '@src/js/common/consts/objectType.js'
export default class TypeBrowserConstsLoadNodePath {
async doLoadNodePath(params) {
const { object } = params
if (object.type === objectType.OVERVIEW) {
if (object.id === objectType.USER) {
return this.createFolderPath(
objectType.USER,
UserBrowserConsts.TEXT_USERS
)
} else if (object.id === objectType.USER_GROUP) {
return this.createFolderPath(
objectType.USER_GROUP,
UserBrowserConsts.TEXT_GROUPS
)
}
} else if (object.type === objectType.USER) {
const id = new openbis.PersonPermId(object.id)
const fetchOptions = new openbis.PersonFetchOptions()
const persons = await openbis.getPersons([id], fetchOptions)
const person = persons[object.id]
return this.createNodePath(
object,
person,
objectType.USER,
UserBrowserConsts.TEXT_USERS
)
} else if (object.type === objectType.USER_GROUP) {
const id = new openbis.AuthorizationGroupPermId(object.id)
const fetchOptions = new openbis.AuthorizationGroupFetchOptions()
const groups = await openbis.getAuthorizationGroups([id], fetchOptions)
const group = groups[object.id]
return this.createNodePath(
object,
group,
objectType.USER_GROUP,
UserBrowserConsts.TEXT_GROUPS
)
} else {
return null
}
}
createFolderPath(folderObjectType, folderText) {
return [
{
id: UserBrowserConsts.nodeId(
UserBrowserConsts.TYPE_ROOT,
folderObjectType
),
object: { type: objectType.OVERVIEW, id: folderObjectType },
text: folderText
}
]
}
createNodePath(object, loadedObject, folderObjectType, folderText) {
if (loadedObject) {
const folderPath = this.createFolderPath(folderObjectType, folderText)
return [
...folderPath,
{
id: UserBrowserConsts.nodeId(
UserBrowserConsts.TYPE_ROOT,
folderObjectType,
folderObjectType,
object.id
),
object,
text: object.id
}
]
} else {
return null
}
}
}