Skip to content

Commit 33c75c4

Browse files
committed
feat: Add roles EditorListGrantsWithVersions, FileEditorListGrantsWithVersions
1 parent 71f5a1b commit 33c75c4

File tree

7 files changed

+97
-13
lines changed

7 files changed

+97
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Enhancement: Add roles
2+
3+
Add EditorListGrantsWithVersions and FileEditorListGrantsWithVersions roles.
4+
5+
TODO
6+
https://github.com/owncloud/ocis/issues/10747

services/graph/pkg/config/defaults/defaultconfig.go

+2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ var (
2020
unifiedrole.UnifiedRoleSpaceEditorWithoutVersionsID,
2121
unifiedrole.UnifiedRoleViewerListGrantsID,
2222
unifiedrole.UnifiedRoleEditorListGrantsID,
23+
unifiedrole.UnifiedRoleEditorListGrantsWithVersionsID,
2324
unifiedrole.UnifiedRoleFileEditorListGrantsID,
25+
unifiedrole.UnifiedRoleFileEditorListGrantsWithVersionsID,
2426
unifiedrole.UnifiedRoleDeniedID,
2527
}
2628
)

services/graph/pkg/unifiedrole/conversion.go

+4
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ func cs3RoleToDisplayName(role *conversions.Role) string {
212212
return _editorUnifiedRoleDisplayName
213213
case conversions.RoleEditorListGrants:
214214
return _editorListGrantsUnifiedRoleDisplayName
215+
case conversions.RoleEditorListGrantsWithVersions:
216+
return _editorListGrantsWithVersionsUnifiedRoleDisplayName
215217
case conversions.RoleSpaceEditor:
216218
return _spaceEditorUnifiedRoleDisplayName
217219
case conversions.RoleSpaceEditorWithoutVersions:
@@ -220,6 +222,8 @@ func cs3RoleToDisplayName(role *conversions.Role) string {
220222
return _fileEditorUnifiedRoleDisplayName
221223
case conversions.RoleFileEditorListGrants:
222224
return _fileEditorListGrantsUnifiedRoleDisplayName
225+
case conversions.RoleFileEditorListGrantsWithVersions:
226+
return _fileEditorListGrantsWithVersionsUnifiedRoleDisplayName
223227
case conversions.RoleEditorLite:
224228
return _editorLiteUnifiedRoleDisplayName
225229
case conversions.RoleManager:

services/graph/pkg/unifiedrole/export_test.go

+15-13
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
package unifiedrole
22

33
var (
4-
RoleViewer = roleViewer
5-
RoleViewerListGrants = roleViewerListGrants
6-
RoleSpaceViewer = roleSpaceViewer
7-
RoleEditor = roleEditor
8-
RoleEditorListGrants = roleEditorListGrants
9-
RoleSpaceEditor = roleSpaceEditor
10-
RoleSpaceEditorWithoutVersions = roleSpaceEditorWithoutVersions
11-
RoleFileEditor = roleFileEditor
12-
RoleFileEditorListGrants = roleFileEditorListGrants
13-
RoleEditorLite = roleEditorLite
14-
RoleManager = roleManager
15-
RoleSecureViewer = roleSecureViewer
16-
RoleDenied = roleDenied
4+
RoleViewer = roleViewer
5+
RoleViewerListGrants = roleViewerListGrants
6+
RoleSpaceViewer = roleSpaceViewer
7+
RoleEditor = roleEditor
8+
RoleEditorListGrants = roleEditorListGrants
9+
RoleEditorListGrantsWithVersions = roleEditorListGrantsWithVersions
10+
RoleSpaceEditor = roleSpaceEditor
11+
RoleSpaceEditorWithoutVersions = roleSpaceEditorWithoutVersions
12+
RoleFileEditor = roleFileEditor
13+
RoleFileEditorListGrants = roleFileEditorListGrants
14+
RoleFileEditorListGrantsWithVersions = roleFileEditorListGrantsWithVersions
15+
RoleEditorLite = roleEditorLite
16+
RoleManager = roleManager
17+
RoleSecureViewer = roleSecureViewer
18+
RoleDenied = roleDenied
1719

1820
BuildInRoles = buildInRoles
1921

services/graph/pkg/unifiedrole/roles.go

+60
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ const (
2424
UnifiedRoleEditorID = "fb6c3e19-e378-47e5-b277-9732f9de6e21"
2525
// UnifiedRoleEditorListGrantsID Unified role editor id.
2626
UnifiedRoleEditorListGrantsID = "e8ea8b21-abd4-45d2-b893-8d1546378e9e"
27+
// UnifiedRoleEditorListGrantsWithVersionsID Unified role editor with versions id.
28+
UnifiedRoleEditorListGrantsWithVersionsID = "0911d62b-1e3f-4778-8b1b-903b7e4e8476"
2729
// UnifiedRoleSpaceEditorID Unified role space editor id.
2830
UnifiedRoleSpaceEditorID = "58c63c02-1d89-4572-916a-870abc5a1b7d"
2931
// UnifiedRoleSpaceEditorWithoutVersionsID Unified role space editor without list/restore versions id.
@@ -32,6 +34,8 @@ const (
3234
UnifiedRoleFileEditorID = "2d00ce52-1fc2-4dbc-8b95-a73b73395f5a"
3335
// UnifiedRoleFileEditorListGrantsID Unified role file editor id.
3436
UnifiedRoleFileEditorListGrantsID = "c1235aea-d106-42db-8458-7d5610fb0a67"
37+
// UnifiedRoleFileEditorListGrantsWithVersionsID Unified role file editor id.
38+
UnifiedRoleFileEditorListGrantsWithVersionsID = "b173329d-cf2e-42f0-a595-ee410645d840"
3539
// UnifiedRoleEditorLiteID Unified role editor-lite id.
3640
UnifiedRoleEditorLiteID = "1c996275-f1c9-4e71-abdf-a42f6495e960"
3741
// UnifiedRoleManagerID Unified role manager id.
@@ -121,6 +125,12 @@ var (
121125
// UnifiedRole EditorListGrants, Role DisplayName (resolves directly)
122126
_editorListGrantsUnifiedRoleDisplayName = l10n.Template("Can edit")
123127

128+
// UnifiedRoleListGrants Editor, Role Description (resolves directly)
129+
_editorListGrantsWithVersionsUnifiedRoleDescription = l10n.Template("View, download, upload, edit, delete and show all invited people, show all versions.")
130+
131+
// UnifiedRole EditorListGrants, Role DisplayName (resolves directly)
132+
_editorListGrantsWithVersionsUnifiedRoleDisplayName = l10n.Template("Can edit")
133+
124134
// UnifiedRole SpaseEditor, Role Description (resolves directly)
125135
_spaceEditorUnifiedRoleDescription = l10n.Template("View, download, upload, edit, add, delete including the history.")
126136

@@ -145,6 +155,12 @@ var (
145155
// UnifiedRole FileEditorListGrants, Role DisplayName (resolves directly)
146156
_fileEditorListGrantsUnifiedRoleDisplayName = l10n.Template("Can edit")
147157

158+
// UnifiedRole FileEditorListGrants, Role Description (resolves directly)
159+
_fileEditorListGrantsWithVersionsUnifiedRoleDescription = l10n.Template("View, download, edit and show all invited people, show all versions.")
160+
161+
// UnifiedRole FileEditorListGrants, Role DisplayName (resolves directly)
162+
_fileEditorListGrantsWithVersionsUnifiedRoleDisplayName = l10n.Template("Can edit")
163+
148164
// UnifiedRole EditorLite, Role Description (resolves directly)
149165
_editorLiteUnifiedRoleDescription = l10n.Template("View, download and upload.")
150166

@@ -191,10 +207,12 @@ var (
191207
roleSpaceViewer,
192208
roleEditor,
193209
roleEditorListGrants,
210+
roleEditorListGrantsWithVersions,
194211
roleSpaceEditor,
195212
roleSpaceEditorWithoutVersions,
196213
roleFileEditor,
197214
roleFileEditorListGrants,
215+
roleFileEditorListGrantsWithVersions,
198216
roleEditorLite,
199217
roleManager,
200218
roleSecureViewer,
@@ -318,6 +336,27 @@ var (
318336
}
319337
}()
320338

339+
// roleEditorListGrantsWithVersions creates an editor role.
340+
roleEditorListGrantsWithVersions = func() *libregraph.UnifiedRoleDefinition {
341+
r := conversions.NewEditorListGrantsWithVersionsRole()
342+
return &libregraph.UnifiedRoleDefinition{
343+
Id: proto.String(UnifiedRoleEditorListGrantsWithVersionsID),
344+
Description: proto.String(_editorListGrantsWithVersionsUnifiedRoleDescription),
345+
DisplayName: proto.String(cs3RoleToDisplayName(r)),
346+
RolePermissions: []libregraph.UnifiedRolePermission{
347+
{
348+
AllowedResourceActions: CS3ResourcePermissionsToLibregraphActions(r.CS3ResourcePermissions()),
349+
Condition: proto.String(UnifiedRoleConditionFolder),
350+
},
351+
{
352+
AllowedResourceActions: CS3ResourcePermissionsToLibregraphActions(r.CS3ResourcePermissions()),
353+
Condition: proto.String(UnifiedRoleConditionFolderFederatedUser),
354+
},
355+
},
356+
LibreGraphWeight: proto.Int32(0),
357+
}
358+
}()
359+
321360
// roleSpaceEditor creates an editor role
322361
roleSpaceEditor = func() *libregraph.UnifiedRoleDefinition {
323362
r := conversions.NewSpaceEditorRole()
@@ -394,6 +433,27 @@ var (
394433
}
395434
}()
396435

436+
// roleFileEditorListGrantsWithVersions creates a file-editor role
437+
roleFileEditorListGrantsWithVersions = func() *libregraph.UnifiedRoleDefinition {
438+
r := conversions.NewFileEditorListGrantsWithVersionsRole()
439+
return &libregraph.UnifiedRoleDefinition{
440+
Id: proto.String(UnifiedRoleFileEditorListGrantsWithVersionsID),
441+
Description: proto.String(_fileEditorListGrantsWithVersionsUnifiedRoleDescription),
442+
DisplayName: proto.String(cs3RoleToDisplayName(r)),
443+
RolePermissions: []libregraph.UnifiedRolePermission{
444+
{
445+
AllowedResourceActions: CS3ResourcePermissionsToLibregraphActions(r.CS3ResourcePermissions()),
446+
Condition: proto.String(UnifiedRoleConditionFile),
447+
},
448+
{
449+
AllowedResourceActions: CS3ResourcePermissionsToLibregraphActions(r.CS3ResourcePermissions()),
450+
Condition: proto.String(UnifiedRoleConditionFileFederatedUser),
451+
},
452+
},
453+
LibreGraphWeight: proto.Int32(0),
454+
}
455+
}()
456+
397457
// roleEditorLite creates an editor-lite role
398458
roleEditorLite = func() *libregraph.UnifiedRoleDefinition {
399459
r := conversions.NewEditorLiteRole()

services/graph/pkg/unifiedrole/roles_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ func TestGetRolesByPermissions(t *testing.T) {
166166
unifiedrole.RoleViewerListGrants,
167167
unifiedrole.RoleFileEditor,
168168
unifiedrole.RoleFileEditorListGrants,
169+
unifiedrole.RoleFileEditorListGrantsWithVersions,
169170
},
170171
},
171172
"BuildInRoles | folder": {
@@ -179,6 +180,7 @@ func TestGetRolesByPermissions(t *testing.T) {
179180
unifiedrole.RoleEditorLite,
180181
unifiedrole.RoleEditor,
181182
unifiedrole.RoleEditorListGrants,
183+
unifiedrole.RoleEditorListGrantsWithVersions,
182184
},
183185
},
184186
"BuildInRoles | drive": {

services/web/pkg/theme/theme.go

+8
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ var themeDefaults = KV{
3737
"label": "UnifiedRoleFileEditorListGrants",
3838
"iconName": "pencil",
3939
},
40+
unifiedrole.UnifiedRoleFileEditorListGrantsWithVersionsID: KV{
41+
"label": "UnifiedRoleFileEditorListGrantsWithVersions",
42+
"iconName": "pencil",
43+
},
4044
unifiedrole.UnifiedRoleEditorID: KV{
4145
"label": "UnifiedRoleEditor",
4246
"iconName": "pencil",
@@ -45,6 +49,10 @@ var themeDefaults = KV{
4549
"label": "UnifiedRoleEditorListGrants",
4650
"iconName": "pencil",
4751
},
52+
unifiedrole.UnifiedRoleEditorListGrantsWithVersionsID: KV{
53+
"label": "UnifiedRoleEditorListGrantsWithVersions",
54+
"iconName": "pencil",
55+
},
4856
unifiedrole.UnifiedRoleSpaceEditorID: KV{
4957
"label": "UnifiedRoleSpaceEditor",
5058
"iconName": "pencil",

0 commit comments

Comments
 (0)