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" org_grpc "github.com/zitadel/zitadel/internal/api/grpc/org"
"github.com/zitadel/zitadel/internal/query" "github.com/zitadel/zitadel/internal/query"
"github.com/zitadel/zitadel/pkg/grpc/admin" "github.com/zitadel/zitadel/pkg/grpc/admin"
"github.com/zitadel/zitadel/pkg/grpc/org"
) )
func listOrgRequestToModel(req *admin.ListOrgsRequest) (*query.OrgSearchQueries, error) { func listOrgRequestToModel(req *admin.ListOrgsRequest) (*query.OrgSearchQueries, error) {
@ -18,18 +17,9 @@ func listOrgRequestToModel(req *admin.ListOrgsRequest) (*query.OrgSearchQueries,
SearchRequest: query.SearchRequest{ SearchRequest: query.SearchRequest{
Offset: offset, Offset: offset,
Limit: limit, Limit: limit,
SortingColumn: fieldNameToOrgColumn(req.SortingColumn), SortingColumn: org_grpc.FieldNameToOrgColumn(req.SortingColumn),
Asc: asc, Asc: asc,
}, },
Queries: queries, Queries: queries,
}, nil }, 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{ return &query.OrgSearchQueries{
SearchRequest: query.SearchRequest{ SearchRequest: query.SearchRequest{
Offset: offset, Offset: offset,
Limit: limit, Limit: limit,
Asc: asc, Asc: asc,
SortingColumn: org.FieldNameToOrgColumn(req.SortingColumn),
}, },
Queries: queries, Queries: queries,
}, nil }, nil

View File

@ -186,3 +186,14 @@ func DomainValidationTypeFromModel(validationType domain.OrgDomainValidationType
return org_pb.DomainValidationType_DOMAIN_VALIDATION_TYPE_UNSPECIFIED 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, table: orgsTable,
} }
OrgColumnName = Column{ OrgColumnName = Column{
name: projection.OrgColumnName, name: projection.OrgColumnName,
table: orgsTable, table: orgsTable,
isOrderByLower: true,
} }
OrgColumnDomain = Column{ OrgColumnDomain = Column{
name: projection.OrgColumnDomain, name: projection.OrgColumnDomain,

View File

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