Skip to content

Commit

Permalink
Sort share entries alphabetically (#1772)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmgigi96 authored Jun 8, 2021
1 parent 52e7228 commit d85c072
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
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

0 comments on commit d85c072

Please sign in to comment.