mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-25 11:46:43 +01:00
feat: add sorts support for the projects listing API (#14425)
Signed-off-by: He Weiwei <hweiwei@vmware.com>
This commit is contained in:
parent
0d4992a41e
commit
85f9a49bc8
@ -151,6 +151,7 @@ paths:
|
||||
operationId: listProjects
|
||||
parameters:
|
||||
- $ref: '#/parameters/requestId'
|
||||
- $ref: '#/parameters/query'
|
||||
- $ref: '#/parameters/page'
|
||||
- $ref: '#/parameters/pageSize'
|
||||
- $ref: '#/parameters/sort'
|
||||
|
@ -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}
|
||||
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user