15
15
*/
16
16
17
17
import moment from 'moment'
18
+ import { RuntimeParamsAPIResponseType } from '@Shared/types'
19
+ import { stringComparatorBySortOrder } from '@Shared/Helpers'
18
20
import { get , post } from './Api'
19
21
import { ROUTES } from './Constants'
20
22
import { getUrlWithSearchParams , sortCallback } from './Helper'
@@ -80,7 +82,13 @@ export function setImageTags(request, pipelineId: number, artifactId: number) {
80
82
return post ( `${ ROUTES . IMAGE_TAGGING } /${ pipelineId } /${ artifactId } ` , request )
81
83
}
82
84
83
- const cdMaterialListModal = ( artifacts : any [ ] , offset : number , artifactId ?: number , artifactStatus ?: string , disableDefaultSelection ?: boolean ) => {
85
+ const cdMaterialListModal = (
86
+ artifacts : any [ ] ,
87
+ offset : number ,
88
+ artifactId ?: number ,
89
+ artifactStatus ?: string ,
90
+ disableDefaultSelection ?: boolean ,
91
+ ) => {
84
92
if ( ! artifacts || ! artifacts . length ) return [ ]
85
93
86
94
const markFirstSelected = offset === 0
@@ -185,6 +193,11 @@ const processCDMaterialsApprovalInfo = (enableApproval: boolean, cdMaterialsResu
185
193
}
186
194
}
187
195
196
+ export const parseRuntimeParams = ( response : RuntimeParamsAPIResponseType ) =>
197
+ Object . entries ( response ?. envVariables || { } )
198
+ . map ( ( [ key , value ] , index ) => ( { key, value, id : index } ) )
199
+ . sort ( ( a , b ) => stringComparatorBySortOrder ( a . key , b . key ) )
200
+
188
201
const processCDMaterialsMetaInfo = ( cdMaterialsResult ) : CDMaterialsMetaInfo => {
189
202
if ( ! cdMaterialsResult ) {
190
203
return {
@@ -194,6 +207,7 @@ const processCDMaterialsMetaInfo = (cdMaterialsResult): CDMaterialsMetaInfo => {
194
207
resourceFilters : [ ] ,
195
208
totalCount : 0 ,
196
209
requestedUserId : 0 ,
210
+ runtimeParams : [ ] ,
197
211
}
198
212
}
199
213
@@ -204,6 +218,8 @@ const processCDMaterialsMetaInfo = (cdMaterialsResult): CDMaterialsMetaInfo => {
204
218
resourceFilters : cdMaterialsResult . resourceFilters ?? [ ] ,
205
219
totalCount : cdMaterialsResult . totalCount ?? 0 ,
206
220
requestedUserId : cdMaterialsResult . requestedUserId ,
221
+ // TODO: Get this casing fixed from API
222
+ runtimeParams : parseRuntimeParams ( cdMaterialsResult . runtime_params ) ,
207
223
}
208
224
}
209
225
@@ -366,8 +382,8 @@ export const getResourceGroupListRaw = (clusterId: string): Promise<ResponseType
366
382
}
367
383
368
384
export function getNamespaceListMin ( clusterIdsCsv : string ) : Promise < EnvironmentListHelmResponse > {
369
- const URL = `${ ROUTES . NAMESPACE } /autocomplete?ids=${ clusterIdsCsv } `
370
- return get ( URL )
385
+ const URL = `${ ROUTES . NAMESPACE } /autocomplete?ids=${ clusterIdsCsv } `
386
+ return get ( URL )
371
387
}
372
388
export function getWebhookEventsForEventId ( eventId : string | number ) {
373
389
const URL = `${ ROUTES . GIT_HOST_EVENT } /${ eventId } `
0 commit comments