fix: allow sorting of MyProjectOrgs (by name) (#7970)

This commit is contained in:
Livio Spring 2024-05-17 09:52:15 +02:00 committed by GitHub
parent 9e91b53bd4
commit b924fd59a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 21 additions and 16 deletions

View File

@ -5,7 +5,6 @@ import (
org_grpc "github.com/zitadel/zitadel/internal/api/grpc/org"
"github.com/zitadel/zitadel/internal/query"
"github.com/zitadel/zitadel/pkg/grpc/admin"
"github.com/zitadel/zitadel/pkg/grpc/org"
)
func listOrgRequestToModel(req *admin.ListOrgsRequest) (*query.OrgSearchQueries, error) {
@ -18,18 +17,9 @@ func listOrgRequestToModel(req *admin.ListOrgsRequest) (*query.OrgSearchQueries,
SearchRequest: query.SearchRequest{
Offset: offset,
Limit: limit,
SortingColumn: fieldNameToOrgColumn(req.SortingColumn),
SortingColumn: org_grpc.FieldNameToOrgColumn(req.SortingColumn),
Asc: asc,
},
Queries: queries,
}, nil
}
func fieldNameToOrgColumn(fieldName org.OrgFieldName) query.Column {
switch fieldName {
case org.OrgFieldName_ORG_FIELD_NAME_NAME:
return query.OrgColumnName
default:
return query.Column{}
}
}

View File

@ -266,9 +266,10 @@ func ListMyProjectOrgsRequestToQuery(req *auth_pb.ListMyProjectOrgsRequest) (*qu
}
return &query.OrgSearchQueries{
SearchRequest: query.SearchRequest{
Offset: offset,
Limit: limit,
Asc: asc,
Offset: offset,
Limit: limit,
Asc: asc,
SortingColumn: org.FieldNameToOrgColumn(req.SortingColumn),
},
Queries: queries,
}, nil

View File

@ -186,3 +186,14 @@ func DomainValidationTypeFromModel(validationType domain.OrgDomainValidationType
return org_pb.DomainValidationType_DOMAIN_VALIDATION_TYPE_UNSPECIFIED
}
}
func FieldNameToOrgColumn(fieldName org_pb.OrgFieldName) query.Column {
switch fieldName {
case org_pb.OrgFieldName_ORG_FIELD_NAME_NAME:
return query.OrgColumnName
case org_pb.OrgFieldName_ORG_FIELD_NAME_UNSPECIFIED:
return query.Column{}
default:
return query.Column{}
}
}

View File

@ -52,8 +52,9 @@ var (
table: orgsTable,
}
OrgColumnName = Column{
name: projection.OrgColumnName,
table: orgsTable,
name: projection.OrgColumnName,
table: orgsTable,
isOrderByLower: true,
}
OrgColumnDomain = Column{
name: projection.OrgColumnDomain,

View File

@ -1569,6 +1569,8 @@ message ListMyProjectOrgsRequest {
zitadel.v1.ListQuery query = 1;
//criteria the client is looking for
repeated zitadel.org.v1.OrgQuery queries = 2;
// States by which field the results are sorted.
zitadel.org.v1.OrgFieldName sorting_column = 3;
}
message ListMyProjectOrgsResponse {