Nested Folders: Move SharedWithMe to the top of the folders list (#79875)

This commit is contained in:
Tania 2023-12-29 11:35:15 +01:00 committed by GitHub
parent 5a21a6d938
commit a62db1e24b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -263,7 +263,7 @@ func (s *Service) getRootFolders(ctx context.Context, q *folder.GetChildrenQuery
// add "shared with me" folder on the 1st page
if (q.Page == 0 || q.Page == 1) && len(q.FolderUIDs) != 0 {
children = append(children, &folder.SharedWithMeFolder)
children = append([]*folder.Folder{&folder.SharedWithMeFolder}, children...)
}
return children, nil

View File

@ -128,7 +128,7 @@ func TestGetFolders(t *testing.T) {
for i := range res.Payload {
actualFolders = append(actualFolders, res.Payload[i].UID)
}
assert.Equal(t, []string{"folder-0", "folder-1", "folder-2", "folder-3", "folder-4", folder.SharedWithMeFolderUID}, actualFolders)
assert.Equal(t, []string{folder.SharedWithMeFolderUID, "folder-0", "folder-1", "folder-2", "folder-3", "folder-4"}, actualFolders)
})
t.Run("Pagination works as expect for editor", func(t *testing.T) {
@ -140,7 +140,7 @@ func TestGetFolders(t *testing.T) {
for i := range res.Payload {
actualFolders = append(actualFolders, res.Payload[i].UID)
}
assert.Equal(t, []string{"folder-0", "folder-1", folder.SharedWithMeFolderUID}, actualFolders)
assert.Equal(t, []string{folder.SharedWithMeFolderUID, "folder-0", "folder-1"}, actualFolders)
page = int64(2)
res, err = editorClient.Folders.GetFolders(folders.NewGetFoldersParams().WithLimit(&limit).WithPage(&page))
@ -168,7 +168,7 @@ func TestGetFolders(t *testing.T) {
for i := range res.Payload {
actualFolders = append(actualFolders, res.Payload[i].UID)
}
assert.Equal(t, []string{"folder-0", "folder-1", "folder-2", "folder-4", folder.SharedWithMeFolderUID}, actualFolders)
assert.Equal(t, []string{folder.SharedWithMeFolderUID, "folder-0", "folder-1", "folder-2", "folder-4"}, actualFolders)
})
t.Run("Pagination works as expect for viewer", func(t *testing.T) {
@ -180,7 +180,7 @@ func TestGetFolders(t *testing.T) {
for i := range res.Payload {
actualFolders = append(actualFolders, res.Payload[i].UID)
}
assert.Equal(t, []string{"folder-0", "folder-1", folder.SharedWithMeFolderUID}, actualFolders)
assert.Equal(t, []string{folder.SharedWithMeFolderUID, "folder-0", "folder-1"}, actualFolders)
page = int64(2)
res, err = viewerClient.Folders.GetFolders(folders.NewGetFoldersParams().WithLimit(&limit).WithPage(&page))