Skip to content

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

fix(frontend): restore Request Role button, polish SQL review dialogs, fix agent window layout (#19958)

Danny Xu1af76e26b294
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 3e251a77db..facffb88fa 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -2724,8 +2724,11 @@
}
},
"delete": "Delete SQL review policy",
+ "delete-description": "The SQL review policy and all its rules will be permanently removed. This cannot be undone.",
"description": "Define SQL lint rules to enforce best practices and schema consistency. Rules apply to DDL/DML changes only, not to SQL Editor queries.",
+ "disable-description": "Disabling this policy will stop enforcing its rules on the attached resources. You can re-enable it later.",
"disabled": "SQL review is disabled",
+ "enable-description": "Enabling this policy will start enforcing its rules on the attached resources.",
"enabled-rules": "Enabled rules",
"input-then-press-enter": "Input the value then press enter to add",
"level": {
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index e6895a81c5..9b492c9f90 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -2724,8 +2724,11 @@
}
},
"delete": "Eliminar política de revisión SQL",
+ "delete-description": "La política de revisión SQL y todas sus reglas se eliminarán permanentemente. Esta acción no se puede deshacer.",
"description": "Define reglas de lint SQL para aplicar buenas prácticas y consistencia de esquema. Las reglas se aplican solo a cambios DDL/DML, no a consultas en SQL Editor.",
+ "disable-description": "Deshabilitar esta política dejará de aplicar sus reglas a los recursos adjuntos. Puede volver a habilitarla más tarde.",
"disabled": "La revisión de SQL está deshabilitada",
+ "enable-description": "Habilitar esta política comenzará a aplicar sus reglas a los recursos adjuntos.",
"enabled-rules": "Reglas habilitadas",
"input-then-press-enter": "Ingrese el valor y luego presione enter para agregar",
"level": {
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 745ed24207..f9a0e23ac0 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -2724,8 +2724,11 @@
}
},
"delete": "SQL レビューポリシーの削除",
+ "delete-description": "SQL レビューポリシーとそのすべてのルールは完全に削除されます。この操作は元に戻せません。",
"description": "SQL lint ルールを定義し、ベストプラクティスとスキーマの一貫性を適用します。ルールは DDL/DML 変更にのみ適用され、SQL エディターのクエリには適用されません。",
+ "disable-description": "このポリシーを無効にすると、関連付けられたリソースへのルール適用が停止されます。後で再度有効にすることができます。",
"disabled": "SQL レビューポリシーが無効になっています",
+ "enable-description": "このポリシーを有効にすると、関連付けられたリソースへのルール適用が開始されます。",
"enabled-rules": "開かれたルールの数",
"input-then-press-enter": "入力後、Enterを押して追加します",
"level": {
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 4e52465988..ffe9e280b2 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -2724,8 +2724,11 @@
}
},
"delete": "Xóa chính sách đánh giá SQL",
+ "delete-description": "Chính sách đánh giá SQL và tất cả các quy tắc của nó sẽ bị xóa vĩnh viễn. Không thể hoàn tác hành động này.",
"description": "Định nghĩa các quy tắc lint SQL để áp dụng các phương pháp tốt nhất và tính nhất quán của lược đồ. Các quy tắc chỉ áp dụng cho các thay đổi DDL/DML, không áp dụng cho truy vấn trong SQL Editor.",
+ "disable-description": "Tắt chính sách này sẽ ngừng áp dụng các quy tắc của nó trên các tài nguyên đã đính kèm. Bạn có thể bật lại sau.",
"disabled": "Đánh giá SQL bị vô hiệu hóa",
+ "enable-description": "Bật chính sách này sẽ bắt đầu áp dụng các quy tắc của nó trên các tài nguyên đã đính kèm.",
"enabled-rules": "Quy tắc được bật",
"input-then-press-enter": "Nhập giá trị sau đó nhấn enter để thêm",
"level": {
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 450ae3519c..23268b18ff 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -2724,8 +2724,11 @@
}
},
"delete": "删除审核策略",
+ "delete-description": "SQL 审核策略及其所有规则将被永久删除,此操作无法撤销。",
"description": "定义 SQL lint 规则以实施最佳实践和 schema 一致性。规则仅适用于 DDL/DML 变更,不适用于 SQL 编辑器中的查询。",
+ "disable-description": "禁用此策略将停止对已关联资源应用规则。您可以稍后重新启用。",
"disabled": "SQL 审核策略已禁用",
+ "enable-description": "启用此策略将开始对已关联资源应用规则。",
"enabled-rules": "开启的规则数",
"input-then-press-enter": "输入后按下回车来添加",
"level": {
diff --git a/frontend/src/react/components/IssueLabelSelect.tsx b/frontend/src/react/components/IssueLabelSelect.tsx
new file mode 100644
index 0000000000..e4e04e4d7f
--- /dev/null
+++ b/frontend/src/react/components/IssueLabelSelect.tsx
@@ -0,0 +1,137 @@
+import { ChevronDown, X } from "lucide-react";
+import { useCallback, useRef, useState } from "react";
+import { useTranslation } from "react-i18next";
+import { useClickOutside } from "@/react/hooks/useClickOutside";
+import { cn } from "@/react/lib/utils";
+
+export interface IssueLabel {
+ value: string;
+ color: string;
+}
+
+interface IssueLabelSelectProps {
+ labels: IssueLabel[];
+ selected: string[];
+ required: boolean;
+ onChange: (labels: string[]) => void;
+}
+
+/**
+ * IssueLabelSelect — label multi-select for issue creation.
+ *
+ * Rendered as a dropdown with chip-style selected labels. Shared between
+ * drawers that need to attach labels to a new issue (e.g. Data Export,
+ * Request Role).
+ */
+export function IssueLabelSelect({
+ labels,
+ selected,
+ required,
+ onChange,
+}: IssueLabelSelectProps) {
+ const { t } = useTranslation();
+ const [open, setOpen] = useState(false);
+ const containerRef = useRef<HTMLDivElement>(null);
+ const closeDropdown = useCallback(() => setOpen(false), []);
+ useClickOutside(containerRef, open, closeDropdown);
+
+ const toggleLabel = (value: string) => {
+ onChange(
+ selected.includes(value)
+ ? selected.filter((l) => l !== value)
+ : [...selected, value]
+ );
+ };
+
+ return (
+ <div className="flex flex-col gap-y-2">
+ <label className="text-sm font-medium text-control">
+ {t("issue.labels")}
+ {required && <span className="text-error"> *</span>}
+ </label>
+ <div ref={containerRef} className="relative">
+ <button
+ type="button"
+ className={cn(
+ "w-full flex items-center justify-between gap-2 border border-control-border rounded-sm h-9 px-3 text-sm bg-background text-left transition-colors",
+ "hover:border-control-border",
+ open && "border-accent shadow-[0_0_0_1px_var(--color-accent)]"
+ )}
+ onClick={() => setOpen(!open)}
+ >
+ {selected.length > 0 ? (
+ <div className="flex items-center gap-1.5 truncate">
+ {selected.map((val) => {
+ const label = labels.find((l) => l.value === val);
+ return (
+ <span
+ key={val}
+ className="inline-flex items-center gap-1 px-1.5 py-0.5 rounded-xs bg-control-bg text-xs"
+ >
+ <span
+ className="size-2.5 rounded-sm shrink-0"
+ style={{ backgroundColor: label?.color }}
+ />
+ {val}
+ <X
+ className="size-3 text-control-placeholder hover:text-control-light"
+ onClick={(e) => {
+ e.stopPropagation();
+ toggleLabel(val);
+ }}
+ />
+ </span>
+ );
+ })}
+ </div>
+ ) : (
+ <span className="text-control-placeholder">
+ {t("common.select")}
+ </span>
+ )}
+ <ChevronDown
+ className={cn(
+ "size-4 text-control-placeholder shrink-0 transition-transform",
+ open && "rotate-180"
+ )}
+ />
+ </button>
+ {open && (
+ <div className="absolute z-50 mt-1 w-full bg-background border border-block-border rounded-sm shadow-lg overflow-hidden">
+ <div className="max-h-60 overflow-y-auto">
+ {labels.length === 0 ? (
+ <div className="px-3 py-6 text-sm text-control-placeholder text-center">
+ {t("common.no-data")}
+ </div>
+ ) : (
+ labels.map((label) => {
+ const isSelected = selected.includes(label.value);
+ return (
+ <button
+ key={label.value}
+ type="button"
+ className="w-full text-left px-3 py-2 text-sm flex items-center gap-2 hover:bg-control-bg transition-colors"
+ onClick={() => toggleLabel(label.value)}
+ >
+ <input
+ type="checkbox"
+ checked={isSelected}
+ readOnly
+ className="rounded-xs border-control-border accent-accent"
+ />
+ <span
+ className="size-4 rounded-sm shrink-0"
+ style={{ backgroundColor: label.color }}
+ />
+ <span>{label.value}</span>
+ </button>
+ );
+ })
+ )}
+ </div>
+ </div>
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/frontend/src/react/components/ui/expiration-picker.tsx b/frontend/src/react/components/ui/expiration-picker.tsx
index 9954e6eccf..d2d2c25c47 100644
--- a/frontend/src/react/components/ui/expiration-picker.tsx
+++ b/frontend/src/react/components/ui/expiration-picker.tsx
@@ -12,10 +12,12 @@ export function ExpirationPicker({
value,
onChange,
minDate,
+ maxDate,
}: {
value: string | undefined;
onChange: (value: string | undefined) => void;
minDate?: string;
+ maxDate?: string;
}) {
const { t } = useTranslation();
@@ -26,6 +28,7 @@ export function ExpirationPicker({
className="w-64"
value={value ?? ""}
min={minDate}
+ max={maxDate}
onChange={(e) => onChange(e.target.value || undefined)}
/>
{value && (
diff --git a/frontend/src/react/locales/en-US.json b/frontend/src/react/locales/en-US.json
index 4bf4db0692..a07dbcd17e 100644
--- a/frontend/src/react/locales/en-US.json
+++ b/frontend/src/react/locales/en-US.json
@@ -281,6 +281,7 @@
"state": "State",
"statement": "Statement",
"status": "Status",
+ "submit": "Submit",
"system": "System",
"table": "Table",
"title": "Title",
@@ -1109,6 +1110,10 @@
"updated": "Updated",
"waiting-role": "Waiting: {{role}}"
},
+ "title": {
+ "request-role": "Request role",
+ "request-specific-role": "Request \"{{role}}\" role"
+ },
"upload-sql": "Upload SQL",
"waiting-approval": "Waiting for Approval"
},
@@ -1213,6 +1218,16 @@
"disallow-ddl-all-environments": "Disallow running DDL/DML statements for all environments.",
"edit-member": "Edit member - {{member}}",
"never-expires": "Never",
+ "request-role": {
+ "expiration-exceeds-max": "Expiration cannot exceed the workspace limit of {{days}} day(s).",
+ "expiration-must-be-future": "Expiration must be in the future.",
+ "failed-to-build-expression": "Failed to build CEL expression. Please try again.",
+ "labels-misconfigured": {
+ "description": "This project requires issue labels, but no labels have been configured. Please contact the project owner to add labels before requesting a role.",
+ "title": "Issue labels required but not configured"
+ },
+ "max-expiration-hint": "Maximum allowed by workspace policy: {{days}} day(s)."
+ },
"revoke-role-from-member": "Revoke '{{role}}' from '{{member}}'?"
},
"settings": {
@@ -1953,8 +1968,11 @@
}
},
"delete": "Delete SQL review policy",
+ "delete-description": "The SQL review policy and all its rules will be permanently removed. This cannot be undone.",
"description": "SQL review policy can define different set of SQL lint rules for the respective environments. It helps teams to adopt SQL best practice and enforce schema consistency across different databases. Whenever you attempt a DDL/DML change or use SQL Editor to query data, the query will be checked against the configured SQL review policy.",
+ "disable-description": "Disabling this policy will stop enforcing its rules on the attached resources. You can re-enable it later.",
"disabled": "SQL review is disabled",
+ "enable-description": "Enabling this policy will start enforcing its rules on the attached resources.",
"enabled-rules": "Enabled rules",
"engine": {
"mariadb": "MariaDB",
diff --git a/frontend/src/react/locales/es-ES.json b/frontend/src/react/locales/es-ES.json
index e0d68c229f..f5565e4869 100644
--- a/frontend/src/react/locales/es-ES.json
+++ b/frontend/src/react/locales/es-ES.json
@@ -281,6 +281,7 @@
"state": "Estado",
"statement": "Declaración",
"status": "Estado",
+ "submit": "Enviar",
"system": "Sistema",
"table": "Tabla",
"title": "Título",
@@ -1109,6 +1110,10 @@
"updated": "Actualizado",
"waiting-role": "Waiting: {{role}}"
},
+ "title": {
+ "request-role": "Solicitar rol",
+ "request-specific-role": "Solicitar rol \"{{role}}\""
+ },
"upload-sql": "Upload SQL",
"waiting-approval": "A la espera de la aprobación"
},
@@ -1213,6 +1218,16 @@
"disallow-ddl-all-environments": "No permitir ejecutar sentencias DDL/DML en ningún entorno.",
"edit-member": "Editar miembro - {{member}}",
"never-expires": "Never",
+ "request-role": {
+ "expiration-exceeds-max": "La expiración no puede exceder el límite del espacio de trabajo de {{days}} día(s).",
+ "expiration-must-be-future": "La expiración debe ser una fecha futura.",
+ "failed-to-build-expression": "Error al construir la expresión CEL. Inténtalo de nuevo.",
+ "labels-misconfigured": {
+ "description": "Este proyecto requiere etiquetas de incidencia, pero no se ha configurado ninguna etiqueta. Contacte con el propietario del proyecto para añadir etiquetas antes de solicitar un rol.",
+ "title": "Se requieren etiquetas de incidencia pero no están configuradas"
+ },
+ "max-expiration-hint": "Máximo permitido por la política del espacio de trabajo: {{days}} día(s)."
+ },
"revoke-role-from-member": "¿Revocar '{{role}}' de '{{member}}'?"
},
"settings": {
@@ -1953,8 +1968,11 @@
}
},
"delete": "Eliminar política de revisión SQL",
+ "delete-description": "La política de revisión SQL y todas sus reglas se eliminarán permanentemente. Esta acción no se puede deshacer.",
"description": "La política de revisión de SQL puede definir diferentes conjuntos de reglas de lint SQL para los entornos respectivos. Ayuda a los equipos a adoptar las mejores prácticas de SQL y a hacer cumplir la consistencia del esquema en diferentes bases de datos. Cada vez que intente realizar un cambio DDL/DML o use el Editor SQL para consultar datos, la consulta se verificará en función de la política de revisión de SQL configurada.",
+ "disable-description": "Deshabilitar esta política dejará de aplicar sus reglas a los recursos adjuntos. Puede volver a habilitarla más tarde.",
"disabled": "La revisión de SQL está deshabilitada",
+ "enable-description": "Habilitar esta política comenzará a aplicar sus reglas a los recursos adjuntos.",
"enabled-rules": "Reglas habilitadas",
"engine": {
"mariadb": "MariaDB",
diff --git a/frontend/src/react/locales/ja-JP.json b/frontend/src/react/locales/ja-JP.json
index afed78f939..b13f281571 100644
--- a/frontend/src/react/locales/ja-JP.json
+++ b/frontend/src/react/locales/ja-JP.json
@@ -281,6 +281,7 @@
"state": "ステート",
"statement": "ステートメント",
"status": "ステータス",
+ "submit": "送信",
"system": "システム",
"table": "テーブル",
"title": "タイトル",
@@ -1109,6 +1110,10 @@
"updated": "更新日時",
"waiting-role": "Waiting: {{role}}"
},
+ "title": {
+ "request-role": "ロールをリクエスト",
+ "request-specific-role": "「{{role}}」ロールをリクエスト"
+ },
"upload-sql": "Upload SQL",
"waiting-approval": "承認待ち"
},
@@ -1213,6 +1218,16 @@
"disallow-ddl-all-environments": "すべての環境で DDL/DML ステートメントの実行を禁止する。",
"edit-member": "メンバー編集 - {{member}}",
"never-expires": "Never",
+ "request-role": {
+ "expiration-exceeds-max": "有効期限はワークスペースの上限 {{days}} 日を超えることはできません。",
+ "expiration-must-be-future": "有効期限は将来の時刻を指定してください。",
+ "failed-to-build-expression": "CEL 式の構築に失敗しました。もう一度お試しください。",
+ "labels-misconfigured": {
+ "description": "このプロジェクトはイシューラベルを必須にしていますが、ラベルが設定されていません。ロールをリクエストする前に、プロジェクトのオーナーに連絡してラベルを追加してください。",
+ "title": "イシューラベルが必須ですが設定されていません"
+ },
+ "max-expiration-hint": "ワークスペースポリシーで許可される最大値:{{days}} 日。"
+ },
"revoke-role-from-member": "'{{member}}' から '{{role}}' を取り消しますか?"
},
"settings": {
@@ -1953,8 +1968,11 @@
}
},
"delete": "SQL レビューポリシーの削除",
+ "delete-description": "SQL レビューポリシーとそのすべてのルールは完全に削除されます。この操作は元に戻せません。",
"description": "SQL レビューポリシーは、さまざまな環境に対してさまざまな SQL lint ルールのセットを定義でき、チームが SQL のベスト プラクティスを採用し、さまざまなデータベースでスキーマの一貫性を制約するのに役立ちます。 DDL/DML を変更しようとしたり、SQL エディターを使用してデータをクエリしようとしたりすると、設定された SQL レビュールールによって対応する実行ステートメントがチェックされます。",
+ "disable-description": "このポリシーを無効にすると、関連付けられたリソースへのルール適用が停止されます。後で再度有効にすることができます。",
"disabled": "SQL レビューポリシーが無効になっています",
+ "enable-description": "このポリシーを有効にすると、関連付けられたリソースへのルール適用が開始されます。",
"enabled-rules": "開かれたルールの数",
"engine": {
"mariadb": "MariaDB",
diff --git a/frontend/src/react/locales/vi-VN.json b/frontend/src/react/locales/vi-VN.json
index 5873d1ec64..176de1dd11 100644
--- a/frontend/src/react/locales/vi-VN.json
+++ b/frontend/src/react/locales/vi-VN.json
@@ -281,6 +281,7 @@
"state": "Trạng thái",
"statement": "Câu lệnh",
"status": "Trạng thái",
+ "submit": "Gửi",
"system": "Hệ thống",
"table": "Bảng",
"title": "Tiêu đề",
@@ -1109,6 +1110,10 @@
"updated": "Đã cập nhật",
"waiting-role": "Waiting: {{role}}"
},
+ "title": {
+ "request-role": "Yêu cầu vai trò",
+ "request-specific-role": "Yêu cầu vai trò \"{{role}}\""
+ },
"upload-sql": "Upload SQL",
"waiting-approval": "Đang chờ phê duyệt"
},
@@ -1213,6 +1218,16 @@
"disallow-ddl-all-environments": "Không cho phép chạy câu lệnh DDL/DML cho tất cả các môi trường.",
"edit-member": "Chỉnh sửa thành viên - {{member}}",
"never-expires": "Never",
+ "request-role": {
+ "expiration-exceeds-max": "Thời gian hết hạn không được vượt quá giới hạn {{days}} ngày của không gian làm việc.",
+ "expiration-must-be-future": "Thời gian hết hạn phải ở tương lai.",
+ "failed-to-build-expression": "Không thể xây dựng biểu thức CEL. Vui lòng thử lại.",
+ "labels-misconfigured": {
+ "description": "Dự án này yêu cầu nhãn vấn đề, nhưng chưa có nhãn nào được cấu hình. Vui lòng liên hệ chủ sở hữu dự án để thêm nhãn trước khi yêu cầu vai trò.",
+ "title": "Dự án yêu cầu nhãn vấn đề nhưng chưa cấu hình"
+ },
+ "max-expiration-hint": "Tối đa được phép theo chính sách không gian làm việc: {{days}} ngày."
+ },
"revoke-role-from-member": "Thu hồi '{{role}}' từ '{{member}}'?"
},
"settings": {
@@ -1953,8 +1968,11 @@
}
},
"delete": "Xóa chính sách đánh giá SQL",
+ "delete-description": "Chính sách đánh giá SQL và tất cả các quy tắc của nó sẽ bị xóa vĩnh viễn. Không thể hoàn tác hành động này.",
"description": "Chính sách đánh giá SQL có thể xác định các bộ quy tắc lint SQL khác nhau cho các môi trường tương ứng. Nó giúp các nhóm áp dụng thực tiễn tốt nhất về SQL và thực thi tính nhất quán của lược đồ trên các cơ sở dữ liệu khác nhau. Bất cứ khi nào bạn cố gắng thay đổi DDL/DML hoặc sử dụng Trình soạn thảo SQL để truy vấn dữ liệu, truy vấn sẽ được kiểm tra theo chính sách đánh giá SQL đã định cấu hình.",
+ "disable-description": "Tắt chính sách này sẽ ngừng áp dụng các quy tắc của nó trên các tài nguyên đã đính kèm. Bạn có thể bật lại sau.",
"disabled": "Đánh giá SQL bị vô hiệu hóa",
+ "enable-description": "Bật chính sách này sẽ bắt đầu áp dụng các quy tắc của nó trên các tài nguyên đã đính kèm.",
"enabled-rules": "Quy tắc được bật",
"engine": {
"mariadb": "MariaDB",
diff --git a/frontend/src/react/locales/zh-CN.json b/frontend/src/react/locales/zh-CN.json
index e46c911794..10a3e32138 100644
--- a/frontend/src/react/locales/zh-CN.json
+++ b/frontend/src/react/locales/zh-CN.json
@@ -281,6 +281,7 @@
"state": "状态",
"statement": "语句",
"status": "状态",
+ "submit": "提交",
"system": "系统",
"table": "表",
"title": "标题",
@@ -1109,6 +1110,10 @@
"updated": "更新于",
"waiting-role": "等待: {{role}}"
},
+ "title": {
+ "request-role": "申请角色",
+ "request-specific-role": "申请 \"{{role}}\" 角色"
+ },
"upload-sql": "上传 SQL",
"waiting-approval": "等待审批"
},
@@ -1213,6 +1218,16 @@
"disallow-ddl-all-environments": "禁止在所有环境中执行 DDL/DML 语句。",
"edit-member": "编辑成员 - {{member}}",
"never-expires": "Never",
+ "request-role": {
+ "expiration-exceeds-max": "过期时间不能超过工作空间上限 {{days}} 天。",
+ "expiration-must-be-future": "过期时间必须是将来的时间。",
+ "failed-to-build-expression": "构建 CEL 表达式失败,请重试。",
+ "labels-misconfigured": {
+ "description": "此项目要求选择工单标签,但尚未配置任何标签。请联系项目所有者添加标签后再申请角色。",
+ "title": "项目要求工单标签但未配置"
+ },
+ "max-expiration-hint": "工作空间策略允许的最大值:{{days}} 天。"
+ },
"revoke-role-from-member": "从 '{{member}}' 撤销 '{{role}}' 角色?"
},
"settings": {
@@ -1953,8 +1968,11 @@
}
},
"delete": "删除审核策略",
+ "delete-description": "SQL 审核策略及其所有规则将被永久删除,此操作无法撤销。",
"description": "SQL 审核策略可以为不同的环境定义不同的 SQL lint 规则集. 它可以帮助团队采用 SQL 最佳使用实践,并在不同的数据库上约束 schema 的一致性。每当您尝试做一个 DDL/DML 变更或者使用 SQL 编辑器来查询数据时, 配置的 SQL 审核规则就会检查相应的执行语句。",
+ "disable-description": "禁用此策略将停止对已关联资源应用规则。您可以稍后重新启用。",
"disabled": "SQL 审核策略已禁用",
+ "enable-description": "启用此策略将开始对已关联资源应用规则。",
"enabled-rules": "开启的规则数",
"engine": {
"mariadb": "MariaDB",
diff --git a/frontend/src/react/pages/project/export-center/DataExportPrepDrawer.tsx b/frontend/src/react/pages/project/export-center/DataExportPrepDrawer.tsx
index fe2200c935..77c908c348 100644
--- a/frontend/src/react/pages/project/export-center/DataExportPrepDrawer.tsx
+++ b/frontend/src/react/pages/project/export-center/DataExportPrepDrawer.tsx
@@ -1,21 +1,15 @@
import { create } from "@bufbuild/protobuf";
-import {
- ChevronDown,
- Database as DatabaseIcon,
- FolderTree,
- Loader2,
- X,
-} from "lucide-react";
+import { Database as DatabaseIcon, FolderTree, Loader2, X } from "lucide-react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { v4 as uuidv4 } from "uuid";
import { EngineIconPath } from "@/components/InstanceForm/constants";
import { EnvironmentLabel } from "@/react/components/EnvironmentLabel";
+import { IssueLabelSelect } from "@/react/components/IssueLabelSelect";
import { Button } from "@/react/components/ui/button";
import { Input } from "@/react/components/ui/input";
import { SearchInput } from "@/react/components/ui/search-input";
import { Switch } from "@/react/components/ui/switch";
-import { useClickOutside } from "@/react/hooks/useClickOutside";
import { useEscapeKey } from "@/react/hooks/useEscapeKey";
import { useSessionPageSize } from "@/react/hooks/useSessionPageSize";
import { useVueState } from "@/react/hooks/useVueState";
@@ -611,128 +605,6 @@ function TargetBadge({ target }: { target: string }) {
);
}
-// ---------------------------------------------------------------------------
-// IssueLabelSelect (reusable for export form)
-// ---------------------------------------------------------------------------
-
-function IssueLabelSelect({
- labels,
- selected,
- required,
- onChange,
-}: {
- labels: { value: string; color: string }[];
- selected: string[];
- required: boolean;
- onChange: (labels: string[]) => void;
-}) {
- const { t } = useTranslation();
- const [open, setOpen] = useState(false);
- const containerRef = useRef<HTMLDivElement>(null);
- const closeDropdown = useCallback(() => setOpen(false), []);
- useClickOutside(containerRef, open, closeDropdown);
-
- const toggleLabel = (value: string) => {
- onChange(
- selected.includes(value)
- ? selected.filter((l) => l !== value)
- : [...selected, value]
- );
- };
-
- return (
- <div className="flex flex-col gap-y-2">
- <label className="text-sm font-medium text-control">
- {t("issue.labels")}
- {required && <span className="text-error"> *</span>}
- </label>
- <div ref={containerRef} className="relative">
- <button
- type="button"
- className={cn(
- "w-full flex items-center justify-between gap-2 border border-control-border rounded-sm h-9 px-3 text-sm bg-background text-left transition-colors",
- "hover:border-control-border",
- open && "border-accent shadow-[0_0_0_1px_var(--color-accent)]"
- )}
- onClick={() => setOpen(!open)}
- >
- {selected.length > 0 ? (
- <div className="flex items-center gap-1.5 truncate">
- {selected.map((val) => {
- const label = labels.find((l) => l.value === val);
- return (
- <span
- key={val}
- className="inline-flex items-center gap-1 px-1.5 py-0.5 rounded-xs bg-control-bg text-xs"
- >
- <span
- className="size-2.5 rounded-sm shrink-0"
- style={{ backgroundColor: label?.color }}
- />
- {val}
- <X
- className="size-3 text-control-placeholder hover:text-control-light"
- onClick={(e) => {
- e.stopPropagation();
- toggleLabel(val);
- }}
- />
- </span>
- );
- })}
- </div>
- ) : (
- <span className="text-control-placeholder">
- {t("common.select")}
- </span>
- )}
- <ChevronDown
- className={cn(
- "size-4 text-control-placeholder shrink-0 transition-transform",
- open && "rotate-180"
- )}
- />
- </button>
- {open && (
- <div className="absolute z-50 mt-1 w-full bg-background border border-block-border rounded-sm shadow-lg overflow-hidden">
- <div className="max-h-60 overflow-y-auto">
- {labels.length === 0 ? (
- <div className="px-3 py-6 text-sm text-control-placeholder text-center">
- {t("common.no-data")}
- </div>
- ) : (
- labels.map((label) => {
- const isSelected = selected.includes(label.value);
- return (
- <button
- key={label.value}
- type="button"
- className="w-full text-left px-3 py-2 text-sm flex items-center gap-2 hover:bg-control-bg transition-colors"
- onClick={() => toggleLabel(label.value)}
- >
- <input
- type="checkbox"
- checked={isSelected}
- readOnly
- className="rounded-xs border-control-border accent-accent"
- />
- <span
- className="size-4 rounded-sm shrink-0"
- style={{ backgroundColor: label.color }}
- />
- <span>{label.value}</span>
- </button>
- );
- })
- )}
- </div>
- </div>
- )}
- </div>
- </div>
- );
-}
-
// ---------------------------------------------------------------------------
// DatabaseAndGroupSelector (step 1)
// ---------------------------------------------------------------------------
diff --git a/frontend/src/react/pages/settings/MembersPage.tsx b/frontend/src/react/pages/settings/MembersPage.tsx
index 74d762d224..296d47220e 100644
--- a/frontend/src/react/pages/settings/MembersPage.tsx
+++ b/frontend/src/react/pages/settings/MembersPage.tsx
@@ -1,4 +1,6 @@
import { create } from "@bufbuild/protobuf";
+import { DurationSchema } from "@bufbuild/protobuf/wkt";
+import dayjs from "dayjs";
import {
Building2,
Check,
@@ -7,6 +9,7 @@ import {
Info,
Pencil,
Plus,
+ ShieldUser,
Trash2,
Users,
X,
@@ -25,9 +28,21 @@ import {
roleHasDatabaseLimitation,
roleHasEnvironmentLimitation,
} from "@/components/ProjectMember/utils";
+import { issueServiceClientConnect } from "@/connect";
+import type { ConditionGroupExpr, Factor, Operator } from "@/plugins/cel";
+import {
+ buildCELExpr,
+ emptySimpleExpr,
+ validateSimpleExpr,
+ wrapAsGroup,
+} from "@/plugins/cel";
import { AccountMultiSelect } from "@/react/components/AccountMultiSelect";
import { DatabaseResourceSelector as DatabaseResourceSelectorComponent } from "@/react/components/DatabaseResourceSelector";
import { EnvironmentLabel } from "@/react/components/EnvironmentLabel";
+import type { OptionConfig } from "@/react/components/ExprEditor";
+import { ExprEditor } from "@/react/components/ExprEditor";
+import { FeatureBadge } from "@/react/components/FeatureBadge";
+import { IssueLabelSelect } from "@/react/components/IssueLabelSelect";
import { LearnMoreLink } from "@/react/components/LearnMoreLink";
import { PermissionGuard } from "@/react/components/PermissionGuard";
import { RoleSelect } from "@/react/components/RoleSelect";
@@ -39,6 +54,12 @@ import {
} from "@/react/components/ui/alert";
import { Badge } from "@/react/components/ui/badge";
import { Button } from "@/react/components/ui/button";
+import {
+ Dialog,
+ DialogContent,
+ DialogTitle,
+} from "@/react/components/ui/dialog";
+import { ExpirationPicker } from "@/react/components/ui/expiration-picker";
import { Input } from "@/react/components/ui/input";
import { SearchInput } from "@/react/components/ui/search-input";
import {
@@ -47,10 +68,13 @@ import {
TabsPanel,
TabsTrigger,
} from "@/react/components/ui/tabs";
+import { Textarea } from "@/react/components/ui/textarea";
import { useClickOutside } from "@/react/hooks/useClickOutside";
import { useEscapeKey } from "@/react/hooks/useEscapeKey";
import { useVueState } from "@/react/hooks/useVueState";
import { cn } from "@/react/lib/utils";
+import { router } from "@/router";
+import { PROJECT_V1_ROUTE_ISSUE_DETAIL } from "@/router/dashboard/projectV1";
import {
pushNotification,
useActuatorV1Store,
@@ -59,6 +83,7 @@ import {
useProjectIamPolicyStore,
useProjectV1Store,
useRoleStore,
+ useSettingV1Store,
useSubscriptionV1Store,
useWorkspaceV1Store,
} from "@/store";
@@ -67,19 +92,38 @@ import {
ALL_USERS_USER_EMAIL,
type DatabaseResource,
isDefaultProject,
+ PresetRoleType,
userBindingPrefix,
} from "@/types";
import { ExprSchema as ConditionExprSchema } from "@/types/proto-es/google/type/expr_pb";
import { State } from "@/types/proto-es/v1/common_pb";
import { type Binding, BindingSchema } from "@/types/proto-es/v1/iam_policy_pb";
+import {
+ CreateIssueRequestSchema,
+ Issue_Type,
+ IssueSchema,
+ RoleGrantSchema,
+} from "@/types/proto-es/v1/issue_service_pb";
+import type { Project } from "@/types/proto-es/v1/project_service_pb";
+import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
import { AccountType, getAccountTypeByEmail } from "@/types/v1/user";
import {
+ batchConvertParsedExprToCELString,
displayRoleTitle,
+ extractIssueUID,
+ extractProjectResourceName,
formatAbsoluteDateTime,
+ formatIssueTitle,
+ getDatabaseNameOptionConfig,
hasProjectPermissionV2,
hasWorkspacePermissionV2,
sortRoles,
} from "@/utils";
+import {
+ CEL_ATTRIBUTE_RESOURCE_DATABASE,
+ CEL_ATTRIBUTE_RESOURCE_SCHEMA_NAME,
+ CEL_ATTRIBUTE_RESOURCE_TABLE_NAME,
+} from "@/utils/cel-attributes";
import {
buildConditionExpr,
convertFromExpr,
@@ -1600,6 +1644,460 @@ function EditMemberRoleDrawer({
);
}
+// ============================================================
+// RequestRoleDialog — lets a project member without
+// `bb.projects.setIamPolicy` open a role-grant issue to request
+// access for themselves. This is the React equivalent of the old
+// Vue `RoleGrantPanel` entry point that lived on the project
+// members page before the React migration.
+// ============================================================
+
+function RequestRoleDialog({
+ project,
+ onClose,
+}: {
+ project: Project;
+ onClose: () => void;
+}) {
+ const { t } = useTranslation();
+ const currentUser = useVueState(() => useCurrentUserV1().value);
+ const [role, setRole] = useState("");
+ const [reason, setReason] = useState("");
+ const [expirationTimestamp, setExpirationTimestamp] = useState<
+ string | undefined
+ >(undefined);
+ const [labels, setLabels] = useState<string[]>([]);
+ // Role-scope fields — only rendered for roles that require them, but kept
+ // in state so switching roles back and forth preserves user input.
+ const [databaseMode, setDatabaseMode] = useState<DatabaseMode>("ALL");
+ const [databaseResources, setDatabaseResources] = useState<
+ DatabaseResource[]
+ >([]);
+ // CEL expression for EXPRESSION mode is held as a structured group so it
+ // can render in ExprEditor (matching the old Vue DatabaseResourceForm).
+ const [exprGroup, setExprGroup] = useState<ConditionGroupExpr>(() =>
+ wrapAsGroup(emptySimpleExpr())
+ );
+ const [environments, setEnvironments] = useState<string[]>([]);
+ const [submitting, setSubmitting] = useState(false);
+
+ const settingStore = useSettingV1Store();
+
+ // Workspace-configured maximum role expiration, in days. Matches the old
+ // Vue ExpirationSelector: PROJECT_OWNER grants are exempted (project
+ // owners can request unbounded expirations), otherwise the workspace cap
+ // applies. Returns undefined when no cap is set.
+ const maximumRoleExpirationDays = useVueState(() => {
+ if (role === PresetRoleType.PROJECT_OWNER) return undefined;
+ const seconds =
+ settingStore.workspaceProfile.maximumRoleExpiration?.seconds;
+ if (!seconds) return undefined;
+ return Math.floor(Number(seconds) / (60 * 60 * 24));
+ });
+
+ // ExprEditor factor/option config — mirrors the old Vue
+ // DatabaseResourceForm config for role-grant requests.
+ const factorList = useMemo<Factor[]>(
+ () => [
+ CEL_ATTRIBUTE_RESOURCE_DATABASE,
+ CEL_ATTRIBUTE_RESOURCE_TABLE_NAME,
+ CEL_ATTRIBUTE_RESOURCE_SCHEMA_NAME,
+ ],
+ []
+ );
+ const factorOperatorOverrideMap = useMemo(
+ () =>
+ new Map<Factor, Operator[]>([
+ [CEL_ATTRIBUTE_RESOURCE_DATABASE, ["_==_", "@in"]],
+ [CEL_ATTRIBUTE_RESOURCE_SCHEMA_NAME, ["_==_"]],
+ [CEL_ATTRIBUTE_RESOURCE_TABLE_NAME, ["_==_", "@in"]],
+ ]),
+ []
+ );
+ const factorOptionConfigMap = useMemo(
+ () =>
+ factorList.reduce((map, factor) => {
+ if (factor === CEL_ATTRIBUTE_RESOURCE_DATABASE) {
+ map.set(factor, getDatabaseNameOptionConfig(project.name));
+ } else {
+ map.set(factor, { options: [] });
+ }
+ return map;
+ }, new Map<Factor, OptionConfig>()),
+ [factorList, project.name]
+ );
+
+ // Bind the datetime-local picker's min to the current minute so users
+ // can't silently pick a time earlier today and submit a zero-duration
+ // role grant.
+ const minDatetime = dayjs().format("YYYY-MM-DDTHH:mm");
+ const maxDatetime = maximumRoleExpirationDays
+ ? dayjs().add(maximumRoleExpirationDays, "days").format("YYYY-MM-DDTHH:mm")
+ : undefined;
+
+ const expirationIsInPast =
+ !!expirationTimestamp &&
+ dayjs(expirationTimestamp).unix() <= dayjs().unix();
+
+ // Workspace policy may cap role expiration; block submit when the picked
+ // timestamp would exceed that cap (matches Vue ExpirationSelector which
+ // disables over-cap dates in its picker).
+ const expirationExceedsMax =
+ !!expirationTimestamp &&
+ !!maximumRoleExpirationDays &&
+ dayjs(expirationTimestamp).isAfter(
+ dayjs().add(maximumRoleExpirationDays, "days")
+ );
+
+ const labelsMisconfigured =
+ project.forceIssueLabels && project.issueLabels.length === 0;
+
+ // Match the old Vue AddProjectMemberForm behavior: reason is only required
+ // when the project enforces issue titles (where the reason becomes the
+ // title). Otherwise the title is auto-generated and the reason is optional.
+ const reasonRequired = project.enforceIssueTitle;
+
+ // SQL-permission roles need a database scope (and sometimes an environment
+ // scope). Submitting without one produces a project-wide binding which is
+ // broader than the user typically intends.
+ const showDatabases = !!role && roleHasDatabaseLimitation(role);
+ const showEnvironments = !!role && roleHasEnvironmentLimitation(role);
+
+ const databaseScopeComplete =
+ !showDatabases ||
+ databaseMode === "ALL" ||
+ (databaseMode === "SELECT" && databaseResources.length > 0) ||
+ (databaseMode === "EXPRESSION" && validateSimpleExpr(exprGroup));
+
+ // When the workspace enforces a maximum role expiration, the user MUST
+ // pick an expiration — leaving it empty sends `roleGrant.expiration` as
+ // `undefined`, which the backend's approval runner treats as effectively
+ // unbounded (math.MaxInt32 days), bypassing the cap entirely.
+ const expirationRequired = maximumRoleExpirationDays !== undefined;
+
+ const canSubmit =
+ !submitting &&
+ !!role &&
+ (!reasonRequired || reason.trim().length > 0) &&
+ (!expirationRequired || !!expirationTimestamp) &&
+ !expirationIsInPast &&
+ !expirationExceedsMax &&
+ !labelsMisconfigured &&
+ databaseScopeComplete &&
+ (!project.forceIssueLabels || labels.length > 0);
+
+ const handleSubmit = async () => {
+ if (!canSubmit) return;
+ setSubmitting(true);
+ try {
+ const trimmedReason = reason.trim();
+ const expirationTimestampInMS = expirationTimestamp
+ ? dayjs(expirationTimestamp).valueOf()
+ : undefined;
+
+ // Only pass scope filters when the selected role actually requires
+ // them, matching EditMemberRoleDrawer's submit logic.
+ const scopedDatabaseResources =
+ showDatabases &&
+ databaseMode === "SELECT" &&
+ databaseResources.length > 0
+ ? databaseResources
+ : undefined;
+ const scopedEnvironments = showEnvironments ? environments : undefined;
+
+ // The backend uses two fields on the RoleGrant message:
+ // 1. `condition.expression` — CEL evaluated by
+ // UpdateProjectPolicyFromRoleGrantIssue to gate the resulting
+ // project IAM binding (access control).
+ // 2. `expiration` — Duration consumed by
+ // backend/runner/approval/runner.go (request.expiration_days) to
+ // route the approval chain; unset defaults to math.MaxInt32 days.
+ // Both must be populated — the condition controls what the grant
+ // allows, the expiration controls which approvers review it.
+ let condition;
+ if (showDatabases && databaseMode === "EXPRESSION") {
+ // Convert the structured ExprEditor group to a raw CEL string and
+ // combine it with any environment/expiration clauses. Mirrors
+ // ProjectMaskingExemptionCreatePage's EXPRESSION-mode submit path.
+ const parsedExpr = await buildCELExpr(exprGroup);
+ if (!parsedExpr) {
+ throw new Error("failed to build CEL expression");
+ }
+ const [exprString] = await batchConvertParsedExprToCELString([
+ parsedExpr,
+ ]);
+ // `batchConvertParsedExprToCELString` swallows deparse errors and
+ // returns an empty string on failure. Submitting anyway would
+ // silently drop the database scope filter and produce a broader
+ // grant than the user requested — refuse instead and surface an
+ // error so the user can retry.
+ if (!exprString || !exprString.trim()) {
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: t("project.members.request-role.failed-to-build-expression"),
+ });
+ return;
+ }
+ const extraParts = stringifyConditionExpression({
+ expirationTimestampInMS,
+ environments: scopedEnvironments,
+ });
+ const fullExpression = extraParts
+ ? `(${exprString}) && ${extraParts}`
+ : exprString;
+ condition = create(ConditionExprSchema, {
+ expression: fullExpression,
+ description: trimmedReason,
+ });
+ } else {
+ condition = buildConditionExpr({
+ role,
+ description: trimmedReason,
+ expirationTimestampInMS,
+ databaseResources: scopedDatabaseResources,
+ environments: scopedEnvironments,
+ });
+ }
+
+ const expiration = expirationTimestamp
+ ? create(DurationSchema, {
+ seconds: BigInt(
+ Math.max(0, dayjs(expirationTimestamp).unix() - dayjs().unix())
+ ),
+ })
+ : undefined;
+
+ const roleGrant = create(RoleGrantSchema, {
+ role,
+ user: `users/${currentUser.email}`,
+ condition,
+ expiration,
+ });
+
+ // Collect the scoped database names so the auto-generated title shows
+ // `[db1]` / `[N databases]` instead of defaulting to `[All databases]`
+ // — matches the old Vue RoleGrantPanel behavior. EXPRESSION mode
+ // currently falls through to `[All databases]` since parsing CEL back
+ // into concrete database names would require an async round-trip.
+ const titleDatabaseNames =
+ scopedDatabaseResources && scopedDatabaseResources.length > 0
+ ? [...new Set(scopedDatabaseResources.map((r) => r.databaseFullName))]
+ : undefined;
+
+ // When the project enforces issue titles, the user-provided reason is
+ // treated as the title (matching the old Vue RoleGrantPanel behavior).
+ const title = project.enforceIssueTitle
+ ? `[${t("issue.title.request-role")}] ${trimmedReason}`
+ : formatIssueTitle(
+ t("issue.title.request-specific-role", {
+ role: displayRoleTitle(role),
+ }),
+ titleDatabaseNames
+ );
+
+ const newIssue = create(IssueSchema, {
+ title,
+ description: trimmedReason,
+ type: Issue_Type.ROLE_GRANT,
+ roleGrant,
+ labels,
+ });
+ const response = await issueServiceClientConnect.createIssue(
+ create(CreateIssueRequestSchema, {
+ parent: project.name,
+ issue: newIssue,
+ })
+ );
+ const route = router.resolve({
+ name: PROJECT_V1_ROUTE_ISSUE_DETAIL,
+ params: {
+ projectId: extractProjectResourceName(response.name),
+ issueId: extractIssueUID(response.name),
+ },
+ });
+ window.open(route.fullPath, "_blank", "noopener,noreferrer");
+ onClose();
+ } catch {
+ // Error notification is pushed by the client middleware.
+ } finally {
+ setSubmitting(false);
+ }
+ };
+
+ const showLabelSelect =
+ project.issueLabels.length > 0 || project.forceIssueLabels;
+
+ return (
+ <Dialog
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DialogContent className="max-w-lg p-6">
+ <DialogTitle>{t("issue.title.request-role")}</DialogTitle>
+ <div className="flex flex-col gap-y-4 mt-4">
+ {labelsMisconfigured && (
+ <Alert variant="warning">
+ <AlertTitle>
+ {t("project.members.request-role.labels-misconfigured.title")}
+ </AlertTitle>
+ <AlertDescription>
+ {t(
+ "project.members.request-role.labels-misconfigured.description"
+ )}
+ </AlertDescription>
+ </Alert>
+ )}
+ <div className="flex flex-col gap-y-1">
+ <label className="text-sm font-medium">
+ {t("common.role.self")}
+ <span className="text-error ml-0.5">*</span>
+ </label>
+ <RoleSelect
+ scope="project"
+ multiple={false}
+ value={role ? [role] : []}
+ onChange={(roles) => {
+ setRole(roles[0] ?? "");
+ // Reset scope when switching roles since DB/env fields only
+ // apply to some roles and the new role may not use them.
+ setDatabaseMode("ALL");
+ setDatabaseResources([]);
+ setExprGroup(wrapAsGroup(emptySimpleExpr()));
+ setEnvironments([]);
+ }}
+ />
+ </div>
+ <div className="flex flex-col gap-y-1">
+ <label className="text-sm font-medium">
+ {t("common.reason")}
+ {reasonRequired && <span className="text-error ml-0.5">*</span>}
+ </label>
+ <Textarea
+ value={reason}
+ onChange={(e) => setReason(e.target.value)}
+ placeholder={t("common.reason")}
+ rows={3}
+ />
+ </div>
+ {showDatabases && (
+ <div className="flex flex-col gap-y-2">
+ <label className="text-sm font-medium">
+ {t("common.databases")}
+ <span className="text-error ml-0.5">*</span>
+ </label>
+ <div className="flex items-center gap-x-4">
+ {(["ALL", "EXPRESSION", "SELECT"] as DatabaseMode[]).map(
+ (m) => (
+ <label
+ key={m}
+ className="flex items-center gap-x-2 text-sm cursor-pointer"
+ >
+ <input
+ type="radio"
+ name="request-role-db-mode"
+ checked={databaseMode === m}
+ onChange={() => {
+ setDatabaseMode(m);
+ setDatabaseResources([]);
+ setExprGroup(wrapAsGroup(emptySimpleExpr()));
+ }}
+ />
+ {m === "ALL"
+ ? t("issue.role-grant.all-databases")
+ : m === "EXPRESSION"
+ ? t("issue.role-grant.use-cel")
+ : t("issue.role-grant.manually-select")}
+ </label>
+ )
+ )}
+ </div>
+ {databaseMode === "EXPRESSION" && (
+ <ExprEditor
+ expr={exprGroup}
+ factorList={factorList}
+ optionConfigMap={factorOptionConfigMap}
+ factorOperatorOverrideMap={factorOperatorOverrideMap}
+ onUpdate={setExprGroup}
+ />
+ )}
+ {databaseMode === "SELECT" && (
+ <DatabaseResourceSelectorComponent
+ projectName={project.name}
+ value={databaseResources}
+ onChange={setDatabaseResources}
+ />
+ )}
+ </div>
+ )}
+ {showEnvironments && (
+ <div className="flex flex-col gap-y-1">
+ <label className="text-sm font-medium">
+ {t("common.environments")}
+ </label>
+ <EnvironmentMultiSelect
+ value={environments}
+ onChange={setEnvironments}
+ />
+ </div>
+ )}
+ <div className="flex flex-col gap-y-1">
+ <label className="text-sm font-medium">
+ {t("common.expiration")}
+ {expirationRequired && (
+ <span className="text-error ml-0.5">*</span>
+ )}
+ </label>
+ <ExpirationPicker
+ value={expirationTimestamp}
+ onChange={setExpirationTimestamp}
+ minDate={minDatetime}
+ maxDate={maxDatetime}
+ />
+ {maximumRoleExpirationDays !== undefined && (
+ <p className="text-xs text-control-light">
+ {t("project.members.request-role.max-expiration-hint", {
+ days: maximumRoleExpirationDays,
+ })}
+ </p>
+ )}
+ {expirationIsInPast && (
+ <p className="text-xs text-error">
+ {t("project.members.request-role.expiration-must-be-future")}
+ </p>
+ )}
+ {expirationExceedsMax && (
+ <p className="text-xs text-error">
+ {t("project.members.request-role.expiration-exceeds-max", {
+ days: maximumRoleExpirationDays,
+ })}
+ </p>
+ )}
+ </div>
+ {showLabelSelect && (
+ <IssueLabelSelect
+ labels={project.issueLabels}
+ selected={labels}
+ required={project.forceIssueLabels}
+ onChange={setLabels}
+ />
+ )}
+ </div>
+ <div className="flex items-center justify-end gap-x-2 mt-6">
+ <Button variant="outline" onClick={onClose} disabled={submitting}>
+ {t("common.cancel")}
+ </Button>
+ <Button disabled={!canSubmit} onClick={handleSubmit}>
+ {t("common.submit")}
+ </Button>
+ </div>
+ </DialogContent>
+ </Dialog>
+ );
+}
+
// ============================================================
// MembersPage
// ============================================================
@@ -1636,6 +2134,11 @@ export function MembersPage({ projectId }: { projectId?: string }) {
const [editingMember, setEditingMember] = useState<
MemberBinding | undefined
>();
+ const [showRequestRoleDialog, setShowRequestRoleDialog] = useState(false);
+
+ const hasRequestRoleFeature = useVueState(() =>
+ subscriptionStore.hasFeature(PlanFeature.FEATURE_REQUEST_ROLE_WORKFLOW)
+ );
// Fetch project IAM policy on mount
useEffect(() => {
@@ -1747,6 +2250,20 @@ export function MembersPage({ projectId }: { projectId?: string }) {
const scope = projectName ? "project" : "workspace";
+ // A project member without `bb.projects.setIamPolicy` cannot grant access
+ // to themselves, so they need to request it instead. The old Vue
+ // ProjectMemberPanel showed a "Request Role" button in this case; we
+ // restore the same behavior here.
+ const canRequestRole = useMemo(() => {
+ if (!project || !projectName) return false;
+ if (!project.allowRequestRole) return false;
+ if (canSetIamPolicy) return false;
+ return (
+ hasProjectPermissionV2(project, "bb.issues.create") &&
+ hasProjectPermissionV2(project, "bb.roles.list")
+ );
+ }, [project, projectName, canSetIamPolicy]);
+
return (
<div className="w-full px-4 overflow-x-hidden flex flex-col pt-2 pb-4">
{!projectName && remainingUserCount <= 3 && (
@@ -1781,29 +2298,48 @@ export function MembersPage({ projectId }: { projectId?: string }) {
value={memberSearchText}
onChange={(e) => setMemberSearchText(e.target.value)}
/>
- <PermissionGuard permissions={["bb.workspaces.setIamPolicy"]}>
- <div className="flex items-center gap-x-2">
- {memberViewTab === "MEMBERS" && (
+ <div className="flex items-center gap-x-2">
+ <PermissionGuard permissions={["bb.workspaces.setIamPolicy"]}>
+ <div className="flex items-center gap-x-2">
+ {memberViewTab === "MEMBERS" && (
+ <Button
+ variant="outline"
+ disabled={!canSetIamPolicy || selectedMembers.length === 0}
+ onClick={handleRevokeSelected}
+ >
+ {t("settings.members.revoke-access")}
+ </Button>
+ )}
<Button
- variant="outline"
- disabled={!canSetIamPolicy || selectedMembers.length === 0}
- onClick={handleRevokeSelected}
+ disabled={!canSetIamPolicy}
+ onClick={() => {
+ setEditingMember(undefined);
+ setShowEditMemberDrawer(true);
+ }}
>
- {t("settings.members.revoke-access")}
+ <Plus className="h-4 w-4 mr-1" />
+ {t("settings.members.grant-access")}
</Button>
- )}
+ </div>
+ </PermissionGuard>
+ {canRequestRole && (
<Button
- disabled={!canSetIamPolicy}
- onClick={() => {
- setEditingMember(undefined);
- setShowEditMemberDrawer(true);
- }}
+ disabled={!hasRequestRoleFeature}
+ onClick={() => setShowRequestRoleDialog(true)}
>
- <Plus className="h-4 w-4 mr-1" />
- {t("settings.members.grant-access")}
+ {hasRequestRoleFeature ? (
+ <ShieldUser className="size-4 mr-1" />
+ ) : (
+ <FeatureBadge
+ feature={PlanFeature.FEATURE_REQUEST_ROLE_WORKFLOW}
+ clickable={false}
+ className="mr-1"
+ />
+ )}
+ {t("issue.title.request-role")}
</Button>
- </div>
- </PermissionGuard>
+ )}
+ </div>
</div>
<Tabs
@@ -1844,6 +2380,13 @@ export function MembersPage({ projectId }: { projectId?: string }) {
</TabsPanel>
</Tabs>
+ {showRequestRoleDialog && project && (
+ <RequestRoleDialog
+ project={project}
+ onClose={() => setShowRequestRoleDialog(false)}
+ />
+ )}
+
{showEditMemberDrawer && (
<EditMemberRoleDrawer
member={editingMember}
diff --git a/frontend/src/react/pages/settings/SQLReviewDetailPage.tsx b/frontend/src/react/pages/settings/SQLReviewDetailPage.tsx
index d921eaa631..5a629f7778 100644
--- a/frontend/src/react/pages/settings/SQLReviewDetailPage.tsx
+++ b/frontend/src/react/pages/settings/SQLReviewDetailPage.tsx
@@ -14,6 +14,7 @@ import { Button } from "@/react/components/ui/button";
import {
Dialog,
DialogContent,
+ DialogDescription,
DialogTitle,
} from "@/react/components/ui/dialog";
import { Input } from "@/react/components/ui/input";
@@ -371,11 +372,14 @@ export function SQLReviewDetailPage({
{/* Disable confirmation dialog */}
<Dialog open={showDisableModal} onOpenChange={setShowDisableModal}>
- <DialogContent>
+ <DialogContent className="max-w-md p-6">
<DialogTitle>
{t("common.disable")} &apos;{reviewPolicy.name}&apos;?
</DialogTitle>
- <div className="flex justify-end gap-x-2 mt-4">
+ <DialogDescription className="mt-2">
+ {t("sql-review.disable-description")}
+ </DialogDescription>
+ <div className="flex justify-end gap-x-2 mt-6">
<Button
variant="outline"
onClick={() => setShowDisableModal(false)}
@@ -391,11 +395,14 @@ export function SQLReviewDetailPage({
{/* Enable confirmation dialog */}
<Dialog open={showEnableModal} onOpenChange={setShowEnableModal}>
- <DialogContent>
+ <DialogContent className="max-w-md p-6">
<DialogTitle>
{t("common.enable")} &apos;{reviewPolicy.name}&apos;?
</DialogTitle>
- <div className="flex justify-end gap-x-2 mt-4">
+ <DialogDescription className="mt-2">
+ {t("sql-review.enable-description")}
+ </DialogDescription>
+ <div className="flex justify-end gap-x-2 mt-6">
<Button variant="outline" onClick={() => setShowEnableModal(false)}>
{t("common.cancel")}
</Button>
@@ -406,11 +413,14 @@ export function SQLReviewDetailPage({
{/* Delete confirmation dialog */}
<Dialog open={showDeleteConfirm} onOpenChange={setShowDeleteConfirm}>
- <DialogContent>
+ <DialogContent className="max-w-md p-6">
<DialogTitle>
{t("common.delete")} &apos;{reviewPolicy.name}&apos;?
</DialogTitle>
- <div className="flex justify-end gap-x-2 mt-4">
+ <DialogDescription className="mt-2">
+ {t("sql-review.delete-description")}
+ </DialogDescription>
+ <div className="flex justify-end gap-x-2 mt-6">
<Button
variant="outline"
onClick={() => setShowDeleteConfirm(false)}
diff --git a/frontend/src/react/plugins/agent/components/AgentWindow.tsx b/frontend/src/react/plugins/agent/components/AgentWindow.tsx
index 82146a0e1b..1f85836c30 100644
--- a/frontend/src/react/plugins/agent/components/AgentWindow.tsx
+++ b/frontend/src/react/plugins/agent/components/AgentWindow.tsx
@@ -22,11 +22,19 @@ import {
import { AgentChat } from "./AgentChat";
import { AgentInput } from "./AgentInput";
-const MIN_WIDTH = 300;
-const MIN_HEIGHT = 400;
-const WINDOW_MARGIN = 16;
const MIN_SIDEBAR_WIDTH = 180;
const MIN_MAIN_PANEL_WIDTH = 240;
+// Budget for the sidebar resize handle, borders, and a small breathing
+// room so the main panel actually reaches its minimum width without the
+// input row collapsing.
+const WINDOW_CHROME_BUDGET = 40;
+// Keep the total window wide enough so both the sidebar and the main panel
+// can render at their minimums side by side; otherwise the input row gets
+// squeezed and the placeholder wraps onto multiple lines.
+const MIN_WIDTH =
+ MIN_SIDEBAR_WIDTH + MIN_MAIN_PANEL_WIDTH + WINDOW_CHROME_BUDGET;
+const MIN_HEIGHT = 400;
+const WINDOW_MARGIN = 16;
const tokenFormatter = new Intl.NumberFormat();
@@ -67,24 +75,38 @@ export function AgentWindow() {
const resizeObserverRef = useRef<ResizeObserver | null>(null);
// --- Clamping helpers ---
+ //
+ // On wide viewports we keep MIN_WIDTH/MIN_HEIGHT as the preferred floor so
+ // the sidebar and main panel both hit their minimums. On narrow viewports
+ // (split panes, mobile-like widths), forcing those minimums would render
+ // the window partially off-screen — so the floor drops to whatever the
+ // viewport can accommodate minus the standard margins. At very narrow
+ // widths the main panel gets cramped, but that's strictly better than
+ // hiding controls.
const maxWidth = useCallback(
- () => Math.max(MIN_WIDTH, viewportSize.width - WINDOW_MARGIN * 2),
+ () => Math.max(1, viewportSize.width - WINDOW_MARGIN * 2),
[viewportSize.width]
);
const maxHeight = useCallback(
- () => Math.max(MIN_HEIGHT, viewportSize.height - WINDOW_MARGIN * 2),
+ () => Math.max(1, viewportSize.height - WINDOW_MARGIN * 2),
[viewportSize.height]
);
const clampWidth = useCallback(
- (width: number) =>
- Math.min(maxWidth(), Math.max(MIN_WIDTH, Math.round(width))),
+ (width: number) => {
+ const max = maxWidth();
+ const min = Math.min(MIN_WIDTH, max);
+ return Math.min(max, Math.max(min, Math.round(width)));
+ },
[maxWidth]
);
const clampHeight = useCallback(
- (height: number) =>
- Math.min(maxHeight(), Math.max(MIN_HEIGHT, Math.round(height))),
+ (height: number) => {
+ const max = maxHeight();
+ const min = Math.min(MIN_HEIGHT, max);
+ return Math.min(max, Math.max(min, Math.round(height)));
+ },
[maxHeight]
);
@@ -502,13 +524,21 @@ export function AgentWindow() {
const vh = window.innerHeight;
const dx = e.clientX - resizeStartRef.current.x;
const dy = e.clientY - resizeStartRef.current.y;
+ // Same viewport-aware clamp as clampWidth/clampHeight: floor at
+ // MIN_WIDTH/MIN_HEIGHT, but drop the floor when the viewport
+ // itself is narrower/shorter so the window never exceeds the
+ // visible area.
+ const maxW = Math.max(1, vw - WINDOW_MARGIN * 2);
+ const minW = Math.min(MIN_WIDTH, maxW);
+ const maxH = Math.max(1, vh - WINDOW_MARGIN * 2);
+ const minH = Math.min(MIN_HEIGHT, maxH);
const clW = Math.min(
- Math.max(MIN_WIDTH, vw - WINDOW_MARGIN * 2),
- Math.max(MIN_WIDTH, Math.round(resizeStartRef.current.w + dx))
+ maxW,
+ Math.max(minW, Math.round(resizeStartRef.current.w + dx))
);
const clH = Math.min(
- Math.max(MIN_HEIGHT, vh - WINDOW_MARGIN * 2),
- Math.max(MIN_HEIGHT, Math.round(resizeStartRef.current.h + dy))
+ maxH,
+ Math.max(minH, Math.round(resizeStartRef.current.h + dy))
);
el.style.width = `${clW}px`;
el.style.height = `${clH}px`;
@@ -625,14 +655,13 @@ export function AgentWindow() {
if (width === store.size.width && height === store.size.height) return;
useAgentStore.setState((state) => {
- const clW = Math.min(
- Math.max(MIN_WIDTH, viewportSize.width - WINDOW_MARGIN * 2),
- Math.max(MIN_WIDTH, Math.round(width))
- );
- const clH = Math.min(
- Math.max(MIN_HEIGHT, viewportSize.height - WINDOW_MARGIN * 2),
- Math.max(MIN_HEIGHT, Math.round(height))
- );
+ // Same viewport-aware floor as clampWidth/clampHeight.
+ const maxW = Math.max(1, viewportSize.width - WINDOW_MARGIN * 2);
+ const minW = Math.min(MIN_WIDTH, maxW);
+ const maxH = Math.max(1, viewportSize.height - WINDOW_MARGIN * 2);
+ const minH = Math.min(MIN_HEIGHT, maxH);
+ const clW = Math.min(maxW, Math.max(minW, Math.round(width)));
+ const clH = Math.min(maxH, Math.max(minH, Math.round(height)));
state.size.width = clW;
state.size.height = clH;
const maxX = Math.max(
diff --git a/frontend/src/react/plugins/agent/store/agent.ts b/frontend/src/react/plugins/agent/store/agent.ts
index 6241c7f8dc..5837c68b98 100644
--- a/frontend/src/react/plugins/agent/store/agent.ts
+++ b/frontend/src/react/plugins/agent/store/agent.ts
@@ -566,11 +566,11 @@ export const createAgentStore = () => {
// Window state
visible: false,
position: {
- x: typeof window !== "undefined" ? window.innerWidth - 420 : 0,
- y: typeof window !== "undefined" ? window.innerHeight - 520 : 0,
+ x: typeof window !== "undefined" ? window.innerWidth - 500 : 0,
+ y: typeof window !== "undefined" ? window.innerHeight - 560 : 0,
},
- size: { width: 400, height: 500 },
- sidebarWidth: 256,
+ size: { width: 480, height: 540 },
+ sidebarWidth: 200,
minimized: false,
// Chat state (from persisted/initial)