File tree Expand file tree Collapse file tree 1 file changed +33
-2
lines changed
src/modules/access-control/table Expand file tree Collapse file tree 1 file changed +33
-2
lines changed Original file line number Diff line number Diff line change 11import MultipleGroups from "@components/ui/MultipleGroups" ;
2+ import ResourceBadge from "@components/ui/ResourceBadge" ;
3+ import useFetchApi from "@utils/api" ;
24import React , { useMemo } from "react" ;
5+ import Skeleton from "react-loading-skeleton" ;
36import { Group } from "@/interfaces/Group" ;
4- import { Policy } from "@/interfaces/Policy" ;
7+ import { NetworkResource } from "@/interfaces/Network" ;
8+ import { Policy , PolicyRuleResource } from "@/interfaces/Policy" ;
59
610type Props = {
711 policy : Policy ;
812} ;
9- export default function AccessControlDestinationsCell ( { policy } : Props ) {
13+ export default function AccessControlDestinationsCell ( {
14+ policy,
15+ } : Readonly < Props > ) {
1016 const firstRule = useMemo ( ( ) => {
1117 if ( policy . rules . length > 0 ) return policy . rules [ 0 ] ;
1218 return undefined ;
1319 } , [ policy ] ) ;
1420
21+ if ( firstRule ?. destinationResource ) {
22+ return (
23+ < AccessControlDestinationResourceCell
24+ resource = { firstRule . destinationResource }
25+ />
26+ ) ;
27+ }
28+
1529 return firstRule ? (
1630 < MultipleGroups groups = { firstRule . destinations as Group [ ] } />
1731 ) : null ;
1832}
33+
34+ const AccessControlDestinationResourceCell = ( {
35+ resource,
36+ } : {
37+ resource : PolicyRuleResource ;
38+ } ) => {
39+ const { data : resources , isLoading } = useFetchApi < NetworkResource [ ] > (
40+ "/networks/resources" ,
41+ ) ;
42+ if ( isLoading ) return < Skeleton height = { 35 } width = { "50%" } /> ;
43+
44+ return (
45+ < div className = { "flex" } >
46+ < ResourceBadge resource = { resources ?. find ( ( r ) => r . id === resource . id ) } />
47+ </ div >
48+ ) ;
49+ } ;
You can’t perform that action at this time.
0 commit comments