Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: changelist dash (#12879)

Danny Xufdb44f235c50
diff --git a/backend/api/v1/acl_iam.go b/backend/api/v1/acl_iam.go
index 30f8509386..2d9a36d485 100644
--- a/backend/api/v1/acl_iam.go
+++ b/backend/api/v1/acl_iam.go
@@ -162,7 +162,6 @@ func isSkippedMethod(fullMethod string) bool {
v1pb.IssueService_SearchIssues_FullMethodName,
v1pb.ProjectService_ListDatabaseGroups_FullMethodName,
v1pb.ProjectService_SearchProjects_FullMethodName,
- v1pb.ChangelistService_ListChangelists_FullMethodName,
v1pb.PlanService_ListPlans_FullMethodName,
v1pb.PlanService_SearchPlans_FullMethodName,
v1pb.UserGroupService_DeleteUserGroup_FullMethodName,
diff --git a/backend/api/v1/changelist_service.go b/backend/api/v1/changelist_service.go
index 7a905a0f2f..30104d34aa 100644
--- a/backend/api/v1/changelist_service.go
+++ b/backend/api/v1/changelist_service.go
@@ -121,36 +121,22 @@ func (s *ChangelistService) ListChangelists(ctx context.Context, request *v1pb.L
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, err.Error())
}
-
- user, ok := ctx.Value(common.UserContextKey).(*store.UserMessage)
- if !ok {
- return nil, status.Errorf(codes.Internal, "user not found")
- }
-
- projectIDs, err := getProjectIDsWithPermission(ctx, s.store, user, s.iamManager, iam.PermissionChangelistsList)
+ project, err := s.store.GetProjectV2(ctx, &store.FindProjectMessage{
+ ResourceID: &projectResourceID,
+ })
if err != nil {
- return nil, status.Errorf(codes.Internal, "failed to get projectIDs, error: %v", err)
+ return nil, status.Errorf(codes.Internal, fmt.Sprintf("failed to get project with resource id %q, err: %s", projectResourceID, err.Error()))
}
-
- find := &store.FindChangelistMessage{
- ProjectIDs: projectIDs,
+ if project == nil {
+ return nil, status.Errorf(codes.NotFound, fmt.Sprintf("project with resource id %q not found", projectResourceID))
}
- if projectResourceID != "-" {
- project, err := s.store.GetProjectV2(ctx, &store.FindProjectMessage{
- ResourceID: &projectResourceID,
- })
- if err != nil {
- return nil, status.Errorf(codes.Internal, fmt.Sprintf("failed to get project with resource id %q, err: %s", projectResourceID, err.Error()))
- }
- if project == nil {
- return nil, status.Errorf(codes.NotFound, fmt.Sprintf("project with resource id %q not found", projectResourceID))
- }
- if project.Deleted {
- return nil, status.Errorf(codes.NotFound, fmt.Sprintf("project with resource id %q had deleted", projectResourceID))
- }
- find.ProjectID = &projectResourceID
+ if project.Deleted {
+ return nil, status.Errorf(codes.NotFound, fmt.Sprintf("project with resource id %q had deleted", projectResourceID))
}
- changelists, err := s.store.ListChangelists(ctx, find)
+
+ changelists, err := s.store.ListChangelists(ctx, &store.FindChangelistMessage{
+ ProjectID: &projectResourceID,
+ })
if err != nil {
return nil, err
}
diff --git a/backend/api/v1/ctx.go b/backend/api/v1/ctx.go
index 0c1adbf5fb..908c635964 100644
--- a/backend/api/v1/ctx.go
+++ b/backend/api/v1/ctx.go
@@ -248,6 +248,8 @@ func (*ContextProvider) getProjectIDsForChangelistService(_ context.Context, req
switch r := req.(type) {
case *v1pb.CreateChangelistRequest:
projects = append(projects, r.GetParent())
+ case *v1pb.ListChangelistsRequest:
+ projects = append(projects, r.GetParent())
case *v1pb.GetChangelistRequest:
changelists = append(changelists, r.GetName())
}
diff --git a/backend/store/changelist.go b/backend/store/changelist.go
index 389da1e8fa..1fb8125bdc 100644
--- a/backend/store/changelist.go
+++ b/backend/store/changelist.go
@@ -32,7 +32,6 @@ type ChangelistMessage struct {
// FindChangelistMessage is the API message for finding changelists.
type FindChangelistMessage struct {
ProjectID *string
- ProjectIDs *[]string
ResourceID *string
}
@@ -66,9 +65,6 @@ func (s *Store) ListChangelists(ctx context.Context, find *FindChangelistMessage
if v := find.ProjectID; v != nil {
where, args = append(where, fmt.Sprintf("project.resource_id = $%d", len(args)+1)), append(args, *v)
}
- if v := find.ProjectIDs; v != nil {
- where, args = append(where, fmt.Sprintf("project.resource_id = ANY($%d)", len(args)+1)), append(args, *v)
- }
if v := find.ResourceID; v != nil {
where, args = append(where, fmt.Sprintf("changelist.name = $%d", len(args)+1)), append(args, *v)
}
diff --git a/frontend/src/types/proto/v1/changelist_service.ts b/frontend/src/types/proto/v1/changelist_service.ts
index cec23cce5d..384f081b06 100644
--- a/frontend/src/types/proto/v1/changelist_service.ts
+++ b/frontend/src/types/proto/v1/changelist_service.ts
@@ -39,7 +39,6 @@ export interface ListChangelistsRequest {
/**
* The parent, which owns this collection of changelists.
* Format: projects/{project}
- * Use "projects/-" to list all changelists.
*/
parent: string;
/**
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index f05a022a87..592c140b98 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -4024,7 +4024,7 @@ This value should be 4-63 characters, and valid characters are /[a-z][0-9]-/. |
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
-| parent | [string](#string) | | The parent, which owns this collection of changelists. Format: projects/{project} Use "projects/-" to list all changelists. |
+| parent | [string](#string) | | The parent, which owns this collection of changelists. Format: projects/{project} |
| page_size | [int32](#int32) | | The maximum number of databases to return. The service may return fewer than this value. If unspecified, at most 50 databases will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000. |
| page_token | [string](#string) | | A page token, received from a previous `ListDatabases` call. Provide this to retrieve the subsequent page.
diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.html
index 38e8bbb942..f1cfae740c 100644
--- a/proto/gen/grpc-doc/v1/index.html
+++ b/proto/gen/grpc-doc/v1/index.html
@@ -11953,8 +11953,7 @@ Format: projects/{project}/changelists/{changelist} </p></td>
<td><a href="#string">string</a></td>
<td></td>
<td><p>The parent, which owns this collection of changelists.
-Format: projects/{project}
-Use &#34;projects/-&#34; to list all changelists. </p></td>
+Format: projects/{project} </p></td>
</tr>
<tr>
diff --git a/proto/generated-go/v1/changelist_service.pb.go b/proto/generated-go/v1/changelist_service.pb.go
index 5fe93e34da..dc266204cf 100644
--- a/proto/generated-go/v1/changelist_service.pb.go
+++ b/proto/generated-go/v1/changelist_service.pb.go
@@ -151,7 +151,6 @@ type ListChangelistsRequest struct {
// The parent, which owns this collection of changelists.
// Format: projects/{project}
- // Use "projects/-" to list all changelists.
Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"`
// The maximum number of databases to return. The service may return fewer than
// this value.
diff --git a/proto/v1/changelist_service.proto b/proto/v1/changelist_service.proto
index 94e1d55488..580723502a 100644
--- a/proto/v1/changelist_service.proto
+++ b/proto/v1/changelist_service.proto
@@ -69,7 +69,6 @@ message GetChangelistRequest {
message ListChangelistsRequest {
// The parent, which owns this collection of changelists.
// Format: projects/{project}
- // Use "projects/-" to list all changelists.
string parent = 1 [(google.api.field_behavior) = REQUIRED];
// The maximum number of databases to return. The service may return fewer than