Skip to content

Commit 243227a

Browse files
committed
feat: Add roles EditorListGrantsWithVersions, FileEditorListGrantsWithVersions
1 parent 7db0c82 commit 243227a

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
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+
https://github.com/cs3org/reva/pull/5063
6+
https://github.com/owncloud/ocis/issues/10747

pkg/conversions/role.go

+25
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ const (
4545
RoleEditor = "editor"
4646
// RoleEditorListGrants grants editor permission on a resource, including folders.
4747
RoleEditorListGrants = "editor-list-grants"
48+
// RoleEditorListGrantsWithVersions grants editor permission on a resource, including folders.
49+
RoleEditorListGrantsWithVersions = "editor-list-grants-with-versions"
4850
// RoleSpaceEditor grants editor permission on a space.
4951
RoleSpaceEditor = "spaceeditor"
5052
// RoleSpaceEditorWithoutVersions grants editor permission without list/restore versions on a space.
@@ -53,6 +55,8 @@ const (
5355
RoleFileEditor = "file-editor"
5456
// RoleFileEditorListGrants grants editor permission on a single file.
5557
RoleFileEditorListGrants = "file-editor-list-grants"
58+
// RoleFileEditorListGrantsWithVersions grants editor permission on a single file.
59+
RoleFileEditorListGrantsWithVersions = "file-editor-list-grants-with-versions"
5660
// RoleCoowner grants co-owner permissions on a resource.
5761
RoleCoowner = "coowner"
5862
// RoleEditorLite grants permission to upload and download to a resource.
@@ -171,12 +175,16 @@ func RoleFromName(name string) *Role {
171175
return NewEditorRole()
172176
case RoleEditorListGrants:
173177
return NewEditorListGrantsRole()
178+
case RoleEditorListGrantsWithVersions:
179+
return NewEditorListGrantsWithVersionsRole()
174180
case RoleSpaceEditor:
175181
return NewSpaceEditorRole()
176182
case RoleFileEditor:
177183
return NewFileEditorRole()
178184
case RoleFileEditorListGrants:
179185
return NewFileEditorListGrantsRole()
186+
case RoleFileEditorListGrantsWithVersions:
187+
return NewFileEditorListGrantsWithVersionsRole()
180188
case RoleUploader:
181189
return NewUploaderRole()
182190
case RoleManager:
@@ -276,6 +284,13 @@ func NewEditorListGrantsRole() *Role {
276284
return role
277285
}
278286

287+
// NewEditorListGrantsWithVersionsRole creates an editor role. `sharing` indicates if sharing permission should be added
288+
func NewEditorListGrantsWithVersionsRole() *Role {
289+
role := NewEditorListGrantsRole()
290+
role.cS3ResourcePermissions.ListFileVersions = true
291+
return role
292+
}
293+
279294
// NewSpaceEditorRole creates an editor role
280295
func NewSpaceEditorRole() *Role {
281296
return &Role{
@@ -348,6 +363,13 @@ func NewFileEditorListGrantsRole() *Role {
348363
return role
349364
}
350365

366+
// NewFileEditorListGrantsWithVersionsRole creates a file-editor role
367+
func NewFileEditorListGrantsWithVersionsRole() *Role {
368+
role := NewFileEditorListGrantsRole()
369+
role.cS3ResourcePermissions.ListFileVersions = true
370+
return role
371+
}
372+
351373
// NewCoownerRole creates a coowner role.
352374
func NewCoownerRole() *Role {
353375
return &Role{
@@ -595,6 +617,9 @@ func RoleFromResourcePermissions(rp *provider.ResourcePermissions, islink bool)
595617
if rp.ListGrants {
596618
r.Name = RoleEditorListGrants
597619
}
620+
if rp.RemoveGrant && rp.ListFileVersions {
621+
r.Name = RoleEditorListGrantsWithVersions
622+
}
598623
if rp.RemoveGrant {
599624
r.Name = RoleManager
600625
}

0 commit comments

Comments
 (0)