Skip to content

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

fix: access grant and cosmos db issue (#21126)

ecmadaofdd88c3e7723
diff --git a/backend/api/mcp/gen/openapi.yaml b/backend/api/mcp/gen/openapi.yaml
index 448c66707d..be1fe8035d 100644
--- a/backend/api/mcp/gen/openapi.yaml
+++ b/backend/api/mcp/gen/openapi.yaml
@@ -8067,6 +8067,14 @@ components:
type: boolean
title: export
description: Whether export the query result.
+ schema:
+ type: string
+ title: schema
+ description: The default schema to execute the query.
+ container:
+ type: string
+ title: container
+ description: The container name to execute the query against, used for CosmosDB only.
- oneOf:
- type: object
properties:
diff --git a/backend/api/v1/access_grant_service.go b/backend/api/v1/access_grant_service.go
index 0e839e6f9a..e1d32a50b0 100644
--- a/backend/api/v1/access_grant_service.go
+++ b/backend/api/v1/access_grant_service.go
@@ -214,6 +214,8 @@ func (s *AccessGrantService) CreateAccessGrant(ctx context.Context, request *con
Export: ag.Export,
Reason: ag.Reason,
RequestedDuration: requestedDuration,
+ Schema: ag.Schema,
+ Container: ag.Container,
},
})
if err != nil {
@@ -491,6 +493,8 @@ func convertToAccessGrant(msg *store.AccessGrantMessage) *v1pb.AccessGrant {
ag.Unmask = p.Unmask
ag.Export = p.Export
ag.Reason = p.Reason
+ ag.Schema = p.Schema
+ ag.Container = p.Container
if p.IssueId != 0 {
ag.Issue = common.FormatIssue(msg.ProjectID, p.IssueId)
}
diff --git a/backend/api/v1/access_grant_service_test.go b/backend/api/v1/access_grant_service_test.go
index 9f3aa4fa8c..4f70c121c1 100644
--- a/backend/api/v1/access_grant_service_test.go
+++ b/backend/api/v1/access_grant_service_test.go
@@ -95,11 +95,13 @@ func TestConvertToAccessGrantPropagatesPayloadFields(t *testing.T) {
Status: storepb.AccessGrant_ACTIVE,
ExpireTime: &expire,
Payload: &storepb.AccessGrantPayload{
- Targets: []string{"instances/inst/databases/db"},
- Query: "SELECT * FROM t",
- Unmask: true,
- Export: true,
- Reason: "investigating PR-1234",
+ Targets: []string{"instances/inst/databases/db"},
+ Query: "SELECT * FROM t",
+ Unmask: true,
+ Export: true,
+ Reason: "investigating PR-1234",
+ Schema: "APP",
+ Container: "orders",
},
}
@@ -110,6 +112,8 @@ func TestConvertToAccessGrantPropagatesPayloadFields(t *testing.T) {
require.True(t, ag.Unmask)
require.True(t, ag.Export)
require.Equal(t, "investigating PR-1234", ag.Reason)
+ require.Equal(t, "APP", ag.Schema)
+ require.Equal(t, "orders", ag.Container)
}
// TestConvertToAccessGrantNilPayloadIsSafe guards the `if p := msg.Payload; p != nil`
@@ -130,4 +134,69 @@ func TestConvertToAccessGrantNilPayloadIsSafe(t *testing.T) {
require.False(t, ag.Unmask)
require.False(t, ag.Export)
require.Empty(t, ag.Reason)
+ require.Empty(t, ag.Schema)
+ require.Empty(t, ag.Container)
+}
+
+func TestAccessGrantMatchesExecutionContext(t *testing.T) {
+ schema := "APP"
+ tests := []struct {
+ name string
+ payload *storepb.AccessGrantPayload
+ schema *string
+ container string
+ want bool
+ }{
+ {
+ name: "matching schema and container",
+ payload: &storepb.AccessGrantPayload{
+ Schema: "APP",
+ Container: "orders",
+ },
+ schema: &schema,
+ container: "orders",
+ want: true,
+ },
+ {
+ name: "different schema",
+ payload: &storepb.AccessGrantPayload{
+ Schema: "APP",
+ Container: "orders",
+ },
+ schema: func() *string { v := "OTHER"; return &v }(),
+ container: "orders",
+ want: false,
+ },
+ {
+ name: "different container",
+ payload: &storepb.AccessGrantPayload{
+ Schema: "APP",
+ Container: "orders",
+ },
+ schema: &schema,
+ container: "customers",
+ want: false,
+ },
+ {
+ name: "nil payload",
+ payload: nil,
+ schema: &schema,
+ container: "orders",
+ want: false,
+ },
+ {
+ name: "empty context matches omitted values",
+ payload: &storepb.AccessGrantPayload{},
+ schema: nil,
+ container: "",
+ want: true,
+ },
+ }
+
+ for _, tc := range tests {
+ t.Run(tc.name, func(t *testing.T) {
+ grant := &store.AccessGrantMessage{Payload: tc.payload}
+ require.Equal(t, tc.want, accessGrantMatchesExecutionContext(grant, tc.schema, tc.container))
+ })
+ }
}
diff --git a/backend/api/v1/sql_service.go b/backend/api/v1/sql_service.go
index 6c4bc73a7f..a002eddd4c 100644
--- a/backend/api/v1/sql_service.go
+++ b/backend/api/v1/sql_service.go
@@ -198,7 +198,7 @@ func buildExportQueryContext(restriction *store.EffectiveQueryDataPolicy, userEm
//
// The returned grant has a non-nil Payload — callers may deref
// `Payload.Unmask` / `Payload.Export` without an additional check.
-func (s *SQLService) preCheckAccess(ctx context.Context, statement string, instance *store.InstanceMessage, database *store.DatabaseMessage, requireExport bool) *store.AccessGrantMessage {
+func (s *SQLService) preCheckAccess(ctx context.Context, statement string, instance *store.InstanceMessage, database *store.DatabaseMessage, schema *string, container string, requireExport bool) *store.AccessGrantMessage {
project, err := s.store.GetProject(ctx, &store.FindProjectMessage{
Workspace: common.GetWorkspaceIDFromContext(ctx),
ResourceID: &database.ProjectID,
@@ -262,7 +262,13 @@ func (s *SQLService) preCheckAccess(ctx context.Context, statement string, insta
slog.Warn("skip access grant for non-read-only query", slog.String("instance", instance.ResourceID), slog.String("database", database.DatabaseName))
return nil
}
- return selectBestAccessGrant(grants)
+ matchingGrants := make([]*store.AccessGrantMessage, 0, len(grants))
+ for _, grant := range grants {
+ if accessGrantMatchesExecutionContext(grant, schema, container) {
+ matchingGrants = append(matchingGrants, grant)
+ }
+ }
+ return selectBestAccessGrant(matchingGrants)
}
// selectBestAccessGrant picks the highest-ranked grant by capability count
@@ -306,6 +312,17 @@ func selectBestAccessGrant(grants []*store.AccessGrantMessage) *store.AccessGran
return best
}
+func accessGrantMatchesExecutionContext(grant *store.AccessGrantMessage, schema *string, container string) bool {
+ if grant.Payload == nil {
+ return false
+ }
+ requestSchema := ""
+ if schema != nil {
+ requestSchema = *schema
+ }
+ return grant.Payload.Schema == requestSchema && grant.Payload.Container == container
+}
+
func (s *SQLService) Query(ctx context.Context, req *connect.Request[v1pb.QueryRequest]) (*connect.Response[v1pb.QueryResponse], error) {
request := req.Msg
// Prepare related message.
@@ -314,7 +331,7 @@ func (s *SQLService) Query(ctx context.Context, req *connect.Request[v1pb.QueryR
return nil, err
}
- accessGrant := s.preCheckAccess(ctx, request.Statement, instance, database, false /* requireExport */)
+ accessGrant := s.preCheckAccess(ctx, request.Statement, instance, database, request.Schema, request.GetContainer(), false /* requireExport */)
statement := request.Statement
// In Redshift datashare, Rewrite query used for parser.
@@ -981,7 +998,7 @@ func (s *SQLService) Export(ctx context.Context, req *connect.Request[v1pb.Expor
// requireExport=true narrows the CEL filter to grants with export=true,
// so a tied unmask-only grant can't shadow a separately-active export
// grant via slice order (PR #20491 bot review).
- accessGrant := s.preCheckAccess(ctx, request.Statement, instance, database, true /* requireExport */)
+ accessGrant := s.preCheckAccess(ctx, request.Statement, instance, database, request.Schema, request.GetContainer(), true /* requireExport */)
// Validate the request.
// New query ACL experience.
diff --git a/backend/generated-go/store/access_grant.pb.go b/backend/generated-go/store/access_grant.pb.go
index 820ce7ada0..0cb11792c1 100644
--- a/backend/generated-go/store/access_grant.pb.go
+++ b/backend/generated-go/store/access_grant.pb.go
@@ -127,7 +127,11 @@ type AccessGrantPayload struct {
// The server computes expire_time from this value at activation time.
RequestedDuration *durationpb.Duration `protobuf:"bytes,6,opt,name=requested_duration,json=requestedDuration,proto3" json:"requested_duration,omitempty"`
// Whether export the query result.
- Export bool `protobuf:"varint,7,opt,name=export,proto3" json:"export,omitempty"`
+ Export bool `protobuf:"varint,7,opt,name=export,proto3" json:"export,omitempty"`
+ // The default schema to execute the query.
+ Schema string `protobuf:"bytes,8,opt,name=schema,proto3" json:"schema,omitempty"`
+ // The container name to execute the query against, used for CosmosDB only.
+ Container string `protobuf:"bytes,9,opt,name=container,proto3" json:"container,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -211,6 +215,20 @@ func (x *AccessGrantPayload) GetExport() bool {
return false
}
+func (x *AccessGrantPayload) GetSchema() string {
+ if x != nil {
+ return x.Schema
+ }
+ return ""
+}
+
+func (x *AccessGrantPayload) GetContainer() string {
+ if x != nil {
+ return x.Container
+ }
+ return ""
+}
+
var File_store_access_grant_proto protoreflect.FileDescriptor
const file_store_access_grant_proto_rawDesc = "" +
@@ -222,7 +240,7 @@ const file_store_access_grant_proto_rawDesc = "" +
"\aPENDING\x10\x01\x12\n" +
"\n" +
"\x06ACTIVE\x10\x02\x12\v\n" +
- "\aREVOKED\x10\x03\"\xf1\x01\n" +
+ "\aREVOKED\x10\x03\"\xa7\x02\n" +
"\x12AccessGrantPayload\x12\x19\n" +
"\bissue_id\x18\x01 \x01(\x03R\aissueId\x12\x18\n" +
"\atargets\x18\x02 \x03(\tR\atargets\x12\x14\n" +
@@ -230,7 +248,9 @@ const file_store_access_grant_proto_rawDesc = "" +
"\x06unmask\x18\x04 \x01(\bR\x06unmask\x12\x16\n" +
"\x06reason\x18\x05 \x01(\tR\x06reason\x12H\n" +
"\x12requested_duration\x18\x06 \x01(\v2\x19.google.protobuf.DurationR\x11requestedDuration\x12\x16\n" +
- "\x06export\x18\a \x01(\bR\x06exportB\x93\x01\n" +
+ "\x06export\x18\a \x01(\bR\x06export\x12\x16\n" +
+ "\x06schema\x18\b \x01(\tR\x06schema\x12\x1c\n" +
+ "\tcontainer\x18\t \x01(\tR\tcontainerB\x93\x01\n" +
"\x12com.bytebase.storeB\x10AccessGrantProtoP\x01Z\x12generated-go/store\xa2\x02\x03BSX\xaa\x02\x0eBytebase.Store\xca\x02\x0eBytebase\\Store\xe2\x02\x1aBytebase\\Store\\GPBMetadata\xea\x02\x0fBytebase::Storeb\x06proto3"
var (
diff --git a/backend/generated-go/store/access_grant_equal.pb.go b/backend/generated-go/store/access_grant_equal.pb.go
index ad6fb5984e..9d8c441380 100644
--- a/backend/generated-go/store/access_grant_equal.pb.go
+++ b/backend/generated-go/store/access_grant_equal.pb.go
@@ -46,5 +46,11 @@ func (x *AccessGrantPayload) Equal(y *AccessGrantPayload) bool {
if x.Export != y.Export {
return false
}
+ if x.Schema != y.Schema {
+ return false
+ }
+ if x.Container != y.Container {
+ return false
+ }
return true
}
diff --git a/backend/generated-go/v1/access_grant_service.pb.go b/backend/generated-go/v1/access_grant_service.pb.go
index ba36ce4004..74be07cdaa 100644
--- a/backend/generated-go/v1/access_grant_service.pb.go
+++ b/backend/generated-go/v1/access_grant_service.pb.go
@@ -119,7 +119,11 @@ type AccessGrant struct {
UpdateTime *timestamppb.Timestamp `protobuf:"bytes,10,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty"`
Reason string `protobuf:"bytes,12,opt,name=reason,proto3" json:"reason,omitempty"`
// Whether export the query result.
- Export bool `protobuf:"varint,13,opt,name=export,proto3" json:"export,omitempty"`
+ Export bool `protobuf:"varint,13,opt,name=export,proto3" json:"export,omitempty"`
+ // The default schema to execute the query.
+ Schema string `protobuf:"bytes,14,opt,name=schema,proto3" json:"schema,omitempty"`
+ // The container name to execute the query against, used for CosmosDB only.
+ Container string `protobuf:"bytes,15,opt,name=container,proto3" json:"container,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -256,6 +260,20 @@ func (x *AccessGrant) GetExport() bool {
return false
}
+func (x *AccessGrant) GetSchema() string {
+ if x != nil {
+ return x.Schema
+ }
+ return ""
+}
+
+func (x *AccessGrant) GetContainer() string {
+ if x != nil {
+ return x.Container
+ }
+ return ""
+}
+
type isAccessGrant_Expiration interface {
isAccessGrant_Expiration()
}
@@ -773,7 +791,7 @@ var File_v1_access_grant_service_proto protoreflect.FileDescriptor
const file_v1_access_grant_service_proto_rawDesc = "" +
"\n" +
- "\x1dv1/access_grant_service.proto\x12\vbytebase.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x13v1/annotation.proto\"\xb2\x05\n" +
+ "\x1dv1/access_grant_service.proto\x12\vbytebase.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x13v1/annotation.proto\"\xe8\x05\n" +
"\vAccessGrant\x12\x12\n" +
"\x04name\x18\x01 \x01(\tR\x04name\x12\x1d\n" +
"\acreator\x18\x02 \x01(\tB\x03\xe0A\x02R\acreator\x12<\n" +
@@ -791,7 +809,9 @@ const file_v1_access_grant_service_proto_rawDesc = "" +
" \x01(\v2\x1a.google.protobuf.TimestampB\x03\xe0A\x03R\n" +
"updateTime\x12\x16\n" +
"\x06reason\x18\f \x01(\tR\x06reason\x12\x16\n" +
- "\x06export\x18\r \x01(\bR\x06export\"F\n" +
+ "\x06export\x18\r \x01(\bR\x06export\x12\x16\n" +
+ "\x06schema\x18\x0e \x01(\tR\x06schema\x12\x1c\n" +
+ "\tcontainer\x18\x0f \x01(\tR\tcontainer\"F\n" +
"\x06Status\x12\x16\n" +
"\x12STATUS_UNSPECIFIED\x10\x00\x12\v\n" +
"\aPENDING\x10\x01\x12\n" +
diff --git a/backend/generated-go/v1/access_grant_service_equal.pb.go b/backend/generated-go/v1/access_grant_service_equal.pb.go
index 0e34eba682..51b97081e2 100644
--- a/backend/generated-go/v1/access_grant_service_equal.pb.go
+++ b/backend/generated-go/v1/access_grant_service_equal.pb.go
@@ -54,6 +54,12 @@ func (x *AccessGrant) Equal(y *AccessGrant) bool {
if x.Export != y.Export {
return false
}
+ if x.Schema != y.Schema {
+ return false
+ }
+ if x.Container != y.Container {
+ return false
+ }
return true
}
diff --git a/backend/plugin/db/cosmosdb/cosmosdb.go b/backend/plugin/db/cosmosdb/cosmosdb.go
index 5d4d4d96ea..5059126270 100644
--- a/backend/plugin/db/cosmosdb/cosmosdb.go
+++ b/backend/plugin/db/cosmosdb/cosmosdb.go
@@ -192,6 +192,7 @@ func (d *Driver) QueryConn(ctx context.Context, _ *sql.Conn, statement string, q
result := &v1pb.QueryResult{
ColumnNames: []string{"result"},
ColumnTypeNames: []string{"TEXT"},
+ Statement: statement,
}
for _, item := range items {
result.Rows = append(result.Rows, &v1pb.QueryRow{
@@ -202,6 +203,7 @@ func (d *Driver) QueryConn(ctx context.Context, _ *sql.Conn, statement string, q
}
result.Latency = durationpb.New(time.Since(startTime))
+ result.RowsCount = int64(len(result.Rows))
return []*v1pb.QueryResult{result}, nil
}
diff --git a/backend/plugin/db/cosmosdb/cosmosdb_integration_test.go b/backend/plugin/db/cosmosdb/cosmosdb_integration_test.go
index 32e48cba0c..6124438137 100644
--- a/backend/plugin/db/cosmosdb/cosmosdb_integration_test.go
+++ b/backend/plugin/db/cosmosdb/cosmosdb_integration_test.go
@@ -78,6 +78,7 @@ func runQuery(t *testing.T, driver *Driver, container, sql string) [][]byte {
results, err := driver.QueryConn(ctx, nil, sql, db.QueryContext{Container: container})
require.NoError(t, err, "QueryConn: %s", sql)
require.Len(t, results, 1, "driver returns exactly one QueryResult per query")
+ require.Equal(t, sql, results[0].Statement)
out := make([][]byte, 0, len(results[0].Rows))
for _, row := range results[0].Rows {
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 32c321ead9..8bb9b7ffad 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1302,6 +1302,7 @@
}
}
},
+ "container": "Container",
"details": "Access grant details",
"duration-after-approval": "{{duration}} after issue approved",
"expired-at": "Expired at",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index dd6af5fc86..2dbb71f1e5 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1302,6 +1302,7 @@
}
}
},
+ "container": "Contenedor",
"details": "Detalles de la concesión de acceso",
"duration-after-approval": "{{duration}} después de aprobar la solicitud",
"expired-at": "Expiró el",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 214ea4380d..3914df9224 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1302,6 +1302,7 @@
}
}
},
+ "container": "コンテナ",
"details": "アクセス付与の詳細",
"duration-after-approval": "Issue 承認後 {{duration}}",
"expired-at": "有効期限",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 89dca608b1..bb7ee07b59 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -1302,6 +1302,7 @@
}
}
},
+ "container": "Container",
"details": "Chi tiết cấp quyền truy cập",
"duration-after-approval": "{{duration}} sau khi yêu cầu được duyệt",
"expired-at": "Hết hạn lúc",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 7d8f57c5ef..d230227a09 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1302,6 +1302,7 @@
}
}
},
+ "container": "容器",
"details": "访问授权详情",
"duration-after-approval": "工单批准后 {{duration}}",
"expired-at": "过期时间",
diff --git a/frontend/src/modules/sql-editor/components/AccessGrantItem.test.tsx b/frontend/src/modules/sql-editor/components/AccessGrantItem.test.tsx
index a21f1dc0ed..fec2122719 100644
--- a/frontend/src/modules/sql-editor/components/AccessGrantItem.test.tsx
+++ b/frontend/src/modules/sql-editor/components/AccessGrantItem.test.tsx
@@ -16,6 +16,19 @@ const mocks = vi.hoisted(() => ({
getAccessGrantStatusTagType: vi.fn(),
}));
+vi.mock("@/components/DatabaseTargetDisplay", () => ({
+ DatabaseTargetDisplay: (props: {
+ target: string;
+ showEnvironment?: boolean;
+ }) => (
+ <span
+ data-testid="database-target-display"
+ data-target={props.target}
+ data-show-environment={String(props.showEnvironment)}
+ />
+ ),
+}));
+
vi.mock("react-i18next", () => ({
useTranslation: mocks.useTranslation,
}));
@@ -142,6 +155,43 @@ afterEach(() => {
});
describe("AccessGrantItem", () => {
+ test("renders database targets with the unified display", () => {
+ const grant = makeGrant({
+ targets: [
+ "instances/inst1/databases/db1",
+ "instances/inst2/databases/db2",
+ "instances/inst3/databases/db3",
+ ],
+ });
+
+ const { container, render, unmount } = renderIntoContainer(
+ <AccessGrantItem
+ grant={grant as never}
+ onRun={vi.fn()}
+ onRequest={vi.fn()}
+ />
+ );
+ render();
+
+ const targets = Array.from(
+ container.querySelectorAll("[data-testid='database-target-display']")
+ );
+ expect(targets).toHaveLength(2);
+ expect(targets[0]?.getAttribute("data-target")).toBe(
+ "instances/inst1/databases/db1"
+ );
+ expect(targets[1]?.getAttribute("data-target")).toBe(
+ "instances/inst2/databases/db2"
+ );
+ expect(
+ targets.every(
+ (target) => target.getAttribute("data-show-environment") === "true"
+ )
+ ).toBe(true);
+ expect(container.textContent).toContain("sql-editor.and-n-more-databases");
+ unmount();
+ });
+
test("renders status badge with correct label for ACTIVE status", () => {
mocks.getAccessGrantDisplayStatus.mockReturnValue("ACTIVE");
mocks.getAccessGrantDisplayStatusText.mockReturnValue("Active");
diff --git a/frontend/src/modules/sql-editor/components/AccessGrantItem.tsx b/frontend/src/modules/sql-editor/components/AccessGrantItem.tsx
index fe7f077d5d..7fb5e36a94 100644
--- a/frontend/src/modules/sql-editor/components/AccessGrantItem.tsx
+++ b/frontend/src/modules/sql-editor/components/AccessGrantItem.tsx
@@ -1,4 +1,5 @@
import { useTranslation } from "react-i18next";
+import { DatabaseTargetDisplay } from "@/components/DatabaseTargetDisplay";
import { RouterLink } from "@/components/RouterLink";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
@@ -69,14 +70,26 @@ export function AccessGrantItem({
return `${t("issue.access-grant.expired-at")} ${info.value}`;
})();
- const allDatabaseNames = grant.targets.map((tgt) => {
- const match = tgt.match(/databases\/(.+)$/);
- return match ? match[1] : tgt;
- });
- const databaseNamesDisplay =
- allDatabaseNames.length <= 2
- ? allDatabaseNames.join(", ")
- : `${allDatabaseNames.slice(0, 2).join(", ")} ${t("sql-editor.and-n-more-databases", { n: allDatabaseNames.length - 2 })}`;
+ const visibleTargets = grant.targets.slice(0, 2);
+ const remainingTargetCount = grant.targets.length - visibleTargets.length;
+ const databaseTargets = (
+ <div className="flex w-full min-w-0 flex-col gap-y-1">
+ {visibleTargets.map((target, index) => (
+ <DatabaseTargetDisplay
+ key={`${target}-${index}`}
+ target={target}
+ showEnvironment
+ />
+ ))}
+ {remainingTargetCount > 0 && (
+ <span className="text-xs text-control-placeholder">
+ {t("sql-editor.and-n-more-databases", {
+ n: remainingTargetCount,
+ })}
+ </span>
+ )}
+ </div>
+ );
const issueLink = grant.issue
? grant.issue.startsWith("/")
@@ -156,24 +169,24 @@ export function AccessGrantItem({
</Tooltip>
<div className="w-full flex flex-col gap-y-2">
- {allDatabaseNames.length <= 2 ? (
- <span className="text-xs text-control-placeholder truncate">
- {databaseNamesDisplay}
- </span>
+ {remainingTargetCount === 0 ? (
+ databaseTargets
) : (
<Tooltip
content={
- <div className="flex flex-col">
- {allDatabaseNames.map((n) => (
- <span key={n}>{n}</span>
+ <div className="flex max-w-lg flex-col gap-y-1">
+ {grant.targets.map((target, index) => (
+ <DatabaseTargetDisplay
+ key={`${target}-${index}`}
+ target={target}
+ showEnvironment
+ />
))}
</div>
}
side="right"
>
- <span className="text-xs text-control-placeholder truncate">
- {databaseNamesDisplay}
- </span>
+ {databaseTargets}
</Tooltip>
)}
diff --git a/frontend/src/modules/sql-editor/components/AccessGrantRequestDrawer.test.tsx b/frontend/src/modules/sql-editor/components/AccessGrantRequestDrawer.test.tsx
index 2e3428ce25..db3c902fd9 100644
--- a/frontend/src/modules/sql-editor/components/AccessGrantRequestDrawer.test.tsx
+++ b/frontend/src/modules/sql-editor/components/AccessGrantRequestDrawer.test.tsx
@@ -13,6 +13,8 @@ const mocks = vi.hoisted(() => ({
project: "projects/proj1" as string,
// Current tab connection database used to derive default targets.
currentTabDatabase: "instances/inst1/databases/db1" as string | undefined,
+ currentTabSchema: undefined as string | undefined,
+ currentTabTable: undefined as string | undefined,
// New zustand setters.
setAsidePanelTab: vi.fn(),
setHighlightAccessGrantName: vi.fn(),
@@ -78,7 +80,16 @@ vi.mock("@/modules/sql-editor/store/tab", () => ({
getSQLEditorTabsState: () => ({
currentTabId: "tab1",
tabsById: new Map([
- ["tab1", { connection: { database: mocks.currentTabDatabase } }],
+ [
+ "tab1",
+ {
+ connection: {
+ database: mocks.currentTabDatabase,
+ schema: mocks.currentTabSchema,
+ table: mocks.currentTabTable,
+ },
+ },
+ ],
]),
}),
useSQLEditorTabState: (
@@ -368,8 +379,10 @@ const setupMocks = () => {
mocks.project = "projects/proj1";
mocks.currentTabDatabase = "instances/inst1/databases/db1";
+ mocks.currentTabSchema = undefined;
+ mocks.currentTabTable = undefined;
- mocks.fetchDatabases.mockResolvedValue({ databases: [], nextPageToken: "" });
+ mocks.fetchDatabases.mockResolvedValue({ databases: [], nextPageToken: "" });
// vi.clearAllMocks() does not reset a plain hoisted property.
mocks.dbOnSearch = undefined;
mocks.maximumRequestExpirationSeconds = undefined;
@@ -688,4 +701,115 @@ describe("AccessGrantRequestDrawer", () => {
);
unmount();
});
+
+ test("current schema and CosmosDB container are submitted to createAccessGrant", async () => {
+ mocks.currentTabSchema = "APP";
+ mocks.currentTabTable = "orders";
+ mocks.createAccessGrant.mockResolvedValue({
+ status: 2,
+ issue: "",
+ name: "projects/proj1/accessGrants/g",
+ });
+ const onClose = vi.fn();
+ const {
+ container,
+ render: renderFn,
+ unmount,
+ } = renderIntoContainer(
+ <AccessGrantRequestDrawer
+ targets={["instances/inst1/databases/db1"]}
+ query="SELECT * FROM orders"
+ onClose={onClose}
+ />
+ );
+ renderFn();
+
+ const textarea = container.querySelector(
+ "[data-testid='textarea']"
+ ) as HTMLTextAreaElement;
+ await act(async () => {
+ const changeEvent = new Event("change", { bubbles: true });
+ Object.defineProperty(textarea, "value", {
+ writable: true,
+ value: "investigate orders",
+ });
+ Object.defineProperty(changeEvent, "target", {
+ writable: false,
+ value: textarea,
+ });
+ textarea.dispatchEvent(changeEvent);
+ });
+
+ const submitBtn = container.querySelector(
+ "[data-submit-btn]"
+ ) as HTMLButtonElement;
+ await act(async () => submitBtn.click());
+
+ expect(mocks.createAccessGrant).toHaveBeenCalledWith(
+ expect.objectContaining({
+ accessGrant: expect.objectContaining({
+ schema: "APP",
+ container: "orders",
+ }),
+ })
+ );
+ unmount();
+ });
+
+ test("prop schema and CosmosDB container are submitted to createAccessGrant", async () => {
+ mocks.currentTabDatabase = "instances/inst1/databases/db1";
+ mocks.currentTabSchema = "ACTIVE_TAB_SCHEMA";
+ mocks.currentTabTable = "active-tab-container";
+ mocks.createAccessGrant.mockResolvedValue({
+ status: 2,
+ issue: "",
+ name: "projects/proj1/accessGrants/g",
+ });
+ const onClose = vi.fn();
+ const {
+ container,
+ render: renderFn,
+ unmount,
+ } = renderIntoContainer(
+ <AccessGrantRequestDrawer
+ targets={["instances/inst1/databases/db2"]}
+ query="SELECT * FROM orders"
+ schema="REQUEST_SCHEMA"
+ container="request-container"
+ onClose={onClose}
+ />
+ );
+ renderFn();
+
+ const textarea = container.querySelector(
+ "[data-testid='textarea']"
+ ) as HTMLTextAreaElement;
+ await act(async () => {
+ const changeEvent = new Event("change", { bubbles: true });
+ Object.defineProperty(textarea, "value", {
+ writable: true,
+ value: "rerun existing grant",
+ });
+ Object.defineProperty(changeEvent, "target", {
+ writable: false,
+ value: textarea,
+ });
+ textarea.dispatchEvent(changeEvent);
+ });
+
+ const submitBtn = container.querySelector(
+ "[data-submit-btn]"
+ ) as HTMLButtonElement;
+ await act(async () => submitBtn.click());
+
+ expect(mocks.createAccessGrant).toHaveBeenCalledWith(
+ expect.objectContaining({
+ accessGrant: expect.objectContaining({
+ schema: "REQUEST_SCHEMA",
+ container: "request-container",
+ }),
+ })
+ );
+ unmount();
+ });
});
diff --git a/frontend/src/modules/sql-editor/components/AccessGrantRequestDrawer.tsx b/frontend/src/modules/sql-editor/components/AccessGrantRequestDrawer.tsx
index b972022a0b..45ddb2b201 100644
--- a/frontend/src/modules/sql-editor/components/AccessGrantRequestDrawer.tsx
+++ b/frontend/src/modules/sql-editor/components/AccessGrantRequestDrawer.tsx
@@ -57,6 +57,8 @@ interface Props {
readonly query?: string;
readonly unmask?: boolean;
readonly export?: boolean;
+ readonly schema?: string;
+ readonly container?: string;
readonly onClose: () => void;
}
@@ -102,11 +104,21 @@ function AccessGrantRequestDrawerInner({
?.database;
return database ? [database] : [];
}, [stableProps.targets]);
+ const defaultConnectionContext = useMemo(() => {
+ const tabsState = getSQLEditorTabsState();
+ return tabsState.tabsById.get(tabsState.currentTabId)?.connection;
+ }, []);
const [targets, setTargets] = useState<string[]>(defaultTargets);
const [query, setQuery] = useState(stableProps.query ?? "");
const [unmask, setUnmask] = useState(stableProps.unmask ?? false);
const [exportResult, setExportResult] = useState(stableProps.export ?? false);
+ const [schema] = useState(
+ stableProps.schema ?? defaultConnectionContext?.schema ?? ""
+ );
+ const [container] = useState(
+ stableProps.container ?? defaultConnectionContext?.table ?? ""
+ );
const [duration, setDuration] = useState<number>(4);
const [customExpireTime, setCustomExpireTime] = useState<string | undefined>(
undefined
@@ -257,6 +269,8 @@ function AccessGrantRequestDrawerInner({
export: exportResult,
reason,
expiration,
+ schema,
+ container,
});
const response = await accessGrantServiceClientConnect.createAccessGrant(
@@ -455,6 +469,8 @@ export function AccessGrantRequestDrawer({
query,
unmask,
export: exportResult,
+ schema,
+ container,
onClose,
}: Props) {
const propsRef = useRef({
@@ -462,6 +478,8 @@ export function AccessGrantRequestDrawer({
query,
unmask,
export: exportResult,
+ schema,
+ container,
onClose,
});
// Freeze props while drawer is open so inner form stays stable during close animation
@@ -499,7 +517,7 @@ export function AccessGrantRequestDrawer({
onPointerDown={stopDrawerEvent}
>
<AccessGrantRequestDrawerInner
- key={`${targets?.join(",")}-${query}-${unmask}-${exportResult}`}
+ key={`${targets?.join(",")}-${query}-${unmask}-${exportResult}-${schema}-${container}`}
stableProps={stableProps}
onClose={onClose}
/>
diff --git a/frontend/src/modules/sql-editor/components/AccessPane.test.tsx b/frontend/src/modules/sql-editor/components/AccessPane.test.tsx
index 49a410f512..7fcbd3f4f4 100644
--- a/frontend/src/modules/sql-editor/components/AccessPane.test.tsx
+++ b/frontend/src/modules/sql-editor/components/AccessPane.test.tsx
@@ -204,6 +204,8 @@ type GrantLike = {
name: string;
query: string;
targets: string[];
+ schema?: string;
+ container?: string;
unmask: boolean;
issue: string;
status: number;
@@ -451,4 +453,43 @@ describe("AccessPane", () => {
);
unmount();
});
+
+ test("click Run on a grant preserves schema and CosmosDB container", async () => {
+ const grant = {
+ ...makeGrant("grant1"),
+ schema: "APP",
+ container: "orders",
+ };
+ mocks.searchMyAccessGrants.mockResolvedValue({
+ accessGrants: [grant],
+ nextPageToken: "",
+ });
+
+ const { container, render, unmount } = renderIntoContainer(<AccessPane />);
+ render();
+
+ await act(async () => {
+ await new Promise((r) => setTimeout(r, 0));
+ });
+
+ const runBtn = container.querySelector(
+ "[data-run-btn]"
+ ) as HTMLButtonElement;
+ expect(runBtn).not.toBeNull();
+
+ await act(async () => {
+ runBtn.click();
+ });
+
+ expect(mocks.sqlEditorEventsEmit).toHaveBeenCalledWith(
+ "execute-sql",
+ expect.objectContaining({
+ connection: expect.objectContaining({
+ schema: "APP",
+ table: "orders",
+ }),
+ })
+ );
+ unmount();
+ });
});
diff --git a/frontend/src/modules/sql-editor/components/AccessPane.tsx b/frontend/src/modules/sql-editor/components/AccessPane.tsx
index 6ec5a74ab1..1d0127ea59 100644
--- a/frontend/src/modules/sql-editor/components/AccessPane.tsx
+++ b/frontend/src/modules/sql-editor/components/AccessPane.tsx
@@ -311,7 +311,12 @@ export function AccessPane() {
const instanceName = database.replace(/\/databases\/.*$/, "");
await getOrFetchDatabaseByName(database);
await sqlEditorEvents.emit("execute-sql", {
- connection: { instance: instanceName, database },
+ connection: {
+ instance: instanceName,
+ database,
+ schema: grant.schema || undefined,
+ table: grant.container || undefined,
+ },
statement: grant.query,
batchQueryContext: { databases: grant.targets },
});
@@ -401,6 +406,8 @@ export function AccessPane() {
query={pendingCreate?.query}
unmask={pendingCreate?.unmask}
export={pendingCreate?.export}
+ schema={pendingCreate?.schema}
+ container={pendingCreate?.container}
targets={pendingCreate?.targets}
onClose={handleDrawerClose}
/>
diff --git a/frontend/src/modules/sql-editor/components/ResultView/ResultStatusBar.test.tsx b/frontend/src/modules/sql-editor/components/ResultView/ResultStatusBar.test.tsx
index 207c9b7770..c8451de49f 100644
--- a/frontend/src/modules/sql-editor/components/ResultView/ResultStatusBar.test.tsx
+++ b/frontend/src/modules/sql-editor/components/ResultView/ResultStatusBar.test.tsx
@@ -1,9 +1,8 @@
import { render, screen } from "@testing-library/react";
import { act } from "react";
import { beforeEach, describe, expect, test, vi } from "vitest";
-import { Engine } from "@/types/proto-es/v1/common_pb";
import type { Database } from "@/types/proto-es/v1/database_service_pb";
-import { ResultStatusBar, RichDatabaseName } from "./ResultStatusBar";
+import { ResultStatusBar } from "./ResultStatusBar";
vi.mock("react-i18next", () => ({
initReactI18next: {
@@ -13,8 +12,20 @@ vi.mock("react-i18next", () => ({
useTranslation: () => ({ t: (key: string) => key }),
}));
-vi.mock("@/components/EngineIcon", () => ({
- EngineIcon: () => <span data-testid="engine-icon" />,
+vi.mock("@/components/DatabaseTargetDisplay", () => ({
+ DatabaseTargetDisplay: ({
+ database,
+ showEnvironment,
+ }: {
+ database: Database;
+ showEnvironment?: boolean;
+ }) => (
+ <span
+ data-testid="database-target-display"
+ data-database={database.name}
+ data-show-environment={String(showEnvironment)}
+ />
+ ),
}));
vi.mock("@/components/ui/tooltip", () => ({
@@ -29,25 +40,6 @@ vi.mock("@/stores/app", () => ({
},
}));
-vi.mock("@/utils/v1/database", () => ({
- extractDatabaseResourceName: () => ({
- instance: "instances/prod",
- database: "instances/prod/databases/very-long-database-name",
- instanceName: "prod",
- databaseName: "very-long-database-name",
- }),
- getDatabaseEnvironment: () => ({ title: "Prod" }),
- getInstanceResource: () => ({
- name: "instances/prod",
- title: "bytebase-3.17.11-selfhost",
- engine: Engine.POSTGRES,
- }),
-}));
-
-vi.mock("@/utils/v1/instance", () => ({
- instanceV1Name: () => "bytebase-3.17.11-selfhost",
-}));
-
const database = {
name: "instances/prod/databases/very-long-database-name",
project: "projects/prod",
@@ -109,11 +101,18 @@ describe("ResultStatusBar", () => {
expect(statement.textContent).toContain("SELECT db.environment");
});
- test("does not cap rich database names outside the status bar", () => {
- render(<RichDatabaseName database={database} />);
+ test("renders the database with the unified display", () => {
+ render(
+ <ResultStatusBar
+ database={database}
+ statement="SELECT 1"
+ queryTime="3 ms"
+ />
+ );
- const databaseLabel = screen.getByTestId("result-status-database");
- expect(databaseLabel.className).not.toContain("max-w-[45%]");
+ const databaseTarget = screen.getByTestId("database-target-display");
+ expect(databaseTarget.getAttribute("data-database")).toBe(database.name);
+ expect(databaseTarget.getAttribute("data-show-environment")).toBe("true");
});
test("lets the statement use available space while keeping copy attached", () => {
@@ -135,6 +134,16 @@ describe("ResultStatusBar", () => {
expect(copyButton.className).toContain("shrink-0");
});
+ test("hides the statement copy button when the statement is empty", () => {
+ render(
+ <ResultStatusBar database={database} statement="" queryTime="3 ms" />
+ );
+
+ expect(
+ screen.queryByRole("button", { name: "common.copy" })
+ ).not.toBeInTheDocument();
+ });
+
test("hides the database label when it would constrain the statement", () => {
render(
<ResultStatusBar
diff --git a/frontend/src/modules/sql-editor/components/ResultView/ResultStatusBar.tsx b/frontend/src/modules/sql-editor/components/ResultView/ResultStatusBar.tsx
index b1231d0f60..2e4e3cb9e4 100644
--- a/frontend/src/modules/sql-editor/components/ResultView/ResultStatusBar.tsx
+++ b/frontend/src/modules/sql-editor/components/ResultView/ResultStatusBar.tsx
@@ -1,18 +1,11 @@
-import { ChevronRightIcon } from "lucide-react";
-import { type Ref, useLayoutEffect, useRef, useState } from "react";
+import { useLayoutEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
-import { EngineIcon } from "@/components/EngineIcon";
+import { DatabaseTargetDisplay } from "@/components/DatabaseTargetDisplay";
import { Button } from "@/components/ui/button";
import { CopyButton } from "@/components/ui/copy-button";
import { EllipsisText } from "@/components/ui/ellipsis-text";
import { cn } from "@/lib/utils";
import type { Database } from "@/types/proto-es/v1/database_service_pb";
-import {
- extractDatabaseResourceName,
- getDatabaseEnvironment,
- getInstanceResource,
-} from "@/utils/v1/database";
-import { instanceV1Name } from "@/utils/v1/instance";
type ResultStatusBarProps = Readonly<{
database: Database;
@@ -30,6 +23,7 @@ export function ResultStatusBar({
onVisualizeExplain,
}: ResultStatusBarProps) {
const { t } = useTranslation();
+ const hasStatement = statement.trim() !== "";
const statusLeftRef = useRef<HTMLDivElement>(null);
const databaseRef = useRef<HTMLDivElement>(null);
const statementRef = useRef<HTMLDivElement>(null);
@@ -76,12 +70,20 @@ export function ResultStatusBar({
className="flex min-w-0 flex-1 items-center gap-x-2 overflow-hidden"
data-testid="result-status-left"
>
- <RichDatabaseName
+ <div
ref={databaseRef}
- database={database}
- hidden={hideDatabase}
- className="max-w-[45%] shrink"
- />
+ className={cn(
+ "min-w-0 max-w-[45%] shrink overflow-hidden whitespace-nowrap",
+ hideDatabase && "hidden"
+ )}
+ data-testid="result-status-database"
+ >
+ <DatabaseTargetDisplay
+ database={database}
+ showEnvironment
+ className="max-w-full"
+ />
+ </div>
<div
ref={statementRef}
className="flex min-w-0 flex-1 items-center gap-x-1"
@@ -91,12 +93,14 @@ export function ResultStatusBar({
text={statement}
className="min-w-0 max-w-full truncate"
/>
- <CopyButton
- content={statement}
- size="xs"
- appearance="secondary"
- className="h-auto shrink-0 px-0 text-control-light hover:bg-transparent hover:text-control"
- />
+ {hasStatement && (
+ <CopyButton
+ content={statement}
+ size="xs"
+ appearance="secondary"
+ className="h-auto shrink-0 px-0 text-control-light hover:bg-transparent hover:text-control"
+ />
+ )}
</div>
</div>
<div className="flex shrink-0 items-center gap-x-2">
@@ -117,44 +121,3 @@ export function ResultStatusBar({
</div>
);
}
-
-/**
- * Inline simplified renderer mirroring the visible output of Vue
- * `RichDatabaseName` with default props: engine icon + instance title +
- * chevron + environment + database. Skips the popover-on-hover branch
- * (only used by `tooltip="instance"` callers; result-view doesn't set it).
- */
-export function RichDatabaseName({
- ref,
- database,
- hidden = false,
- className,
-}: Readonly<{
- ref?: Ref<HTMLDivElement>;
- database: Database;
- hidden?: boolean;
- className?: string;
-}>) {
- const instance = getInstanceResource(database);
- const environment = getDatabaseEnvironment(database);
- const { databaseName } = extractDatabaseResourceName(database.name);
- return (
- <div
- ref={ref}
- className={cn(
- "flex min-w-0 items-center gap-x-1 overflow-hidden whitespace-nowrap",
- className,
- hidden && "hidden"
- )}
- data-testid="result-status-database"
- >
- <EngineIcon engine={instance.engine} className="size-4 shrink-0" />
- <span className="truncate">{instanceV1Name(instance)}</span>
- <ChevronRightIcon className="size-3 shrink-0" />
- <span className="flex min-w-0 items-center gap-x-1 overflow-hidden">
- <span className="truncate text-control-light">{environment.title}</span>
- <span className="truncate">{databaseName}</span>
- </span>
- </div>
- );
-}
diff --git a/frontend/src/modules/sql-editor/components/ResultView/SingleResultView.tsx b/frontend/src/modules/sql-editor/components/ResultView/SingleResultView.tsx
index 429e903a7e..36dc2f74f5 100644
--- a/frontend/src/modules/sql-editor/components/ResultView/SingleResultView.tsx
+++ b/frontend/src/modules/sql-editor/components/ResultView/SingleResultView.tsx
@@ -23,6 +23,7 @@ import {
type ScopeOption,
type SearchParams,
} from "@/components/AdvancedSearch";
+import { DatabaseTargetDisplay } from "@/components/DatabaseTargetDisplay";
import {
DataExportButton,
type DataExportRequest,
@@ -69,7 +70,7 @@ import { formatAsCSV, formatAsSQL, formatAsText } from "./copy-formats";
import { DetailPanel } from "./DetailPanel";
import { EmptyView } from "./EmptyView";
import { ErrorView } from "./ErrorView";
-import { ResultStatusBar, RichDatabaseName } from "./ResultStatusBar";
+import { ResultStatusBar } from "./ResultStatusBar";
import { SelectionCopyTooltips } from "./SelectionCopyTooltips";
import type { ResultTableColumn, ResultTableRow, SortState } from "./types";
import {
@@ -800,16 +801,12 @@ function useLocalStorageBoolean(
return [value, update];
}
-/**
- * Inline simplified `DatabaseInfo` for the export drawer's form-prefix slot.
- * Vue version showed `[engine] instance > [env] database`; we mirror that.
- */
function DatabaseInfo({ database }: { database: Database }) {
const { t } = useTranslation();
return (
<div className="flex flex-col gap-1 mb-3">
<span className="text-xs text-control-light">{t("common.database")}</span>
- <RichDatabaseName database={database} />
+ <DatabaseTargetDisplay database={database} showEnvironment />
</div>
);
}
diff --git a/frontend/src/routes/project/issue-detail/components/IssueDetailAccessGrantDetails.test.tsx b/frontend/src/routes/project/issue-detail/components/IssueDetailAccessGrantDetails.test.tsx
new file mode 100644
index 0000000000..6a43dc849d
--- /dev/null
+++ b/frontend/src/routes/project/issue-detail/components/IssueDetailAccessGrantDetails.test.tsx
@@ -0,0 +1,103 @@
+import { render, screen } from "@testing-library/react";
+import { beforeEach, describe, expect, test, vi } from "vitest";
+import { IssueDetailAccessGrantDetails } from "./IssueDetailAccessGrantDetails";
+
+const mocks = vi.hoisted(() => ({
+ accessGrant: undefined as
+ | {
+ name: string;
+ targets: string[];
+ query: string;
+ unmask: boolean;
+ export: boolean;
+ schema: string;
+ container: string;
+ }
+ | undefined,
+ issue: {
+ name: "projects/proj/issues/123",
+ accessGrant: "projects/proj/accessGrants/ag1",
+ },
+ project: { name: "projects/proj" },
+ fetchAccessGrant: vi.fn(),
+ searchMyAccessGrants: vi.fn(),
+ getOrFetchDatabaseByName: vi.fn(),
+}));
+
+vi.mock("react-i18next", () => ({
+ useTranslation: () => ({
+ t: (key: string) => key,
+ }),
+}));
+
+vi.mock("@/components/DatabaseTargetDisplay", () => ({
+ DatabaseTargetDisplay: ({ target }: { target: string }) => (
+ <span>{target}</span>
+ ),
+}));
+
+vi.mock("@/hooks/useProjectByName", () => ({
+ useProjectByName: () => mocks.project,
+}));
+
+vi.mock("@/stores/app", () => {
+ const state = () => ({
+ projectsByName: {},
+ fetchAccessGrant: mocks.fetchAccessGrant,
+ searchMyAccessGrants: mocks.searchMyAccessGrants,
+ getOrFetchDatabaseByName: mocks.getOrFetchDatabaseByName,
+ });
+ return {
+ useAppStore: Object.assign(
+ (selector: (s: ReturnType<typeof state>) => unknown) => selector(state()),
+ { getState: state }
+ ),
+ };
+});
+
+vi.mock("@/stores/modules/v1/common", () => ({
+ projectNamePrefix: "projects/",
+}));
+
+vi.mock("@/types", () => ({
+ isValidDatabaseName: (name: string) => name.includes("/databases/"),
+}));
+
+vi.mock("@/utils", () => ({
+ extractProjectResourceName: () => "proj",
+ hasProjectPermissionV2: () => true,
+}));
+
+vi.mock("@/utils/accessGrant", () => ({
+ getAccessGrantExpirationText: () => ({ type: "never" }),
+}));
+
+vi.mock("../context/IssueDetailContext", () => ({
+ useIssueDetailContext: () => ({ issue: mocks.issue, projectId: "proj" }),
+}));
+
+beforeEach(() => {
+ vi.clearAllMocks();
+ mocks.accessGrant = {
+ name: "projects/proj/accessGrants/ag1",
+ targets: ["instances/inst/databases/db"],
+ query: "SELECT * FROM orders",
+ unmask: true,
+ export: true,
+ schema: "APP",
+ container: "orders",
+ };
+ mocks.fetchAccessGrant.mockImplementation(async () => mocks.accessGrant);
+ mocks.searchMyAccessGrants.mockResolvedValue({ accessGrants: [] });
+});
+
+describe("IssueDetailAccessGrantDetails", () => {
+ test("renders schema and CosmosDB container for approvers", async () => {
+ render(<IssueDetailAccessGrantDetails />);
+
+ expect(await screen.findByText("APP")).toBeInTheDocument();
+ expect(screen.getByText("orders")).toBeInTheDocument();
+ expect(screen.getByText("common.schema")).toBeInTheDocument();
+ expect(screen.getByText("issue.access-grant.container")).toBeInTheDocument();
+ });
+});
diff --git a/frontend/src/routes/project/issue-detail/components/IssueDetailAccessGrantDetails.tsx b/frontend/src/routes/project/issue-detail/components/IssueDetailAccessGrantDetails.tsx
index cdd9cc6b19..dda5a616b0 100644
--- a/frontend/src/routes/project/issue-detail/components/IssueDetailAccessGrantDetails.tsx
+++ b/frontend/src/routes/project/issue-detail/components/IssueDetailAccessGrantDetails.tsx
@@ -105,6 +105,32 @@ export function IssueDetailAccessGrantDetails() {
</div>
)}
+ {(accessGrant.schema || accessGrant.container) && (
+ <div className="flex flex-col gap-y-2">
+ <span className="text-sm text-control-light">
+ {t("common.scope")}
+ </span>
+ <div className="flex flex-col gap-y-1 text-sm">
+ {accessGrant.schema && (
+ <div className="flex gap-x-2">
+ <span className="text-control-light">
+ {t("common.schema")}
+ </span>
+ <span className="font-medium">{accessGrant.schema}</span>
+ </div>
+ )}
+ {accessGrant.container && (
+ <div className="flex gap-x-2">
+ <span className="text-control-light">
+ {t("issue.access-grant.container")}
+ </span>
+ <span className="font-medium">{accessGrant.container}</span>
+ </div>
+ )}
+ </div>
+ </div>
+ )}
+
{accessGrant.query && (
<div className="flex flex-col gap-y-2">
<span className="text-sm text-control-light">
diff --git a/frontend/src/types/proto-es/v1/access_grant_service_pb.d.ts b/frontend/src/types/proto-es/v1/access_grant_service_pb.d.ts
index 1e63cc80d3..ea128bc216 100644
--- a/frontend/src/types/proto-es/v1/access_grant_service_pb.d.ts
+++ b/frontend/src/types/proto-es/v1/access_grant_service_pb.d.ts
@@ -120,6 +120,20 @@ export declare type AccessGrant = Message<"bytebase.v1.AccessGrant"> & {
* @generated from field: bool export = 13;
*/
export: boolean;
+
+ /**
+ * The default schema to execute the query.
+ *
+ * @generated from field: string schema = 14;
+ */
+ schema: string;
+
+ /**
+ * The container name to execute the query against, used for CosmosDB only.
+ *
+ * @generated from field: string container = 15;
+ */
+ container: string;
};
/**
diff --git a/frontend/src/types/proto-es/v1/access_grant_service_pb.js b/frontend/src/types/proto-es/v1/access_grant_service_pb.js
index 755126b1bc..00d701415c 100644
--- a/frontend/src/types/proto-es/v1/access_grant_service_pb.js
+++ b/frontend/src/types/proto-es/v1/access_grant_service_pb.js
@@ -14,7 +14,7 @@ import { file_v1_annotation } from "./annotation_pb";
* Describes the file v1/access_grant_service.proto.
*/
export const file_v1_access_grant_service = /*@__PURE__*/
- fileDesc("Ch12MS9hY2Nlc3NfZ3JhbnRfc2VydmljZS5wcm90bxILYnl0ZWJhc2UudjEi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ABChRTZWFyY2hNeUFjY2Vzc0dyYW50cxIoLmJ5dGViYXNlLnYxLlNlYXJjaE15QWNjZXNzR3JhbnRzUmVxdWVzdBopLmJ5dGViYXNlLnYxLlNlYXJjaE15QWNjZXNzR3JhbnRzUmVzcG9uc2UiU4rqMBNiYi5hY2Nlc3NHcmFudHMuZ2V0kOowAoLT5JMCMjoBKiItL3YxL3twYXJlbnQ9cHJvamVjdHMvKn0vYWNjZXNzR3JhbnRzOnNlYXJjaE15Qq0BCg9jb20uYnl0ZWJhc2UudjFCF0FjY2Vzc0dyYW50U2VydmljZVByb3RvUAFaNGdpdGh1Yi5jb20vYnl0ZWJhc2UvYnl0ZWJhc2UvYmFja2VuZC9nZW5lcmF0ZWQtZ28vdjGiAgNCWFiqAgtCeXRlYmFzZS5WMcoCC0J5dGViYXNlXFYx4gIXQnl0ZWJhc2VcVjFcR1BCTWV0YWRhdGHqAgxCeXRlYmFzZTo6VjFiBnByb3RvMw", [file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_duration, file_google_protobuf_timestamp, file_v1_annotation]);
+ fileDesc("Ch12MS9hY2Nlc3NfZ3JhbnRfc2VydmljZS5wcm90bxILYnl0ZWJhc2UudjEi5gQKC0FjY2Vzc0dyYW50EgwKBG5hbWUYASABKAkSFAoHY3JlYXRvchgCIAEoCUID4EECEjQKBnN0YXR1cxgDIAEoDjIfLmJ5dGViYXNlLnYxLkFjY2Vzc0dyYW50LlN0YXR1c0ID4EEDEjEKC2V4cGlyZV90aW1lGAQgASgLMhouZ29vZ2xlLnByb3RvYnVmLlRpbWVzdGFtcEgAEi0KA3R0bBgLIAEoCzIZLmdvb2dsZS5wcm90b2J1Zi5EdXJhdGlvbkID4EEESAASEgoFaXNzdWUYBSABKAlCA+BBAxIUCgd0YXJnZXRzGAYgAygJQgPgQQISDQoFcXVlcnkYByABKAkSDgoGdW5tYXNrGAggASgIEjQKC2NyZWF0ZV90aW1lGAkgASgLMhouZ29vZ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YmFzZS9ieXRlYmFzZS9iYWNrZW5kL2dlbmVyYXRlZC1nby92MaICA0JYWKoCC0J5dGViYXNlLlYxygILQnl0ZWJhc2VcVjHiAhdCeXRlYmFzZVxWMVxHUEJNZXRhZGF0YeoCDEJ5dGViYXNlOjpWMWIGcHJvdG8z", [file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_duration, file_google_protobuf_timestamp, file_v1_annotation]);
/**
* Describes the message bytebase.v1.AccessGrant.
diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yaml
index 815ca2f8f7..b337ded76a 100644
--- a/proto/gen/grpc-doc/openapi.yaml
+++ b/proto/gen/grpc-doc/openapi.yaml
@@ -18935,6 +18935,14 @@ components:
type: boolean
title: export
description: Whether export the query result.
+ schema:
+ type: string
+ title: schema
+ description: The default schema to execute the query.
+ container:
+ type: string
+ title: container
+ description: The container name to execute the query against, used for CosmosDB only.
- oneOf:
- type: object
properties:
diff --git a/proto/gen/grpc-doc/store/README.md b/proto/gen/grpc-doc/store/README.md
index b8569bda46..6ba2be9ddf 100644
--- a/proto/gen/grpc-doc/store/README.md
+++ b/proto/gen/grpc-doc/store/README.md
@@ -396,6 +396,8 @@
| reason | [string](#string) | | |
| requested_duration | [google.protobuf.Duration](#google-protobuf-Duration) | | The requested duration for the access grant. Stored when the user provides a TTL instead of an absolute expire_time. The server computes expire_time from this value at activation time. |
| export | [bool](#bool) | | Whether export the query result. |
+| schema | [string](#string) | | The default schema to execute the query. |
+| container | [string](#string) | | The container name to execute the query against, used for CosmosDB only. |
diff --git a/proto/gen/grpc-doc/store/index.html b/proto/gen/grpc-doc/store/index.html
index e7571a1585..2d80ff76aa 100644
--- a/proto/gen/grpc-doc/store/index.html
+++ b/proto/gen/grpc-doc/store/index.html
@@ -1703,6 +1703,20 @@ The server computes expire_time from this value at activation time. </p></td>
<td><p>Whether export the query result. </p></td>
</tr>
+ <tr>
+ <td>schema</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p>The default schema to execute the query. </p></td>
+ </tr>
+
+ <tr>
+ <td>container</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p>The container name to execute the query against, used for CosmosDB only. </p></td>
+ </tr>
+
</tbody>
</table>
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index bd297b5525..abb6da1ddb 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -847,6 +847,8 @@ Authorization method for RPC calls.
| update_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | |
| reason | [string](#string) | | |
| export | [bool](#bool) | | Whether export the query result. |
+| schema | [string](#string) | | The default schema to execute the query. |
+| container | [string](#string) | | The container name to execute the query against, used for CosmosDB only. |
diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.html
index dc1563d11a..4d81453641 100644
--- a/proto/gen/grpc-doc/v1/index.html
+++ b/proto/gen/grpc-doc/v1/index.html
@@ -3333,6 +3333,20 @@ Format: instances/{instance}/databases/{database} </p></td>
<td><p>Whether export the query result. </p></td>
</tr>
+ <tr>
+ <td>schema</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p>The default schema to execute the query. </p></td>
+ </tr>
+
+ <tr>
+ <td>container</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p>The container name to execute the query against, used for CosmosDB only. </p></td>
+ </tr>
+
</tbody>
</table>
diff --git a/proto/store/store/access_grant.proto b/proto/store/store/access_grant.proto
index 019df79a95..7f9aebe7c8 100644
--- a/proto/store/store/access_grant.proto
+++ b/proto/store/store/access_grant.proto
@@ -38,4 +38,10 @@ message AccessGrantPayload {
// Whether export the query result.
bool export = 7;
+
+ // The default schema to execute the query.
+ string schema = 8;
+
+ // The container name to execute the query against, used for CosmosDB only.
+ string container = 9;
}
diff --git a/proto/v1/v1/access_grant_service.proto b/proto/v1/v1/access_grant_service.proto
index 46fcb70ef7..399e929adc 100644
--- a/proto/v1/v1/access_grant_service.proto
+++ b/proto/v1/v1/access_grant_service.proto
@@ -145,6 +145,12 @@ message AccessGrant {
// Whether export the query result.
bool export = 13;
+
+ // The default schema to execute the query.
+ string schema = 14;
+
+ // The container name to execute the query against, used for CosmosDB only.
+ string container = 15;
}
message GetAccessGrantRequest {