1
1
import React from 'react' ;
2
2
3
3
import { Table , WarningPanel } from '@backstage/core-components' ;
4
+ import { catalogEntityReadPermission } from '@backstage/plugin-catalog-common/alpha' ;
4
5
import { usePermission } from '@backstage/plugin-permission-react' ;
5
6
6
7
import { Card , CardContent , makeStyles } from '@material-ui/core' ;
@@ -43,10 +44,14 @@ const getEditIcon = (isAllowed: boolean, roleName: string) => {
43
44
export const MembersCard = ( { roleName } : MembersCardProps ) => {
44
45
const { data, loading, retry, error } = useMembers ( roleName ) ;
45
46
const [ members , setMembers ] = React . useState < MembersData [ ] > ( ) ;
46
- const permissionResult = usePermission ( {
47
+ const policyEntityPermissionResult = usePermission ( {
47
48
permission : policyEntityUpdatePermission ,
48
49
resourceRef : policyEntityUpdatePermission . resourceType ,
49
50
} ) ;
51
+ const catalogEntityPermissionResult = usePermission ( {
52
+ permission : catalogEntityReadPermission ,
53
+ resourceRef : catalogEntityReadPermission . resourceType ,
54
+ } ) ;
50
55
51
56
const classes = useStyles ( ) ;
52
57
const actions = [
@@ -57,8 +62,17 @@ export const MembersCard = ({ roleName }: MembersCardProps) => {
57
62
onClick : ( ) => retry ( ) ,
58
63
} ,
59
64
{
60
- icon : ( ) => getEditIcon ( permissionResult . allowed , roleName ) ,
61
- tooltip : ! permissionResult . allowed ? 'Unauthorized to edit' : 'Edit' ,
65
+ icon : ( ) =>
66
+ getEditIcon (
67
+ policyEntityPermissionResult . allowed &&
68
+ catalogEntityPermissionResult . allowed ,
69
+ roleName ,
70
+ ) ,
71
+ tooltip :
72
+ catalogEntityPermissionResult . allowed &&
73
+ policyEntityPermissionResult . allowed
74
+ ? 'Edit'
75
+ : 'Unauthorized to edit' ,
62
76
isFreeAction : true ,
63
77
onClick : ( ) => { } ,
64
78
} ,
0 commit comments