Skip to content

Commit

Permalink
Impl repo scoped app fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
motoki317 committed Dec 4, 2023
1 parent ae4c3c0 commit 48fdc39
Show file tree
Hide file tree
Showing 6 changed files with 416 additions and 349 deletions.
2 changes: 2 additions & 0 deletions api/proto/neoshowcase/protobuf/gateway.proto
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,10 @@ message GetApplicationsRequest {
enum Scope {
MINE = 0;
ALL = 1;
REPOSITORY = 2;
}
Scope scope = 1;
optional string repository_id = 2;
}

message UpdateApplicationRequest {
Expand Down
12 changes: 12 additions & 0 deletions dashboard/src/api/neoshowcase/protobuf/gateway_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2630,6 +2630,11 @@ export class GetApplicationsRequest extends Message<GetApplicationsRequest> {
*/
scope = GetApplicationsRequest_Scope.MINE;

/**
* @generated from field: optional string repository_id = 2;
*/
repositoryId?: string;

constructor(data?: PartialMessage<GetApplicationsRequest>) {
super();
proto3.util.initPartial(data, this);
Expand All @@ -2639,6 +2644,7 @@ export class GetApplicationsRequest extends Message<GetApplicationsRequest> {
static readonly typeName = "neoshowcase.protobuf.GetApplicationsRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "scope", kind: "enum", T: proto3.getEnumType(GetApplicationsRequest_Scope) },
{ no: 2, name: "repository_id", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GetApplicationsRequest {
Expand Down Expand Up @@ -2671,11 +2677,17 @@ export enum GetApplicationsRequest_Scope {
* @generated from enum value: ALL = 1;
*/
ALL = 1,

/**
* @generated from enum value: REPOSITORY = 2;
*/
REPOSITORY = 2,
}
// Retrieve enum metadata with: proto3.getEnumType(GetApplicationsRequest_Scope)
proto3.util.setEnumType(GetApplicationsRequest_Scope, "neoshowcase.protobuf.GetApplicationsRequest.Scope", [
{ no: 0, name: "MINE" },
{ no: 1, name: "ALL" },
{ no: 2, name: "REPOSITORY" },
]);

/**
Expand Down
7 changes: 5 additions & 2 deletions pkg/infrastructure/grpc/api_app_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ func (s *APIService) CreateApplication(ctx context.Context, req *connect.Request
}

func (s *APIService) GetApplications(ctx context.Context, req *connect.Request[pb.GetApplicationsRequest]) (*connect.Response[pb.GetApplicationsResponse], error) {
all := req.Msg.Scope == pb.GetApplicationsRequest_ALL
apps, err := s.svc.GetApplications(ctx, all)
scope := apiserver.GetAppScope{
Scope: pbconvert.AppScopeMapper.IntoMust(req.Msg.Scope),
RepositoryID: optional.FromPtr(req.Msg.RepositoryId),
}
apps, err := s.svc.GetApplications(ctx, scope)
if err != nil {
return nil, handleUseCaseError(err)
}
Expand Down
Loading

0 comments on commit 48fdc39

Please sign in to comment.