Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(frontend): custom role title (#5681)
Liu Jiafc511247ebc
diff --git a/frontend/src/components/Project/ProjectSetting/ProjectMemberTable/PrincipalTable.vue b/frontend/src/components/Project/ProjectSetting/ProjectMemberTable/PrincipalTable.vueindex 98e13966b8..06cf729a46 100644--- a/frontend/src/components/Project/ProjectSetting/ProjectMemberTable/PrincipalTable.vue+++ b/frontend/src/components/Project/ProjectSetting/ProjectMemberTable/PrincipalTable.vue@@ -30,7 +30,7 @@:closable="allowRemoveRole(role)"@close="removeRole(item, role)">- {{ roleNameText(extractRoleResourceName(role)) }}+ {{ displayRoleTitle(role) }}</NTag><NPopselectv-if="allowAddRole(item)"@@ -96,10 +96,9 @@ import {useUserStore,} from "@/store";import {- extractRoleResourceName,hasPermissionInProject,hasWorkspacePermission,- roleNameText,+ displayRoleTitle,addRoleToProjectIamPolicy,removeRoleFromProjectIamPolicy,removeUserFromProjectIamPolicy,@@ -242,7 +241,7 @@ const allowRemoveRole = (role: ProjectRoleType) => {const removeRole = (item: ComposedPrincipal, role: string) => {const title = t("project.settings.members.revoke-role-from-user", {- role: roleNameText(extractRoleResourceName(role)),+ role: displayRoleTitle(role),user: item.principal.name,});const d = dialog.error({@@ -277,9 +276,8 @@ const getRoleOptions = (item: ComposedPrincipal) => {return roleStore.roleList.filter((role) => !item.roleList.includes(role.name)).map<SelectOption>((role) => {- const name = extractRoleResourceName(role.name);return {- label: roleNameText(name),+ label: displayRoleTitle(role.name),value: role.name,};});diff --git a/frontend/src/components/Role/Setting/components/RolePanel.vue b/frontend/src/components/Role/Setting/components/RolePanel.vueindex 516358f734..09a48c7cda 100644--- a/frontend/src/components/Role/Setting/components/RolePanel.vue+++ b/frontend/src/components/Role/Setting/components/RolePanel.vue@@ -10,38 +10,32 @@:closable="true"class="w-[30rem] max-w-[100vw] relative">- <div- class="flex flex-col gap-y-4"- style="grid-template-columns: auto 1fr"- >+ <div class="flex flex-col gap-y-4"><div class="flex flex-col gap-y-2"><div class="textlabel">- {{ $t("common.name") }}+ {{ $t("role.title") }}<span class="ml-0.5 text-error">*</span></div>- <div class="flex flex-col gap-y-2">+ <div><NInput- v-model:value="readableName"- :placeholder="$t('role.setting.name-placeholder')"- :disabled="mode === 'EDIT'"- :status="errors.name?.length ? 'error' : undefined"+ v-model:value="state.role.title"+ :placeholder="$t('role.setting.title-placeholder')"+ :status="state.role.title?.length === 0 ? 'error' : undefined"/>- <div- v-if="mode === 'ADD' && !readableName"- class="text-sm text-warning"- >- {{ $t("resource-id.cannot-be-changed-later") }}- </div>- <div- v-for="(err, i) in errors.name"- :key="i"- class="text-sm text-error"- >- {{ err }}- </div></div></div>+ <ResourceIdField+ ref="resourceIdField"+ v-model:value="resourceId"+ resource-type="role"+ :resource-title="state.role.title"+ :suffix="true"+ :readonly="mode === 'EDIT'"+ :validate="validateResourceId"+ class="flex flex-col gap-y-2"+ />+<div class="flex flex-col gap-y-2"><div class="textlabel">{{ $t("common.description") }}</div><div>@@ -75,18 +69,16 @@</template><script setup lang="ts">-import { computed, reactive, watch, nextTick } from "vue";+import { computed, reactive, watch, nextTick, ref } from "vue";import { useI18n } from "vue-i18n";import { cloneDeep } from "lodash-es";import { NButton, NDrawer, NDrawerContent, NInput } from "naive-ui";import { Role } from "@/types/proto/v1/role_service";-import { extractRoleResourceName } from "@/utils";+import { ResourceIdField } from "@/components/v2";import { pushNotification, useRoleStore } from "@/store";--type ValidationErrors<T> = Partial<{- [K in keyof T]: string[];-}>;+import { extractRoleResourceName } from "@/utils";+import { ValidatedMessage } from "@/types";type LocalState = {role: Role;@@ -103,8 +95,8 @@ const emit = defineEmits<{(event: "close"): void;}>();-const RESOURCE_ID_PATTERN = /^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$/;const { t } = useI18n();+const resourceIdField = ref<InstanceType<typeof ResourceIdField>>();const store = useRoleStore();const state = reactive<LocalState>({role: Role.fromJSON({}),@@ -112,68 +104,21 @@ const state = reactive<LocalState>({loading: false,});-const readableName = computed({+const resourceId = computed({get() {return extractRoleResourceName(state.role.name);},- set(name) {- state.role.name = `roles/${name}`;+ set(value) {+ state.role.name = `roles/${value}`;},});-const errors = computed(() => {- const errors: ValidationErrors<Role> = {- name: [],- };- const { role, dirty } = state;- if (dirty) {- if (!readableName.value) {- errors.name?.push(- t("role.setting.validation.required", {- resource: t("common.name"),- })- );- } else {- if (role.name !== props.role?.name) {- const roleList = store.roleList;- if (roleList.findIndex((r) => r.name === role.name) >= 0) {- errors.name?.push(- t("role.setting.validation.duplicated", {- resource: t("common.name"),- })- );- }- if (readableName.value.length > 64) {- errors.name?.push(- t("role.setting.validation.max-length", {- length: 64,- resource: t("common.name"),- })- );- }- if (!RESOURCE_ID_PATTERN.test(readableName.value)) {- errors.name?.push(- t("role.setting.validation.pattern", {- resource: t("common.name"),- })- );- }- }- }- }-- return errors;-});-const allowSave = computed(() => {if (!state.dirty) return false;- const keys = Object.keys(errors.value) as (keyof Role)[];- if (- keys.some((key) => {- return errors.value[key]?.length ?? 0 > 0;- })- ) {- return false;+ if (state.role.title?.length === 0) return false;+ if (resourceIdField.value) {+ if (!resourceIdField.value.resourceId) return false;+ if (!resourceIdField.value.isValidated) return false;}return true;});@@ -193,11 +138,30 @@ const handleSave = async () => {}};+const validateResourceId = async (+ name: string+): Promise<ValidatedMessage[]> => {+ if (store.roleList.find((r) => r.name === `roles/${name}`)) {+ return [+ {+ type: "error",+ message: t("resource-id.validation.duplicated", {+ resource: t("role.self"),+ }),+ },+ ];+ }+ return [];+};+watch(() => props.role,() => {if (props.role) {state.role = cloneDeep(props.role);+ if (!state.role.title) {+ state.role.title = extractRoleResourceName(state.role.name);+ }}nextTick(() => {state.dirty = false;diff --git a/frontend/src/components/Role/Setting/components/RoleTable.vue b/frontend/src/components/Role/Setting/components/RoleTable.vueindex 631f57ee56..8a7f08f9b5 100644--- a/frontend/src/components/Role/Setting/components/RoleTable.vue+++ b/frontend/src/components/Role/Setting/components/RoleTable.vue@@ -35,7 +35,7 @@ const { t } = useI18n();const COLUMNS = computed((): BBGridColumn[] => {return [{- title: t("common.name"),+ title: t("role.title"),width: "minmax(auto, 1fr)",},{diff --git a/frontend/src/components/Role/Setting/components/RoleTableRow.vue b/frontend/src/components/Role/Setting/components/RoleTableRow.vueindex a02f166908..8c4dd02c8c 100644--- a/frontend/src/components/Role/Setting/components/RoleTableRow.vue+++ b/frontend/src/components/Role/Setting/components/RoleTableRow.vue@@ -1,10 +1,10 @@<template><div class="bb-grid-cell whitespace-nowrap">- {{ extractRoleResourceName(role.name) }}+ {{ title }}</div><div class="bb-grid-cell">- {{ role.description }}+ {{ description }}</div><div class="bb-grid-cell gap-x-1"><template v-if="allowEdit">@@ -26,9 +26,10 @@<script lang="ts" setup>import { computed } from "vue";import { NButton } from "naive-ui";+import { useI18n } from "vue-i18n";import type { Role } from "@/types/proto/v1/role_service";-import { extractRoleResourceName, useWorkspacePermission } from "@/utils";+import { useWorkspacePermission } from "@/utils";import { SpinnerButton } from "@/components/v2";import { useRoleStore } from "@/store";@@ -40,6 +41,22 @@ defineEmits<{(event: "edit", role: Role): void;}>();+const { t } = useI18n();++const description = computed(() => {+ const { role } = props;+ if (role.name === "roles/OWNER") return t("role.owner.description");+ if (role.name === "roles/DEVELOPER") return t("role.developer.description");+ return role.description;+});++const title = computed(() => {+ const { role } = props;+ if (role.name === "roles/OWNER") return t("common.role.owner");+ if (role.name === "roles/DEVELOPER") return t("common.role.developer");+ return role.title;+});+const allowAdmin = useWorkspacePermission("bb.permission.workspace.manage-general");diff --git a/frontend/src/components/v2/Form/ResourceIdField.vue b/frontend/src/components/v2/Form/ResourceIdField.vuenew file mode 100644index 0000000000..5492e04ecd--- /dev/null+++ b/frontend/src/components/v2/Form/ResourceIdField.vue@@ -0,0 +1,257 @@+<template>+ <div v-if="visible">+ <template v-if="readonly || !state.manualEdit">+ <div v-if="state.resourceId" class="textinfolabel text-sm">+ {{ $t("resource-id.self", { resource: resourceName }) }}:+ <span class="text-gray-600 font-medium mr-1">{{+ state.resourceId+ }}</span>+ <template v-if="!readonly">+ {{ $t("resource-id.cannot-be-changed-later") }}+ <span+ class="text-accent font-medium cursor-pointer hover:opacity-80"+ @click="state.manualEdit = true"+ >+ {{ $t("common.edit") }}+ </span>+ </template>+ </div>+ </template>+ <template v-else>+ <label for="name" class="textlabel">+ {{ $t("resource-id.self", { resource: resourceName }) }}+ <span class="ml-0.5 text-error">*</span>+ </label>+ <div class="textinfolabel">+ {{ $t("resource-id.description", { resource: resourceName }) }}+ </div>+ <NInput+ :value="state.resourceId"+ :status="inputStatus"+ v-bind="inputProps"+ @update:value="handleResourceIdInput($event)"+ />+ </template>+ <ul+ v-if="state.validatedMessages.length > 0"+ class="w-full my-2 space-y-2 list-disc list-outside pl-4"+ >+ <li+ v-for="validateMessage in state.validatedMessages"+ :key="validateMessage.message"+ class="break-words w-full text-xs"+ :class="[+ validateMessage.type === 'warning' && 'text-yellow-600',+ validateMessage.type === 'error' && 'text-red-600',+ ]"+ >+ {{ validateMessage.message }}+ </li>+ </ul>+ </div>+</template>++<script lang="ts" setup>+import { computed, reactive, watch } from "vue";+import { useI18n } from "vue-i18n";+import { NInput, type InputProps } from "naive-ui";++import type { ResourceId, ValidatedMessage } from "@/types";+import { randomString } from "@/utils";++// characters is the validated characters for resource id.+const characters = "abcdefghijklmnopqrstuvwxyz1234567890-";++// randomCharacter returns a random character from the english alphabet.+const randomCharacter = (ch?: string): string => {+ const characters = "abcdefghijklmnopqrstuvwxyz";+ const index = ch+ ? ch.charCodeAt(0) % characters.length+ : Math.floor(Math.random() * characters.length);+ return characters.charAt(index);+};++const resourceIdPattern = /^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$/;++interface LocalState {+ resourceId: string;+ manualEdit: boolean;+ validatedMessages: ValidatedMessage[];+}++type ResourceType = "environment" | "instance" | "project" | "idp" | "role";++const props = withDefaults(+ defineProps<{+ value?: string;+ resourceType: ResourceType;+ resourceTitle?: string;+ suffix?: boolean;+ readonly?: boolean;+ inputProps?: Partial<InputProps>;+ validate?: (resourceId: ResourceId) => Promise<ValidatedMessage[]>;+ }>(),+ {+ value: "",+ resourceTitle: "",+ suffix: false,+ readonly: false,+ inputProps: undefined,+ validate: () => Promise.resolve([]),+ }+);++const emit = defineEmits<{+ (event: "update:value", value: string): void;+}>();++const { t } = useI18n();+const state = reactive<LocalState>({+ resourceId: props.value,+ manualEdit: false,+ validatedMessages: [],+});+// Won't change after the component instance initialized.+const randomSuffix = randomString(4).toLowerCase();++const resourceName = computed(() => {+ return t(`resource.${props.resourceType}`);+});++const visible = computed(() => {+ if (props.readonly || !state.manualEdit) {+ return !!state.resourceId;+ }+ return true;+});++const prefix = computed(() => {+ const { resourceType: resource } = props;+ switch (resource) {+ case "environment":+ return "env";+ case "instance":+ return "ins";+ case "project":+ return "proj";+ default:+ return resource;+ }+});++const inputStatus = computed(() => {+ const { validatedMessages } = state;+ if (validatedMessages.some((m) => m.type === "error")) return "error";+ if (validatedMessages.some((m) => m.type === "warning")) return "warning";+ return undefined;+});++const handleResourceIdInput = (newValue: string) => {+ if (!state.manualEdit) {+ return;+ }++ state.validatedMessages = [];+ handleResourceIdChange(newValue);+};++const handleResourceIdChange = async (newValue: string) => {+ state.resourceId = newValue;+ state.validatedMessages = [];++ emit("update:value", newValue);++ // if the resource id is empty, do not validate.+ if (newValue === "" && !state.manualEdit) {+ return;+ }++ // common validation for resource id (min length, max length, pattern).+ if (state.resourceId.length < 1) {+ state.validatedMessages.push({+ type: "error",+ message: t("resource-id.validation.minlength", {+ resource: resourceName.value,+ }),+ });+ } else if (state.resourceId.length > 64) {+ state.validatedMessages.push({+ type: "error",+ message: t("resource-id.validation.overflow", {+ resource: resourceName.value,+ }),+ });+ } else if (!resourceIdPattern.test(state.resourceId)) {+ state.validatedMessages.push({+ type: "error",+ message: t("resource-id.validation.pattern", {+ resource: resourceName.value,+ }),+ });+ }++ // custom validation for resource id. (e.g. check if the resource id is already used)+ if (props.validate) {+ const messages = await props.validate(state.resourceId);+ state.validatedMessages.push(...messages);+ }+};++watch(+ () => props.value,+ (newValue) => {+ state.resourceId = newValue;+ }+);++const escape = (str: string) => {+ return str+ .toLowerCase()+ .split("")+ .map((char) => {+ if (char.match(/\s/)) return "";+ if (characters.includes(char)) return char;+ return randomCharacter(char);+ })+ .join("")+ .toLowerCase();+};++watch(+ () => props.resourceTitle,+ (resourceTitle) => {+ if (props.readonly) {+ return;+ }+ if (state.manualEdit) {+ return;+ }++ // If we are not in manual edit mode, update the auto-generated resource id+ // according to resource title.+ const parts: string[] = [];+ if (resourceTitle) {+ const escapedTitle = escape(resourceTitle);+ if (props.suffix) {+ parts.push(prefix.value, escapedTitle, randomSuffix);+ } else if (escapedTitle) {+ parts.push(escapedTitle);+ } else {+ parts.push(randomString(4).toLowerCase());+ }+ }+ const name = parts.join("-");+ handleResourceIdChange(name);+ },+ {+ immediate: true,+ }+);++defineExpose({+ resourceId: computed(() => state.resourceId),+ isValidated: computed(() => {+ return state.validatedMessages.length === 0;+ }),+});+</script>diff --git a/frontend/src/components/v2/Form/index.ts b/frontend/src/components/v2/Form/index.tsindex c9307d26aa..6f9c127d0b 100644--- a/frontend/src/components/v2/Form/index.ts+++ b/frontend/src/components/v2/Form/index.ts@@ -1,5 +1,6 @@import SpinnerSwitch from "./SpinnerSwitch.vue";import SpinnerButton from "./SpinnerButton.vue";import SearchBox from "./SearchBox.vue";+import ResourceIdField from "./ResourceIdField.vue";-export { SpinnerSwitch, SpinnerButton, SearchBox };+export { SpinnerSwitch, SpinnerButton, SearchBox, ResourceIdField };diff --git a/frontend/src/components/v2/Select/ProjectRolesSelect.vue b/frontend/src/components/v2/Select/ProjectRolesSelect.vueindex 27e5ac72d4..3901f0765c 100644--- a/frontend/src/components/v2/Select/ProjectRolesSelect.vue+++ b/frontend/src/components/v2/Select/ProjectRolesSelect.vue@@ -14,8 +14,8 @@ import { computed } from "vue";import { type SelectOption, NSelect } from "naive-ui";import { useRoleStore } from "@/store";-import { extractRoleResourceName, roleNameText } from "@/utils";import { ProjectRoleType } from "@/types";+import { displayRoleTitle } from "@/utils";defineProps<{roleList: ProjectRoleType[];@@ -27,9 +27,8 @@ defineEmits<{const roleOptions = computed(() => {return useRoleStore().roleList.map<SelectOption>((role) => {- const readableName = extractRoleResourceName(role.name);return {- label: roleNameText(readableName),+ label: displayRoleTitle(role.name),value: role.name,};});diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex acadf866bc..f4fb007750 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -2047,7 +2047,8 @@"environment": "Environment","instance": "Instance","project": "Project",- "idp": "Identity Provider"+ "idp": "Identity Provider",+ "role": "Role"},"resource-id": {"self": "{resource} ID",@@ -2329,10 +2330,12 @@"select": "Select user"},"role": {+ "self": "Role","setting": {"description": "Defining custom roles, and you may apply them to project members.","add": "Add role","edit": "Edit role",+ "title-placeholder": "Input role title","name-placeholder": "Input role name","description-placeholder": "Input role description","validation": {@@ -2344,6 +2347,13 @@"delete": "Delete role"},"select": "Select role",- "select-roles": "Select roles"+ "select-roles": "Select roles",+ "title": "Title",+ "owner": {+ "description": "System defined project owner role"+ },+ "developer": {+ "description": "System defined project developer role"+ }}}diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 86f98efa90..9be865cfe5 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -2046,14 +2046,15 @@"environment": "环境","instance": "实例","project": "项目",- "idp": "身份提供商"+ "idp": "身份提供商",+ "role": "角色"},"resource-id": {"self": "{resource} ID","description": "{resource} ID 是一个唯一的标识符。创建之后无法修改。","cannot-be-changed-later": "创建之后无法修改。","validation": {- "duplicate": "{resource} ID 已存在。请使用其他 ID。",+ "duplicated": "{resource} ID 已存在。请使用其他 ID。","pattern": "{resource} ID 只能包含小写字母、数字和连字符。它必须以一个小写字母开头。","minlength": "{resource} ID 至少包含 1 个字符。","overflow": "{resource} ID 应该少于 64 个字符。"@@ -2326,11 +2327,13 @@"select": "选择用户"},"role": {+ "self": "角色","setting": {"description": "定义自定义角色,你可以将它们应用到项目成员上。","add": "添加角色","edit": "编辑角色","name-placeholder": "输入角色名称",+ "title-placeholder": "输入角色称谓","description-placeholder": "输入角色描述","validation": {"duplicated": "{resource}已存在",@@ -2341,6 +2344,13 @@"delete": "删除角色"},"select": "选择角色",- "select-roles": "选择角色"+ "select-roles": "选择角色",+ "title": "称谓",+ "owner": {+ "description": "系统定义的项目所有者角色"+ },+ "developer": {+ "description": "系统定义的项目开发者角色"+ }}}diff --git a/frontend/src/store/modules/role.ts b/frontend/src/store/modules/role.tsindex 772ec839e8..6f2c48f41e 100644--- a/frontend/src/store/modules/role.ts+++ b/frontend/src/store/modules/role.ts@@ -4,6 +4,7 @@ import { defineStore } from "pinia";import { Role } from "@/types/proto/v1/role_service";import { roleServiceClient } from "@/grpcweb";import { extractRoleResourceName } from "@/utils";+import { useGracefulRequest } from "./utils";export const useRoleStore = defineStore("role", () => {const roleList = ref<Role[]>([]);@@ -20,7 +21,7 @@ export const useRoleStore = defineStore("role", () => {// updateconst updated = await roleServiceClient.updateRole({role,- updateMask: ["description"],+ updateMask: ["title", "description"],});Object.assign(existedRole, updated);} else {@@ -35,13 +36,15 @@ export const useRoleStore = defineStore("role", () => {};const deleteRole = async (role: Role) => {- await roleServiceClient.deleteRole({- name: role.name,+ await useGracefulRequest(async () => {+ await roleServiceClient.deleteRole({+ name: role.name,+ });+ const index = roleList.value.findIndex((r) => r.name === role.name);+ if (index >= 0) {+ roleList.value.splice(index, 1);+ }});- const index = roleList.value.findIndex((r) => r.name === role.name);- if (index >= 0) {- roleList.value.splice(index, 1);- }};return {diff --git a/frontend/src/store/modules/utils.ts b/frontend/src/store/modules/utils.tsindex 3e0232effa..bc90c7bcde 100644--- a/frontend/src/store/modules/utils.ts+++ b/frontend/src/store/modules/utils.ts@@ -5,6 +5,9 @@ import {ResourceObject,ResponseWithData,} from "@/types";+import { pushNotification } from "./notification";+import { t } from "@/plugins/i18n";+import { ClientError } from "nice-grpc-web";type ConvertEntityFn<T> = (data: ResourceObject,@@ -40,3 +43,23 @@ export function convertEntityList<T, K extends string>(return convert(obj, responseData.included ?? []);});}++export const useGracefulRequest = async <T>(+ fn: () => Promise<T>+): Promise<T> => {+ try {+ const result = await fn();+ return result;+ } catch (err) {+ const description = err instanceof ClientError ? err.details : String(err);+ if (err instanceof ClientError) {+ pushNotification({+ module: "bytebase",+ style: "CRITICAL",+ title: t("common.error"),+ description,+ });+ }+ throw err;+ }+};diff --git a/frontend/src/types/utils.ts b/frontend/src/types/utils.tsindex c19516f72e..7b6e68d30d 100644--- a/frontend/src/types/utils.ts+++ b/frontend/src/types/utils.ts@@ -2,3 +2,8 @@ import { Ref } from "vue";export type SubsetOf<T, S extends T> = S;export type MaybeRef<T> = Ref<T> | T;++export type ValidatedMessage = {+ type: "warning" | "error";+ message: string;+};diff --git a/frontend/src/utils/role.ts b/frontend/src/utils/role.tsindex ddd80122fe..dfe32d4de1 100644--- a/frontend/src/utils/role.ts+++ b/frontend/src/utils/role.ts@@ -1,7 +1,7 @@import { computed, unref } from "vue";import { MaybeRef, ProjectRoleType, RoleType } from "../types";-import { hasFeature, useCurrentUser } from "@/store";-import { t, te } from "@/plugins/i18n";+import { hasFeature, useCurrentUser, useRoleStore } from "@/store";+import { t } from "@/plugins/i18n";export type WorkspacePermissionType =| "bb.permission.workspace.debug"@@ -180,11 +180,12 @@ export const extractRoleResourceName = (resourceId: string): string => {return matches?.[1] ?? "";};-export const roleNameText = (name: string): string => {- const keypath = `common.role.${name.toLowerCase()}`;-- if (te(keypath)) {- return t(keypath);- }- return name;+export const displayRoleTitle = (role: string): string => {+ // Use i18n-defined readable titles for system roles+ if (role === "roles/OWNER") return t("common.role.owner");+ if (role === "roles/DEVELOPER") return t("common.role.developer");+ // Use role.title if possible+ const item = useRoleStore().roleList.find((r) => r.name === role);+ // Fallback to extracted resource name otherwise+ return item?.title || extractRoleResourceName(role);};diff --git a/frontend/src/utils/workspaceApprovalSetting.ts b/frontend/src/utils/workspaceApprovalSetting.tsindex 458794b627..31a0aba34d 100644--- a/frontend/src/utils/workspaceApprovalSetting.ts+++ b/frontend/src/utils/workspaceApprovalSetting.ts@@ -37,7 +37,7 @@ import {resolveCELExpr,SimpleExpr,} from "@/plugins/cel";-import { extractRoleResourceName, roleNameText } from "./role";+import { displayRoleTitle } from "./role";export const approvalNodeGroupValueText = (group: ApprovalNode_GroupValue) => {const name = approvalNode_GroupValueToJSON(group);@@ -49,7 +49,7 @@ export const approvalNodeGroupValueText = (group: ApprovalNode_GroupValue) => {};export const approvalNodeRoleText = (role: string) => {- return roleNameText(extractRoleResourceName(role));+ return displayRoleTitle(role);};export const approvalNodeText = (node: ApprovalNode): string => {