From d85c07294ee759758413f9ce79d7ae5d22424c23 Mon Sep 17 00:00:00 2001 From: Gianmaria Del Monte <39946305+gmgigi96@users.noreply.github.com> Date: Tue, 8 Jun 2021 16:26:23 +0200 Subject: [PATCH] Sort share entries alphabetically (#1772) --- changelog/unreleased/sort-share.md | 6 ++++++ internal/grpc/services/groupprovider/groupprovider.go | 6 ++++++ internal/grpc/services/userprovider/userprovider.go | 6 ++++++ 3 files changed, 18 insertions(+) create mode 100644 changelog/unreleased/sort-share.md diff --git a/changelog/unreleased/sort-share.md b/changelog/unreleased/sort-share.md new file mode 100644 index 0000000000..2e23d448a0 --- /dev/null +++ b/changelog/unreleased/sort-share.md @@ -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 diff --git a/internal/grpc/services/groupprovider/groupprovider.go b/internal/grpc/services/groupprovider/groupprovider.go index 951395825a..1fda6e7d05 100644 --- a/internal/grpc/services/groupprovider/groupprovider.go +++ b/internal/grpc/services/groupprovider/groupprovider.go @@ -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" @@ -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, diff --git a/internal/grpc/services/userprovider/userprovider.go b/internal/grpc/services/userprovider/userprovider.go index 465185d4e6..376f00b694 100644 --- a/internal/grpc/services/userprovider/userprovider.go +++ b/internal/grpc/services/userprovider/userprovider.go @@ -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" @@ -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,