Skip to content

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

refactor(react): always surface expired roles, drop the show-expired toggle (#20181)

h3n4l9c9695bf4c40
diff --git a/frontend/src/react/locales/en-US.json b/frontend/src/react/locales/en-US.json
index 25fb71e853..da2435aee8 100644
--- a/frontend/src/react/locales/en-US.json
+++ b/frontend/src/react/locales/en-US.json
@@ -1724,8 +1724,7 @@
},
"max-expiration-hint": "Maximum allowed by workspace policy: {{days}} day(s)."
},
- "revoke-role-from-member": "Revoke '{{role}}' from '{{member}}'?",
- "show-expired-roles": "Show expired roles"
+ "revoke-role-from-member": "Revoke '{{role}}' from '{{member}}'?"
},
"overview": {
"info-slot-content": "Bytebase periodically syncs the instance schema. Newly synced databases are first placed here. User should transfer them to the proper application project."
diff --git a/frontend/src/react/locales/es-ES.json b/frontend/src/react/locales/es-ES.json
index fb8f0a1b33..3fa55d7a79 100644
--- a/frontend/src/react/locales/es-ES.json
+++ b/frontend/src/react/locales/es-ES.json
@@ -1716,8 +1716,7 @@
},
"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}}'?",
- "show-expired-roles": "Mostrar roles expirados"
+ "revoke-role-from-member": "¿Revocar '{{role}}' de '{{member}}'?"
},
"overview": {
"info-slot-content": "Bytebase sincroniza periódicamente el esquema de la instancia. Las bases de datos recién sincronizadas se colocan aquí primero. El usuario debe transferirlas al proyecto de aplicación adecuado."
diff --git a/frontend/src/react/locales/ja-JP.json b/frontend/src/react/locales/ja-JP.json
index 5668cd870a..3874bfc491 100644
--- a/frontend/src/react/locales/ja-JP.json
+++ b/frontend/src/react/locales/ja-JP.json
@@ -1716,8 +1716,7 @@
},
"max-expiration-hint": "ワークスペースポリシーで許可される最大値:{{days}} 日。"
},
- "revoke-role-from-member": "'{{member}}' から '{{role}}' を取り消しますか?",
- "show-expired-roles": "期限切れのロールを表示"
+ "revoke-role-from-member": "'{{member}}' から '{{role}}' を取り消しますか?"
},
"overview": {
"info-slot-content": "Bytebase はインスタンスのスキーマを定期的に同期します。新しく同期されたデータベースは最初にここに配置され、その後、それらを適切なプロジェクトに転送できます。"
diff --git a/frontend/src/react/locales/vi-VN.json b/frontend/src/react/locales/vi-VN.json
index befaf7ac1a..3e8f92baa6 100644
--- a/frontend/src/react/locales/vi-VN.json
+++ b/frontend/src/react/locales/vi-VN.json
@@ -1716,8 +1716,7 @@
},
"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}}'?",
- "show-expired-roles": "Hiển thị vai trò đã hết hạn"
+ "revoke-role-from-member": "Thu hồi '{{role}}' từ '{{member}}'?"
},
"overview": {
"info-slot-content": "Bytebase định kỳ đồng bộ hóa lược đồ phiên bản. Các cơ sở dữ liệu mới được đồng bộ hóa trước tiên được đặt ở đây. Người dùng nên chuyển chúng đến dự án ứng dụng thích hợp."
diff --git a/frontend/src/react/locales/zh-CN.json b/frontend/src/react/locales/zh-CN.json
index 9f0a1c3231..83b73b02a1 100644
--- a/frontend/src/react/locales/zh-CN.json
+++ b/frontend/src/react/locales/zh-CN.json
@@ -1716,8 +1716,7 @@
},
"max-expiration-hint": "工作空间策略允许的最大值:{{days}} 天。"
},
- "revoke-role-from-member": "从 '{{member}}' 撤销 '{{role}}' 角色?",
- "show-expired-roles": "显示已过期角色"
+ "revoke-role-from-member": "从 '{{member}}' 撤销 '{{role}}' 角色?"
},
"overview": {
"info-slot-content": "Bytebase 会定时同步实例的 schema,新同步的数据库会首先被置于这里,之后您可以再将他们转移到适当的项目中。"
diff --git a/frontend/src/react/pages/settings/MembersPage.tsx b/frontend/src/react/pages/settings/MembersPage.tsx
index 47ecbe391c..787083d637 100644
--- a/frontend/src/react/pages/settings/MembersPage.tsx
+++ b/frontend/src/react/pages/settings/MembersPage.tsx
@@ -126,7 +126,6 @@ function MemberTable({
onUpdateBinding,
onRevokeBinding,
scope,
- showExpiredRoles,
}: {
bindings: MemberBinding[];
allowEdit: boolean;
@@ -135,43 +134,30 @@ function MemberTable({
onUpdateBinding: (binding: MemberBinding) => void;
onRevokeBinding: (binding: MemberBinding) => void;
scope: "workspace" | "project";
- showExpiredRoles: boolean;
}) {
const { t } = useTranslation();
const currentUser = useVueState(() => useCurrentUserV1().value);
const actuatorStore = useActuatorV1Store();
const isSaaSMode = useVueState(() => actuatorStore.isSaaSMode);
- // When showExpiredRoles is off in project scope, hide rows whose only
- // project bindings are expired — otherwise they'd render as empty-roles
- // rows but still be selectable, which is misleading.
- const visibleBindings = useMemo(() => {
- if (scope !== "project" || showExpiredRoles) return bindings;
- return bindings.filter((mb) => {
- if (mb.projectRoleBindings.length === 0) return true;
- return mb.projectRoleBindings.some((b) => !isBindingPolicyExpired(b));
- });
- }, [bindings, scope, showExpiredRoles]);
-
const selectableBindings = useMemo(
() =>
- visibleBindings.filter(
+ bindings.filter(
(b) => scope !== "project" || b.projectRoleBindings.length > 0
),
- [visibleBindings, scope]
+ [bindings, scope]
);
- // Drop selections that are no longer visible (e.g. a member was selected
- // while showExpiredRoles=true, then the toggle was turned off and the
- // member's only bindings are expired). Without this, the bulk Revoke
- // action could destructively act on hidden rows.
+ // Drop selections that are no longer rendered. The parent filters
+ // `bindings` by search text, so without this a user could select rows,
+ // type a search that hides them, and still bulk-revoke hidden members.
useEffect(() => {
- const visibleNames = new Set(visibleBindings.map((b) => b.binding));
+ const visibleNames = new Set(bindings.map((b) => b.binding));
const next = selectedBindings.filter((b) => visibleNames.has(b));
if (next.length !== selectedBindings.length) {
onSelectionChange(next);
}
- }, [visibleBindings, selectedBindings, onSelectionChange]);
+ }, [bindings, selectedBindings, onSelectionChange]);
const allSelected =
selectableBindings.length > 0 &&
@@ -204,15 +190,26 @@ function MemberTable({
};
const renderProjectRoleSummary = (bindings: Binding[]) => {
- const visible = showExpiredRoles
- ? bindings
- : bindings.filter((b) => !isBindingPolicyExpired(b));
- return groupProjectRoleBindings(visible).map((group) => {
- const allExpired = group.bindings.every((b) => isBindingPolicyExpired(b));
- return (
+ // Show all roles, active first then expired. Expired chips get
+ // line-through + reduced opacity so the count of stale bindings is
+ // visible — exposing the issue rather than hiding it.
+ const active = bindings.filter((b) => !isBindingPolicyExpired(b));
+ const expired = bindings.filter((b) => isBindingPolicyExpired(b));
+ return [
+ ...groupProjectRoleBindings(active).map((group) => (
+ <Badge key={`active-${group.role}`} className="text-xs gap-x-1">
+ {displayRoleTitle(group.role)}
+ {group.bindings.length > 1 && (
+ <span className="text-control-light">
+ ({group.bindings.length})
+ </span>
+ )}
+ </Badge>
+ )),
+ ...groupProjectRoleBindings(expired).map((group) => (
<Badge
- key={group.role}
- className={cn("text-xs gap-x-1", allExpired && "line-through")}
+ key={`expired-${group.role}`}
+ className="text-xs gap-x-1 line-through opacity-60"
>
{displayRoleTitle(group.role)}
{group.bindings.length > 1 && (
@@ -221,8 +218,8 @@ function MemberTable({
</span>
)}
</Badge>
- );
- });
+ )),
+ ];
};
return (
@@ -251,7 +248,7 @@ function MemberTable({
</tr>
</thead>
<tbody>
- {visibleBindings.map((mb) => (
+ {bindings.map((mb) => (
<tr
key={mb.binding}
className="border-b last:border-b-0 hover:bg-control-bg"
@@ -372,7 +369,7 @@ function MemberTable({
</td>
</tr>
))}
- {visibleBindings.length === 0 && (
+ {bindings.length === 0 && (
<tr>
<td
colSpan={allowEdit ? 4 : 3}
@@ -398,14 +395,12 @@ function MemberTableByRole({
onUpdateBinding,
onRevokeBinding,
scope,
- showExpiredRoles,
}: {
bindings: MemberBinding[];
allowEdit: boolean;
onUpdateBinding: (binding: MemberBinding) => void;
onRevokeBinding: (binding: MemberBinding) => void;
scope: "workspace" | "project";
- showExpiredRoles: boolean;
}) {
const { t } = useTranslation();
const currentUser = useVueState(() => useCurrentUserV1().value);
@@ -424,13 +419,10 @@ function MemberTableByRole({
};
for (const mb of bindings) {
if (scope === "project") {
- const visibleBindings = showExpiredRoles
- ? mb.projectRoleBindings
- : mb.projectRoleBindings.filter((b) => !isBindingPolicyExpired(b));
- // Group this member's visible bindings by role so we can mark a row
- // expired only when ALL of its bindings for that role are expired.
+ // Group this member's bindings by role so we can mark a row expired
+ // only when ALL of its bindings for that role are expired.
const bindingsByRole = new Map<string, Binding[]>();
- for (const b of visibleBindings) {
+ for (const b of mb.projectRoleBindings) {
const arr = bindingsByRole.get(b.role) ?? [];
arr.push(b);
bindingsByRole.set(b.role, arr);
@@ -450,9 +442,12 @@ function MemberTableByRole({
const sortedRoles = sortRoles([...map.keys()]);
return sortedRoles.map((role) => ({
role,
- members: map.get(role) ?? [],
+ // Active members first, expired-only members last.
+ members: (map.get(role) ?? []).slice().sort((a, b) => {
+ return Number(a.allExpired) - Number(b.allExpired);
+ }),
}));
- }, [bindings, scope, showExpiredRoles]);
+ }, [bindings, scope]);
// Expand all roles by default on first load
useEffect(() => {
@@ -1034,20 +1029,6 @@ function EditMemberRoleDrawer({
});
const [isRequesting, setIsRequesting] = useState(false);
const [showNestedGrant, setShowNestedGrant] = useState(false);
- const [showExpiredRoles, setShowExpiredRoles] = useState(false);
-
- const hasExpiredRoles = useMemo(
- () => liveProjectRoleBindings.some((b) => isBindingPolicyExpired(b)),
- [liveProjectRoleBindings]
- );
-
- const visibleProjectRoleBindings = useMemo(
- () =>
- showExpiredRoles
- ? liveProjectRoleBindings
- : liveProjectRoleBindings.filter((b) => !isBindingPolicyExpired(b)),
- [liveProjectRoleBindings, showExpiredRoles]
- );
const [form, setForm] = useState<RoleBindingFormState>(() => ({
id: crypto.randomUUID(),
@@ -1381,22 +1362,12 @@ function EditMemberRoleDrawer({
{/* Body — Role Bindings */}
<SheetBody className="px-6 py-6">
<div className="flex flex-col gap-y-6">
- {hasExpiredRoles && (
- <label className="flex items-center gap-x-2 text-sm cursor-pointer self-start">
- <input
- type="checkbox"
- checked={showExpiredRoles}
- onChange={(e) => setShowExpiredRoles(e.target.checked)}
- />
- {t("project.members.show-expired-roles")}
- </label>
- )}
- {visibleProjectRoleBindings.length === 0 && (
+ {liveProjectRoleBindings.length === 0 && (
<div className="text-center text-control-light py-8">
{t("common.no-data")}
</div>
)}
- {visibleProjectRoleBindings.map((binding, idx) => {
+ {liveProjectRoleBindings.map((binding, idx) => {
const rows = getSingleBindingRows(binding);
const envLimitation =
getProjectRoleBindingEnvironmentLimitationState(binding);
@@ -1698,7 +1669,6 @@ export function MembersPage({ projectId }: { projectId?: string }) {
MemberBinding | undefined
>();
const [showRequestRoleDialog, setShowRequestRoleDialog] = useState(false);
- const [showExpiredRoles, setShowExpiredRoles] = useState(false);
const hasRequestRoleFeature = useVueState(() =>
subscriptionStore.hasFeature(PlanFeature.FEATURE_REQUEST_ROLE_WORKFLOW)
@@ -1733,14 +1703,6 @@ export function MembersPage({ projectId }: { projectId?: string }) {
})
);
- // Derived from the unfiltered IAM policy, not memberBindings (which is
- // already filtered by the search box). Otherwise the toggle would vanish
- // whenever a search happens to exclude members with expired bindings.
- const hasExpiredProjectRoles = useMemo(() => {
- if (!projectName || !projectIamPolicy) return false;
- return projectIamPolicy.bindings.some((b) => isBindingPolicyExpired(b));
- }, [projectIamPolicy, projectName]);
-
const canSetIamPolicy = project
? !isDefaultProject(project.name) &&
project.state !== State.DELETED &&
@@ -1974,26 +1936,14 @@ export function MembersPage({ projectId }: { projectId?: string }) {
value={memberViewTab}
onValueChange={(v) => setMemberViewTab(v as "MEMBERS" | "ROLES")}
>
- <div className="flex items-center justify-between gap-x-4 border-b border-control-border">
- <TabsList className="border-b-0">
- <TabsTrigger value="MEMBERS">
- {t("settings.members.view-by-members")}
- </TabsTrigger>
- <TabsTrigger value="ROLES">
- {t("settings.members.view-by-roles")}
- </TabsTrigger>
- </TabsList>
- {hasExpiredProjectRoles && (
- <label className="flex items-center gap-x-2 text-sm cursor-pointer pb-2">
- <input
- type="checkbox"
- checked={showExpiredRoles}
- onChange={(e) => setShowExpiredRoles(e.target.checked)}
- />
- {t("project.members.show-expired-roles")}
- </label>
- )}
- </div>
+ <TabsList>
+ <TabsTrigger value="MEMBERS">
+ {t("settings.members.view-by-members")}
+ </TabsTrigger>
+ <TabsTrigger value="ROLES">
+ {t("settings.members.view-by-roles")}
+ </TabsTrigger>
+ </TabsList>
<TabsPanel value="MEMBERS">
<div className="py-4">
<MemberTable
@@ -2004,7 +1954,6 @@ export function MembersPage({ projectId }: { projectId?: string }) {
onUpdateBinding={handleMemberUpdateBinding}
onRevokeBinding={handleMemberRevokeBinding}
scope={scope}
- showExpiredRoles={showExpiredRoles}
/>
</div>
</TabsPanel>
@@ -2016,7 +1965,6 @@ export function MembersPage({ projectId }: { projectId?: string }) {
onUpdateBinding={handleMemberUpdateBinding}
onRevokeBinding={handleMemberRevokeBinding}
scope={scope}
- showExpiredRoles={showExpiredRoles}
/>
</div>
</TabsPanel>