Skip to content

Commit 1febd0a

Browse files
committed
fix: Problem read permission
1 parent 3edc684 commit 1febd0a

File tree

4 files changed

+39
-4
lines changed

4 files changed

+39
-4
lines changed

ui/src/permission/knowledge/system-share.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,21 @@ const share = {
150150
],
151151
'OR'
152152
),
153-
problem_read: () => false,
154-
problem_relate: () =>
153+
problem_read: () =>
155154
hasPermission (
156155
[
157156
RoleConst.ADMIN,
158157
PermissionConst.SHARED_KNOWLEDGE_PROBLEM_READ
159158
],
160159
'OR'
160+
),
161+
problem_relate: () =>
162+
hasPermission (
163+
[
164+
RoleConst.ADMIN,
165+
PermissionConst.SHARED_KNOWLEDGE_PROBLEM_RELATE
166+
],
167+
'OR'
161168
),
162169
problem_delete: () =>
163170
hasPermission (

ui/src/permission/knowledge/workspace.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,16 @@ const workspace = {
212212
]
213213
,'OR'
214214
),
215-
problem_read: () => false,
215+
problem_read: (source_id:string) =>
216+
hasPermission(
217+
[
218+
new ComplexPermission([RoleConst.USER],[PermissionConst.KNOWLEDGE.getKnowledgeWorkspaceResourcePermission(source_id)],[],'AND'),
219+
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
220+
PermissionConst.KNOWLEDGE_PROBLEM_READ.getKnowledgeWorkspaceResourcePermission(source_id),
221+
PermissionConst.KNOWLEDGE_PROBLEM_READ.getWorkspacePermissionWorkspaceManageRole,
222+
],
223+
'OR',
224+
),
216225
problem_create: (source_id:string) =>
217226
hasPermission(
218227
[

ui/src/utils/permission/data.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ const PermissionConst = {
195195
SHARED_KNOWLEDGE_PROBLEM_CREATE: new Permission('SYSTEM_KNOWLEDGE_PROBLEM:READ+CREATE'),
196196
SHARED_KNOWLEDGE_PROBLEM_EDIT: new Permission('SYSTEM_KNOWLEDGE_PROBLEM:READ+EDIT'),
197197
SHARED_KNOWLEDGE_PROBLEM_DELETE: new Permission('SYSTEM_KNOWLEDGE_PROBLEM:READ+DELETE'),
198+
SHARED_KNOWLEDGE_PROBLEM_RELATE: new Permission('SYSTEM_KNOWLEDGE_PROBLEM:READ+RELATE'),
198199

199200
SHARED_KNOWLEDGE_HIT_TEST_READ: new Permission('SYSTEM_KNOWLEDGE_HIT_TEST:READ'),
200201
KNOWLEDGE_HIT_TEST_READ: new Permission('KNOWLEDGE_HIT_TEST:READ'),

ui/src/views/paragraph/component/ParagraphDialog.vue

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
<el-col :span="6" class="border-l" style="width: 300px">
3838
<!-- 关联问题 -->
3939
<ProblemComponent
40+
v-if="permissionPrecise.problem_read(id)"
4041
:paragraphId="paragraphId"
4142
:docId="document_id"
4243
:knowledgeId="id"
@@ -56,12 +57,14 @@
5657
</el-dialog>
5758
</template>
5859
<script setup lang="ts">
59-
import { ref, watch, nextTick } from 'vue'
60+
import { ref, watch, nextTick, computed } from 'vue'
6061
import { useRoute } from 'vue-router'
6162
import { cloneDeep, debounce } from 'lodash'
6263
import ParagraphForm from '@/views/paragraph/component/ParagraphForm.vue'
6364
import ProblemComponent from '@/views/paragraph/component/ProblemComponent.vue'
6465
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
66+
import permissionMap from '@/permission'
67+
6568
6669
const props = defineProps<{
6770
title: String
@@ -73,6 +76,21 @@ const {
7376
params: { id, documentId },
7477
} = route as any
7578
79+
const apiType = computed(() => {
80+
if (route.path.includes('shared')) {
81+
return 'systemShare'
82+
} else if (route.query.from == 'systemManage') {
83+
return 'systemManage'
84+
} else {
85+
return 'workspace'
86+
}
87+
})
88+
89+
const permissionPrecise = computed(() => {
90+
return permissionMap['knowledge'][apiType.value]
91+
})
92+
93+
7694
const emit = defineEmits(['refresh'])
7795
7896
const ProblemRef = ref()

0 commit comments

Comments
 (0)