Skip to content

Commit

Permalink
feat: add sorts support for the projects listing API (#14425)
Browse files Browse the repository at this point in the history
Signed-off-by: He Weiwei <hweiwei@vmware.com>
  • Loading branch information
heww committed Mar 12, 2021
1 parent 0d4992a commit 85f9a49
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions api/v2.0/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ paths:
operationId: listProjects
parameters:
- $ref: '#/parameters/requestId'
- $ref: '#/parameters/query'
- $ref: '#/parameters/page'
- $ref: '#/parameters/pageSize'
- $ref: '#/parameters/sort'
Expand Down
9 changes: 5 additions & 4 deletions src/server/v2.0/handler/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,10 @@ func (a *projectAPI) HeadProject(ctx context.Context, params operation.HeadProje
}

func (a *projectAPI) ListProjects(ctx context.Context, params operation.ListProjectsParams) middleware.Responder {
query := q.New(q.KeyWords{})
query.PageNumber = *params.Page
query.PageSize = *params.PageSize
query, err := a.BuildQuery(ctx, params.Q, params.Sort, params.Page, params.PageSize)
if err != nil {
return a.SendError(ctx, err)
}

if name := lib.StringValue(params.Name); name != "" {
query.Keywords["name"] = &q.FuzzyMatchValue{Value: name}
Expand Down Expand Up @@ -642,7 +643,7 @@ func (a *projectAPI) validateProjectReq(ctx context.Context, req *models.Project
func (a *projectAPI) populateProperties(ctx context.Context, p *project.Project) error {
if secCtx, ok := security.FromContext(ctx); ok {
if sc, ok := secCtx.(*local.SecurityContext); ok {
roles, err := pro.ListRoles(sc.User(), p.ProjectID)
roles, err := a.projectCtl.ListRoles(ctx, p.ProjectID, sc.User())
if err != nil {
return err
}
Expand Down

0 comments on commit 85f9a49

Please sign in to comment.