Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions ui/src/components/COMPONENT_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,7 @@ JSON 专用输入框,通过 `v-model` 接收并回传解析后的 JSON 值,
局部变量使用 camelCase,模板属性使用 kebab-case。`input_type`、`default_value`、
`visibility_rules` 等服务端字段协议保持 snake_case,不在组件边界内改名。

公开入口包括 `dynamicFormTypeOptions`,其中 `label` 保存 `dynamicForm.types.*` 翻译键,由使用处通过 `t()` 获取显示文案;
`FormItem.vue`、`FormItemLabel.vue`、`items/` 和配置器子目录均为内部实现。
公开入口包括 `dynamicFormTypeOptions`;`FormItem.vue`、`FormItemLabel.vue`、`items/` 和配置器子目录均为内部实现。

`MkDynamicsForm` 的主要 Props 为 `modelValue`、`renderData`、`otherParams`、`view`、
`defaultItemWidth` 和 `parentField`,公开 `validate()`、`render()`、`initDefaultData()` 与
Expand Down
63 changes: 24 additions & 39 deletions ui/src/components/business/related-resources-drawer/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n'
import { computed, onBeforeUnmount, ref } from 'vue'
import { cloneDeep } from 'lodash'
import type RelatedResourcesApi from '@/api/admin/workspace/related-resources'
Expand All @@ -12,8 +11,6 @@ import type { Dict, ModelProviderItem, OptionItem, RelatedResource, ResourceType
import ResourceIcon from './ResourceIcon.vue'
import type { RelatedResourceTarget } from './types'

const { t } = useI18n({ useScope: 'global' })

defineOptions({ name: 'RelatedResourcesDrawer' })
const props = defineProps<{
api: typeof RelatedResourcesApi
Expand All @@ -27,20 +24,20 @@ const visible = ref(false)
const resourceType = ref<ResourceType>(RESOURCE_TYPE.APPLICATION)
const targetResource = ref<RelatedResourceTarget>()
const resourceLabels = {
[RESOURCE_TYPE.APPLICATION]: 'system.identity.resourceAuthorization.resourceTypes.application',
[RESOURCE_TYPE.KNOWLEDGE]: 'system.identity.resourceAuthorization.resourceTypes.knowledge',
[RESOURCE_TYPE.TOOL]: 'system.identity.resourceAuthorization.resourceTypes.tool',
[RESOURCE_TYPE.MODEL]: 'system.identity.resourceAuthorization.resourceTypes.model',
[RESOURCE_TYPE.APPLICATION]: '智能体',
[RESOURCE_TYPE.KNOWLEDGE]: '知识库',
[RESOURCE_TYPE.TOOL]: '工具',
[RESOURCE_TYPE.MODEL]: '模型',
}
const resourceTypeOptions = computed(() => Object.entries(resourceLabels).map(([value, label]) => ({ value, label: t(label) })))
const searchFields = computed(() => [
{ label: t('common.fields.name'), value: 'resource_name' },
{ label: t('common.fields.creator'), value: 'user_name' },
])
const relationTabs = computed(() => [
{ value: 'dependency', label: t('components.relatedResources.dependencies') },
{ value: 'dependent', label: t('components.relatedResources.dependents') },
])
const resourceTypeOptions = Object.entries(resourceLabels).map(([value, label]) => ({ value, label }))
const searchFields = [
{ label: '名称', value: 'resource_name' },
{ label: '创建者', value: 'user_name' },
]
const relationTabs = [
{ value: 'dependency', label: '依赖' },
{ value: 'dependent', label: '被依赖' },
]
const relationDirection = ref<'dependency' | 'dependent'>('dependency')

/* 分页查询:两个关系方向共用表格,仅转换关系字段。 */
Expand Down Expand Up @@ -144,10 +141,10 @@ defineExpose({ open, close })
</script>

<template>
<MkDrawer v-model="visible" :title="t('common.actions.relatedResources')" size="60%" @closed="handleClosed">
<MkDrawer v-model="visible" title="查看关联资源" size="60%" @closed="handleClosed">
<template v-if="targetResource">
<div class="flex-align-center mb-4">
<span class="mr-4 mk-N600!">{{ t(resourceLabels[resourceType]) }}</span>
<span class="mr-4 mk-N600!">{{ resourceLabels[resourceType] }}</span>

<ResourceIcon
:resource-type="resourceType"
Expand All @@ -159,7 +156,7 @@ defineExpose({ open, close })
<span class="ml-2">{{ targetResource.name }}</span>
</div>

<h4 class="mk-title-decoration mb-4">{{ t('components.relatedResources.title') }}</h4>
<h4 class="mk-title-decoration mb-4">关联资源</h4>

<div class="flex-between gap-3">
<el-radio-group v-model="relationDirection" @change="changeDirection">
Expand All @@ -177,7 +174,7 @@ defineExpose({ open, close })
@current-change="loadResources"
@size-change="loadResources"
>
<el-table-column prop="name" :label="t('common.fields.name')" min-width="160" show-overflow-tooltip>
<el-table-column prop="name" label="名称" min-width="160" show-overflow-tooltip>
<template #default="{ row }">
<!-- // TODO: 资源跳转 -->
<div class="flex-align-center gap-2">
Expand All @@ -186,38 +183,26 @@ defineExpose({ open, close })
</div>
</template>
</el-table-column>
<el-table-column prop="desc" :label="t('common.fields.description')" min-width="160" show-overflow-tooltip />
<el-table-column :label="t('common.fields.type')" min-width="100">
<el-table-column prop="desc" label="描述" min-width="160" show-overflow-tooltip />
<el-table-column label="类型" min-width="100">
<template #header>
<MkTableFilter
mode="single"
v-model="selectedResourceType"
:label="t('common.fields.type')"
:options="resourceTypeOptions"
@change="handleFilterChange"
/>
<MkTableFilter mode="single" v-model="selectedResourceType" label="类型" :options="resourceTypeOptions" @change="handleFilterChange" />
</template>
<template #default="{ row }">{{ t(resourceLabels[row.resourceType as ResourceType]) }}</template>
<template #default="{ row }">{{ resourceLabels[row.resourceType as ResourceType] }}</template>
</el-table-column>
<el-table-column
v-if="showWorkspace"
prop="workspace_name"
:label="t('system.identity.workspaces.label')"
min-width="140"
show-overflow-tooltip
>
<el-table-column v-if="showWorkspace" prop="workspace_name" label="工作空间" min-width="140" show-overflow-tooltip>
<template #header>
<!-- 筛选关联资源所属工作空间 -->
<MkTableFilter
mode="multiple"
v-model="selectedWorkspaceIds"
:label="t('system.identity.workspaces.label')"
label="工作空间"
:options="workspaceOptions"
@change="handleFilterChange"
/>
</template>
</el-table-column>
<el-table-column prop="username" :label="t('common.fields.creator')" min-width="100" show-overflow-tooltip />
<el-table-column prop="username" label="创建者" min-width="100" show-overflow-tooltip />
</MkTable>
</template>
</MkDrawer>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n'
import { ref } from 'vue'
import type { ResourcePermission } from '@/api/types'

import type { ResourcePermissionOption } from './types'

const { t } = useI18n({ useScope: 'global' })

const props = defineProps<{
options: ResourcePermissionOption[]
isFolder: boolean
Expand Down Expand Up @@ -46,30 +43,26 @@ defineExpose({ open, close })
</script>

<template>
<MkDialog
v-model="visible"
:title="scopeOnly ? t('components.resourceAuthorization.effectiveResources') : t('system.identity.resourceAuthorization.configure')"
@closed="resetData"
>
<MkDialog v-model="visible" :title="scopeOnly ? '生效资源' : '配置权限'" @closed="resetData">
<el-radio-group v-if="!scopeOnly" v-model="permission" class="mk-radio-group-vertical" :disabled="loading">
<el-radio v-for="option in options" :key="option.value" :value="option.value">
<p>{{ t(option.label) }}</p>
<p v-if="option.description" class="mt-1 text-N500">{{ t(option.description) }}</p>
<p>{{ option.label }}</p>
<p v-if="option.description" class="mt-1 text-N500">{{ option.description }}</p>
</el-radio>
</el-radio-group>
<div v-if="isFolder">
<div v-if="!scopeOnly">
<el-divider class="my-4!" />
<h6 class="mb-2">{{ t('components.resourceAuthorization.effectiveResources') }}</h6>
<h6 class="mb-2">生效资源</h6>
</div>
<el-radio-group v-model="includeChildren" class="mk-radio-group-vertical" :disabled="loading">
<el-radio :value="false">{{ t('components.resourceAuthorization.currentResourceOnly') }}</el-radio>
<el-radio :value="true" :disabled="!canIncludeChildren">{{ t('components.resourceAuthorization.includeChildFolders') }}</el-radio>
<el-radio :value="false">仅当前资源</el-radio>
<el-radio :value="true" :disabled="!canIncludeChildren">包含所有子文件夹</el-radio>
</el-radio-group>
</div>
<template #footer>
<el-button plain :disabled="loading" @click="close">{{ t('common.actions.cancel') }}</el-button>
<el-button type="primary" :loading="loading" :disabled="!permission" @click="handleSubmit">{{ t('common.actions.confirm') }}</el-button>
<el-button plain :disabled="loading" @click="close">取消</el-button>
<el-button type="primary" :loading="loading" :disabled="!permission" @click="handleSubmit">确认</el-button>
</template>
</MkDialog>
</template>
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n'
import { computed, onMounted, ref, useTemplateRef } from 'vue'
import { RESOURCE_PERMISSION } from '@/api/enums'
import { RESOURCE_PERMISSION_OPTIONS } from '@/constants/resource-authorization'
Expand All @@ -10,8 +9,6 @@ import type ResourceAuthorizationApi from '@/api/admin/workspace/resource-author
import type SystemResourceAuthorizationApi from '@/api/admin/system/resource-management/resource-authorization'
import type { ResourcePermissionOption } from './types'

const { t } = useI18n({ useScope: 'global' })

const props = defineProps<{
api: typeof ResourceAuthorizationApi | typeof SystemResourceAuthorizationApi
workspaceId: string
Expand All @@ -27,17 +24,12 @@ const canSelectNotAuth = computed(() => props.permissionOptions.some(({ value })

/* 查询与当前页选择 */
const { auth } = useStore()
const searchPermissionOptions = computed(() =>
RESOURCE_PERMISSION_OPTIONS.filter(({ value }) => !auth.isCE || value !== RESOURCE_PERMISSION.ROLE).map((option) => ({
...option,
label: t(option.label),
})),
)
const searchPermissionOptions = computed(() => RESOURCE_PERMISSION_OPTIONS.filter(({ value }) => !auth.isCE || value !== RESOURCE_PERMISSION.ROLE))
const searchFields = computed(() => [
{ label: t('system.identity.users.fields.name'), value: 'nick_name' },
{ label: t('system.identity.users.fields.username'), value: 'username' },
{ label: t('system.identity.resourceAuthorization.permission'), value: 'permission', multiple: true, options: searchPermissionOptions.value },
...(auth.isEE || auth.isPE ? [{ label: t('system.identity.roles.label'), value: 'role' }] : []),
{ label: '姓名', value: 'nick_name' },
{ label: '用户名', value: 'username' },
{ label: '权限', value: 'permission', multiple: true, options: searchPermissionOptions.value },
...(auth.isEE || auth.isPE ? [{ label: '角色', value: 'role' }] : []),
])
const loading = ref(false)
const permissionUsers = ref<ResourceUserPermission[]>([])
Expand Down Expand Up @@ -109,9 +101,7 @@ onMounted(() => loadPermissions())
<div>
<div class="flex-between mb-4 gap-4">
<!-- 批量配置权限 -->
<el-button type="primary" :disabled="!selectedUsers.length || loading || submitting" @click="handleOpenBatchConfig">
{{ t('system.identity.resourceAuthorization.configure') }}
</el-button>
<el-button type="primary" :disabled="!selectedUsers.length || loading || submitting" @click="handleOpenBatchConfig">配置权限</el-button>
<MkComplexSearch :fields="searchFields" @change="handleSearch" />
</div>
<MkTable
Expand All @@ -125,18 +115,18 @@ onMounted(() => loadPermissions())
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="40" />
<el-table-column prop="nick_name" :label="t('system.identity.users.fields.name')" min-width="120" show-overflow-tooltip />
<el-table-column prop="username" :label="t('system.identity.users.fields.username')" min-width="120" show-overflow-tooltip />
<el-table-column v-if="auth.isEE || auth.isPE" :label="t('system.identity.roles.label')" width="160">
<el-table-column prop="nick_name" label="姓名" min-width="120" show-overflow-tooltip />
<el-table-column prop="username" label="用户名" min-width="120" show-overflow-tooltip />
<el-table-column v-if="auth.isEE || auth.isPE" label="角色" width="160">
<template #default="{ row }">
<MkTagGroup v-if="row.role_name?.length" :tags="row.role_name" />
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column :label="t('system.identity.resourceAuthorization.permission')" min-width="340">
<el-table-column label="权限" min-width="340">
<template #default="{ row }">
<el-radio-group :model-value="row.permission" :disabled="submitting" @change="handlePermissionChange($event, row)">
<el-radio v-for="option in permissionOptions" :key="option.value" :value="option.value" class="mr-4!">{{ t(option.label) }}</el-radio>
<el-radio v-for="option in permissionOptions" :key="option.value" :value="option.value" class="mr-4!">{{ option.label }}</el-radio>
</el-radio-group>
</template>
</el-table-column>
Expand Down
18 changes: 4 additions & 14 deletions ui/src/components/business/resource-authorization-drawer/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n'
import { computed, ref, useTemplateRef } from 'vue'
import { cloneDeep } from 'lodash'
import ResourceAuthorizationApi from '@/api/admin/workspace/resource-authorization'
Expand All @@ -15,8 +14,6 @@ import PermissionConfigDialog from './PermissionConfigDialog.vue'
import UserAuthorization from './UserAuthorization.vue'
import UserGroupAuthorization from './user-group/UserGroupAuthorization.vue'

const { t } = useI18n({ useScope: 'global' })

defineOptions({ name: 'ResourceAuthorizationDrawer' })
const props = defineProps<{
type: ResourceAuthorizationTargetType
Expand Down Expand Up @@ -122,7 +119,7 @@ function submitPermissions(permission: ResourcePermission, includeChildren: bool
)
return request
.then(() => {
MsgSuccess(t('common.messages.submitted'))
MsgSuccess('提交成功')
configDialogRef.value?.close()
pendingSubjectIds.value = []
return authorizationRef?.refresh()
Expand Down Expand Up @@ -156,17 +153,10 @@ defineExpose({ open })
</script>

<template>
<MkDrawer
v-model="drawerVisible"
:title="t('common.actions.authorize')"
class="mk-drawer-with-tabs"
contentClass="pt-0"
:size="920"
@closed="handleClosed"
>
<MkDrawer v-model="drawerVisible" title="资源授权" class="mk-drawer-with-tabs" contentClass="pt-0" :size="920" @closed="handleClosed">
<el-tabs v-model="targetType" :before-leave="() => !submitting">
<el-tab-pane :label="t('system.identity.resourceAuthorization.byGroup')" name="user-group" />
<el-tab-pane :label="t('system.identity.resourceAuthorization.byUser')" name="user" />
<el-tab-pane label="按用户组" name="user-group" />
<el-tab-pane label="按用户" name="user" />
</el-tabs>
<div class="mt-6">
<UserGroupAuthorization
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n'
import { computed, onMounted, ref, useTemplateRef } from 'vue'
import type ResourceAuthorizationApi from '@/api/admin/workspace/resource-authorization'
import type SystemResourceAuthorizationApi from '@/api/admin/system/resource-management/resource-authorization'
Expand All @@ -10,8 +9,6 @@ import UserGroupMembersDrawer from './UserGroupMembersDrawer.vue'

import type { ResourcePermissionOption } from '../types'

const { t } = useI18n({ useScope: 'global' })

const props = defineProps<{
api: typeof ResourceAuthorizationApi | typeof SystemResourceAuthorizationApi
workspaceId: string
Expand All @@ -26,7 +23,7 @@ const emit = defineEmits<{ configure: [subjectIds: string[], permission?: Resour
const canSelectNotAuth = computed(() => props.permissionOptions.some(({ value }) => value === RESOURCE_PERMISSION.NOT_AUTH))

/* 查询与当前页选择 */
const searchFields = computed(() => [{ label: t('common.fields.name'), value: 'name' }])
const searchFields = [{ label: '名称', value: 'name' }]
const loading = ref(false)
const permissionGroups = ref<ResourceUserGroupPermission[]>([])
const selectedGroups = ref<ResourceUserGroupPermission[]>([])
Expand Down Expand Up @@ -106,9 +103,7 @@ onMounted(() => loadPermissions())
<div>
<div class="flex-between mb-4 gap-4">
<!-- 批量配置权限 -->
<el-button type="primary" :disabled="!selectedGroups.length || loading || submitting" @click="handleOpenBatchConfig">
{{ t('system.identity.resourceAuthorization.configure') }}
</el-button>
<el-button type="primary" :disabled="!selectedGroups.length || loading || submitting" @click="handleOpenBatchConfig">配置权限</el-button>
<MkComplexSearch :fields="searchFields" @change="handleSearch" />
</div>
<MkTable
Expand All @@ -122,16 +117,16 @@ onMounted(() => loadPermissions())
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="40" />
<el-table-column prop="name" :label="t('system.identity.groups.label')" min-width="160" show-overflow-tooltip />
<el-table-column :label="t('components.resourceAuthorization.memberCount')" min-width="100">
<el-table-column prop="name" label="用户组" min-width="160" show-overflow-tooltip />
<el-table-column label="成员数" min-width="100">
<template #default="{ row }">
<el-link type="primary" @click="handleOpenMembersDrawer(row)">{{ row.count }}</el-link>
</template>
</el-table-column>
<el-table-column :label="t('system.identity.resourceAuthorization.operationPermission')" min-width="340">
<el-table-column label="操作权限" min-width="340">
<template #default="{ row }">
<el-radio-group :model-value="row.permission" :disabled="submitting" @change="handlePermissionChange($event, row)">
<el-radio v-for="option in permissionOptions" :key="option.value" :value="option.value" class="mr-4!">{{ t(option.label) }}</el-radio>
<el-radio v-for="option in permissionOptions" :key="option.value" :value="option.value" class="mr-4!">{{ option.label }}</el-radio>
</el-radio-group>
</template>
</el-table-column>
Expand Down
Loading
Loading