@@ -5,15 +5,15 @@ import { K8sClusterApi } from '@/api';
55import showDeleteConfirm from '@/components/customModal/showDeleteConfirm' ;
66import { getK8sObclusterListReq } from '@/services' ;
77import { formatTime , isNullValue } from '@oceanbase/util' ;
8- import { Link , useAccess } from '@umijs/max' ;
8+ import { Link , useModel } from '@umijs/max' ;
99import { useRequest } from 'ahooks' ;
1010import { ColumnsType } from 'antd/es/table' ;
1111import { useState } from 'react' ;
1212import Createk8sClusterModal from './Createk8sClusterModal' ;
1313
1414const { Text } = Typography ;
1515export default function K8sClusterList ( ) {
16- const access = useAccess ( ) ;
16+ const { initialState } = useModel ( '@@initialState' ) ;
1717 const [ visible , setVisible ] = useState < boolean > ( false ) ;
1818 const [ editData , setEditData ] = useState < string > ( { } ) ;
1919 const { data, refresh, loading } = useRequest ( getK8sObclusterListReq ) ;
@@ -38,6 +38,16 @@ export default function K8sClusterList() {
3838 } ,
3939 ) ;
4040
41+ const allPolicies = initialState ?. policies ?. filter (
42+ ( policy ) => policy . domain === 'k8s-cluster' ,
43+ ) ;
44+ const k8sClusterAccess = allPolicies ?. map (
45+ ( item ) => `k8sCluster${ item . action } ` ,
46+ ) ;
47+
48+ const k8sClusterwrite = k8sClusterAccess ?. includes ( 'k8sClusterwrite' ) ;
49+ const k8sClusterread = k8sClusterAccess ?. includes ( 'k8sClusterread' ) ;
50+
4151 const columns : ColumnsType < API . TenantDetail > = [
4252 {
4353 title : intl . formatMessage ( {
@@ -47,7 +57,7 @@ export default function K8sClusterList() {
4757 dataIndex : 'name' ,
4858 render : ( text ) => (
4959 < Text ellipsis = { { tooltip : text } } >
50- < Link to = { `${ text } ` } > { text } </ Link >
60+ { k8sClusterread ? < Link to = { `${ text } ` } > { text } </ Link > : text }
5161 </ Text >
5262 ) ,
5363 } ,
@@ -78,7 +88,7 @@ export default function K8sClusterList() {
7888 dataIndex : 'operation' ,
7989
8090 render : ( _ , record ) => {
81- return (
91+ return k8sClusterwrite ? (
8292 < Space >
8393 < a
8494 onClick = { ( ) => {
@@ -109,7 +119,7 @@ export default function K8sClusterList() {
109119 } ) }
110120 </ Button >
111121 </ Space >
112- ) ;
122+ ) : null ;
113123 } ,
114124 } ,
115125 ] ;
@@ -128,7 +138,7 @@ export default function K8sClusterList() {
128138 </ div >
129139 }
130140 extra = {
131- access . obclusterwrite ? (
141+ k8sClusterwrite ? (
132142 < Button
133143 type = "primary"
134144 onClick = { ( ) => {
0 commit comments