Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort share entries alphabetically #1772

Merged
merged 2 commits into from
Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/sort-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Sort share entries alphabetically

When showing the list of shares to the end-user, the list was not sorted alphabetically.
This PR sorts the list of users and groups.

https://github.com/cs3org/reva/issues/1763
6 changes: 6 additions & 0 deletions internal/grpc/services/groupprovider/groupprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package groupprovider
import (
"context"
"fmt"
"sort"

grouppb "github.com/cs3org/go-cs3apis/cs3/identity/group/v1beta1"
"github.com/cs3org/reva/pkg/errtypes"
Expand Down Expand Up @@ -138,6 +139,11 @@ func (s *service) FindGroups(ctx context.Context, req *grouppb.FindGroupsRequest
}, nil
}

// sort group by groupname
sort.Slice(groups, func(i, j int) bool {
return groups[i].GroupName <= groups[j].GroupName
})

return &grouppb.FindGroupsResponse{
Status: status.NewOK(ctx),
Groups: groups,
Expand Down
6 changes: 6 additions & 0 deletions internal/grpc/services/userprovider/userprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package userprovider
import (
"context"
"fmt"
"sort"

userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
"github.com/cs3org/reva/pkg/errtypes"
Expand Down Expand Up @@ -145,6 +146,11 @@ func (s *service) FindUsers(ctx context.Context, req *userpb.FindUsersRequest) (
return res, nil
}

// sort users by username
sort.Slice(users, func(i, j int) bool {
return users[i].Username <= users[j].Username
})

res := &userpb.FindUsersResponse{
Status: status.NewOK(ctx),
Users: users,
Expand Down