@@ -28,11 +28,9 @@ import {
2828 getStatusColorSpan ,
2929 getTitleWithBacklink ,
3030 getChips ,
31-
32- API_PROXY_BASE_PATH ,
33- API_VULN_PIPELINE ,
3431 getBacklink
3532} from '../../lib'
33+ import { sysdigApiRef } from '../../api' ;
3634
3735type PipelineScan = {
3836 createdAt : Date ,
@@ -113,20 +111,19 @@ export const DenseTable = ({ pipelineScans, title }: DenseTableProps) => {
113111
114112export const SysdigVMPipelineFetchComponent = ( ) => {
115113 const { entity } = useEntity ( ) ;
116- const backendUrl = useApi ( configApiRef ) . getString ( 'backend.baseUrl' ) ;
114+ const sysdigApiClient = useApi ( sysdigApiRef )
117115 let endpoint : string | undefined = useApi ( configApiRef ) . getOptionalString ( "sysdig.endpoint" ) ;
118116 let backlink_config : string | undefined = useApi ( configApiRef ) . getOptionalString ( "sysdig.backlink" ) ;
119117
120118 var backlink = getBacklink ( endpoint , backlink_config , "vm-pipeline" ) ;
121119
122- let uri = backendUrl + API_PROXY_BASE_PATH + API_VULN_PIPELINE ;
123120 let filter = '?filter=' ;
124121 var name ;
125122
126123 const annotations = entity . metadata . annotations ;
127124 if ( annotations ) {
128125 if ( SYSDIG_CUSTOM_FILTER_ANNOTATION in annotations ) {
129- uri += '? filter=' + annotations [ SYSDIG_CUSTOM_FILTER_ANNOTATION ]
126+ filter += annotations [ SYSDIG_CUSTOM_FILTER_ANNOTATION ]
130127 } else {
131128
132129 var filters = [ ]
@@ -141,17 +138,11 @@ export const SysdigVMPipelineFetchComponent = () => {
141138 }
142139
143140 filter += filters . join ( ' and ' ) ;
144- uri += filter ;
145141 backlink += filter ;
146142 }
147143
148144 const { value, loading, error } = useAsync ( async ( ) : Promise < PipelineScan [ ] > => {
149- const requestOptions = {
150- method : 'GET' ,
151- } ;
152-
153- const response = await fetch ( uri , requestOptions ) ;
154- const data = await response . json ( ) ;
145+ const data = await sysdigApiClient . fetchVulnPipeline ( filter )
155146 return data . data ;
156147 } , [ ] ) ;
157148
@@ -166,4 +157,4 @@ export const SysdigVMPipelineFetchComponent = () => {
166157 } else {
167158 return < Alert severity = "warning" > Please, add annotations to the entity.</ Alert > ;
168159 }
169- } ;
160+ } ;
0 commit comments