Skip to content

Commit 4c499d6

Browse files
avatusrosstimothy
andauthored
[v18] Paginated Access Lists in the web UI (#59265)
* Add ListAccessListsV2 to support sorting and searching (#58323) This PR adds a new API to access lists service/cache that will allow us to sort by name and auditNextDate as well as filter by a search term * Component updates to support paginated AccessLists * Add CreateAccessListNextKey and title sort to AccessLists cache (#58716) * Send non-reviewable AccessLists to back of sort (#59201) If an access list is not elible for review, we should sort it to the back of the "auditNextDate" sort index, similar to time.IsZero * Use ListAccessList RPC in (Client) ListAccessLists (#58658) The client implementation used ListAccessListV2 to avoid calling a deprecated RPC, however, that causes compatibility issues since it does not allow retrieving AccessLists from older versions of Teleport which don't implement the V2 RPC variant. --------- Co-authored-by: rosstimothy <[email protected]>
1 parent 04e9ffb commit 4c499d6

File tree

20 files changed

+1547
-303
lines changed

20 files changed

+1547
-303
lines changed

api/client/accesslist/accesslist.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ func (c *Client) GetAccessLists(ctx context.Context) ([]*accesslist.AccessList,
6161
}
6262

6363
// ListAccessLists returns a paginated list of access lists.
64+
// TODO (avatus): DELETE IN 21.0.0
6465
func (c *Client) ListAccessLists(ctx context.Context, pageSize int, nextToken string) ([]*accesslist.AccessList, string, error) {
66+
//nolint:staticcheck // SA1019. ListAccessLists is deprecated but will
67+
// continue be supported for backward compatibility.
6568
resp, err := c.grpcClient.ListAccessLists(ctx, &accesslistv1.ListAccessListsRequest{
6669
PageSize: int32(pageSize),
6770
NextToken: nextToken,
@@ -82,6 +85,24 @@ func (c *Client) ListAccessLists(ctx context.Context, pageSize int, nextToken st
8285
return accessLists, resp.GetNextToken(), nil
8386
}
8487

88+
// ListAccessListsV2 returns a filtered and sorted paginated list of access lists.
89+
func (c *Client) ListAccessListsV2(ctx context.Context, req *accesslistv1.ListAccessListsV2Request) ([]*accesslist.AccessList, string, error) {
90+
resp, err := c.grpcClient.ListAccessListsV2(ctx, req)
91+
if err != nil {
92+
return nil, "", trace.Wrap(err)
93+
}
94+
95+
accessLists := make([]*accesslist.AccessList, len(resp.AccessLists))
96+
for i, accessList := range resp.AccessLists {
97+
accessLists[i], err = conv.FromProto(accessList, conv.WithOwnersIneligibleStatusField(accessList.GetSpec().GetOwners()))
98+
if err != nil {
99+
return nil, "", trace.Wrap(err)
100+
}
101+
}
102+
103+
return accessLists, resp.GetNextPageToken(), nil
104+
}
105+
85106
// GetAccessList returns the specified access list resource.
86107
func (c *Client) GetAccessList(ctx context.Context, name string) (*accesslist.AccessList, error) {
87108
resp, err := c.grpcClient.GetAccessList(ctx, &accesslistv1.GetAccessListRequest{

0 commit comments

Comments
 (0)