mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 10:12:51 +00:00
fix: Resource authorization modify (#3326)
Co-authored-by: zhangzhanwei <zhanwei.zhang@fit2cloud.com>
This commit is contained in:
parent
63abffec3c
commit
a9d106ddd4
|
|
@ -28,19 +28,22 @@
|
|||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<el-dropdown-item class="border-t p-8" @click="openResetPassword">
|
||||
<el-dropdown-item class="border-t p-8" @click="openResetPassword"
|
||||
v-if="hasPermission([RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,PermissionConst.CHANGE_PASSWORD],'OR')"
|
||||
>
|
||||
{{ $t('views.login.resetPassword') }}
|
||||
</el-dropdown-item>
|
||||
<div
|
||||
v-hasPermission="
|
||||
new ComplexPermission([], [], [EditionConst.IS_EE, EditionConst.IS_PE], 'OR')
|
||||
"
|
||||
>
|
||||
<el-dropdown-item class="p-8" @click="openAPIKeyDialog">
|
||||
<div v-hasPermission="new ComplexPermission([], [], [EditionConst.IS_EE, EditionConst.IS_PE], 'OR')">
|
||||
<el-dropdown-item class="p-8" @click="openAPIKeyDialog"
|
||||
v-if="hasPermission([RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,PermissionConst.SYSTEM_API_KEY_EDIT],'OR')"
|
||||
>
|
||||
|
||||
{{ $t('layout.apiKey') }}
|
||||
</el-dropdown-item>
|
||||
</div>
|
||||
<el-dropdown-item style="padding: 0" @click.stop>
|
||||
<el-dropdown-item style="padding: 0" @click.stop
|
||||
v-if="hasPermission([RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,PermissionConst.SWITCH_LANGUAGE],'OR')"
|
||||
>
|
||||
<el-dropdown class="w-full" trigger="hover" placement="left-start">
|
||||
<div class="flex-between w-full" style="line-height: 22px; padding: 12px 11px">
|
||||
<span> {{ $t('layout.language') }}</span>
|
||||
|
|
@ -73,7 +76,9 @@
|
|||
</template>
|
||||
</el-dropdown>
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item @click="openAbout">
|
||||
<el-dropdown-item @click="openAbout"
|
||||
v-if="hasPermission([RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,PermissionConst.ABOUT_READ],'OR')"
|
||||
>
|
||||
{{ $t('layout.about.title') }}
|
||||
</el-dropdown-item>
|
||||
|
||||
|
|
@ -104,9 +109,10 @@ import ResetPassword from './ResetPassword.vue'
|
|||
import AboutDialog from './AboutDialog.vue'
|
||||
// import UserPwdDialog from '@/views/user-manage/component/UserPwdDialog.vue'
|
||||
import APIKeyDialog from './APIKeyDialog.vue'
|
||||
import { ComplexPermission } from '@/utils/permission/type'
|
||||
import { langList } from '@/locales/index'
|
||||
import { EditionConst } from '@/utils/permission/data'
|
||||
import {ComplexPermission} from '@/utils/permission/type'
|
||||
import {langList} from '@/locales/index'
|
||||
import { hasPermission } from '@/utils/permission'
|
||||
import { PermissionConst, RoleConst,EditionConst } from '@/utils/permission/data'
|
||||
|
||||
const { user, login } = useStore()
|
||||
const router = useRouter()
|
||||
|
|
|
|||
|
|
@ -160,10 +160,10 @@ const PermissionConst = {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SYSTEM_API_KEY_EDIT:new Permission('OTHER: READ+EDIT')
|
||||
ABOUT_READ:new Permission('OTHER:READ'),
|
||||
SWITCH_LANGUAGE:new Permission('OTHER:READ+EDIT'),
|
||||
CHANGE_PASSWORD:new Permission('OTHER:READ+CREATE'),
|
||||
SYSTEM_API_KEY_EDIT:new Permission('OTHER:READ+DELETE')
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -53,6 +53,22 @@ export class Permission {
|
|||
const { user } = useStore()
|
||||
return `${this.permission}:/WORKSPACE/${user.getWorkspaceId()}/${resource}/${resource_id}`
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param resource_id 资源id
|
||||
* @returns 工作空间下知识库资源权限
|
||||
*/
|
||||
getKnowledgeWorkspaceResourcePermission=( resource_id: string)=>{
|
||||
return this.getWorkspaceResourcePermission('KNOWLEDGE',resource_id)
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param resource_id 资源id
|
||||
* @returns 工作空间下应用资源权限
|
||||
*/
|
||||
getApplicationWorkspaceResourcePermission=( resource_id: string)=>{
|
||||
return this.getWorkspaceResourcePermission('APPLICATION',resource_id)
|
||||
}
|
||||
toString() {
|
||||
return this.permission
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,29 +6,19 @@
|
|||
<div class="resource-authorization__left border-r p-8">
|
||||
<div class="p-8">
|
||||
<h4 class="mb-12">{{ $t('views.resourceAuthorization.member') }}</h4>
|
||||
<el-input
|
||||
v-model="filterText"
|
||||
:placeholder="$t('common.search')"
|
||||
prefix-icon="Search"
|
||||
clearable
|
||||
/>
|
||||
<el-input v-model="filterText" :placeholder="$t('common.search')" prefix-icon="Search" clearable />
|
||||
</div>
|
||||
<div class="list-height-left">
|
||||
<el-scrollbar>
|
||||
<common-list
|
||||
:data="filterMember"
|
||||
class="mt-8"
|
||||
v-loading="loading"
|
||||
@click="clickMemberHandle"
|
||||
:default-active="currentUser"
|
||||
>
|
||||
<common-list :data="filterMember" class="mt-8" v-loading="loading" @click="clickMemberHandle"
|
||||
:default-active="currentUser">
|
||||
<template #default="{ row }">
|
||||
<div class="flex-between">
|
||||
<div>
|
||||
<span class="mr-8">{{ row.nick_name }}</span>
|
||||
<el-tag v-if="isManage(row.type)" class="default-tag">{{
|
||||
$t('views.resourceAuthorization.manage')
|
||||
}}</el-tag>
|
||||
}}</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -40,20 +30,10 @@
|
|||
<div class="resource-authorization__table">
|
||||
<h4 class="mb-4">{{ $t('views.resourceAuthorization.permissionSetting') }}</h4>
|
||||
<el-tabs v-model="activeName" class="resource-authorization__tabs">
|
||||
<el-tab-pane
|
||||
v-for="(item, index) in settingTags"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:name="item.value"
|
||||
>
|
||||
<PermissionSetting
|
||||
:key="index"
|
||||
:data="item.data"
|
||||
:type="item.value"
|
||||
:tableHeight="tableHeight"
|
||||
:manage="isManage(currentType)"
|
||||
@refreshData="refreshData"
|
||||
></PermissionSetting>
|
||||
<el-tab-pane v-for="(item, index) in settingTags" :key="item.value" :label="item.label"
|
||||
:name="item.value">
|
||||
<PermissionSetting :key="index" :data="item.data" :type="item.value" :tableHeight="tableHeight"
|
||||
:manage="isManage(currentType)" @refreshData="refreshData"></PermissionSetting>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
|
|
@ -116,23 +96,31 @@ function isManage(type: string) {
|
|||
return type === 'manage'
|
||||
}
|
||||
|
||||
const flotTree = (tree: Array<any>, result: Array<any>) => {
|
||||
tree.forEach(tItem => {
|
||||
result.push(tItem)
|
||||
if (tItem.children) {
|
||||
flotTree(tItem.children, result)
|
||||
}
|
||||
})
|
||||
return result
|
||||
}
|
||||
function submitPermissions() {
|
||||
const obj: any = {
|
||||
user_resource_permission_list: [],
|
||||
}
|
||||
settingTags.map((item: any) => {
|
||||
item.data.map((v: any) => {
|
||||
obj['user_resource_permission_list'].push({
|
||||
const user_resource_permission_list = settingTags.map((item: any) => {
|
||||
return flotTree(item.data, []).filter((v: any) => !v.isFolder).map((v: any) => {
|
||||
return {
|
||||
target_id: v.id,
|
||||
auth_target_type: v.auth_target_type,
|
||||
auth_target_type: item.value,
|
||||
permission: v.permission,
|
||||
auth_type: 'RESOURCE_PERMISSION_GROUP',
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
AuthorizationApi.putResourceAuthorization(currentUser.value, obj, rLoading).then(() => {
|
||||
}).reduce((pre, next) => {
|
||||
return [...pre, ...next]
|
||||
}, [])
|
||||
AuthorizationApi.putResourceAuthorization(currentUser.value, { user_resource_permission_list: user_resource_permission_list }, rLoading).then(() => {
|
||||
MsgSuccess(t('common.submitSuccess'))
|
||||
ResourcePermissions(currentUser.value)
|
||||
getWholeTree(currentUser.value)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@
|
|||
:currentNodeKey="currentFolder?.id"
|
||||
@handleNodeClick="folderClickHandel"
|
||||
@refreshTree ="refreshFolder"
|
||||
shareTitle="views.system.share_tool"
|
||||
:shareTitle="hasPermission(new ComplexPermission(
|
||||
[RoleConst.ADMIN],[PermissionConst.SHARED_TOOL_READ],[EditionConst.IS_EE],'OR'
|
||||
), 'OR')?'views.system.share_tool':null"
|
||||
isShared
|
||||
class="p-8"
|
||||
/>
|
||||
|
|
@ -319,9 +321,10 @@ import { t } from '@/locales'
|
|||
import { isAppIcon } from '@/utils/common'
|
||||
import { MsgSuccess, MsgConfirm, MsgError } from '@/utils/message'
|
||||
import SharedWorkspace from '@/views/shared/tool-shared/SharedWorkspace.vue'
|
||||
import { PermissionConst, RoleConst } from '@/utils/permission/data'
|
||||
import { EditionConst, PermissionConst, RoleConst } from '@/utils/permission/data'
|
||||
import { hasPermission } from '@/utils/permission/index'
|
||||
import { FolderSource } from '@/enums/common'
|
||||
import { ComplexPermission } from '@/utils/permission/type'
|
||||
|
||||
const { folder, user } = useStore()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue