Skip to content

Commit 725adc4

Browse files
committed
feat: RuntimeParams - services updated
1 parent 5abf11a commit 725adc4

File tree

4 files changed

+53
-4
lines changed

4 files changed

+53
-4
lines changed

src/Common/Common.service.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ const processCDMaterialsMetaInfo = (cdMaterialsResult): CDMaterialsMetaInfo => {
343343
resourceFilters: cdMaterialsResult.resourceFilters ?? [],
344344
totalCount: cdMaterialsResult.totalCount ?? 0,
345345
requestedUserId: cdMaterialsResult.requestedUserId,
346-
runtimeParams: parseRuntimeParams(cdMaterialsResult.runtimeParams),
346+
runtimeParams: cdMaterialsResult.runtimeParams.runtimePluginVariables ?? [],
347347
}
348348
}
349349

@@ -520,7 +520,10 @@ export function getWebhookEventsForEventId(eventId: string | number) {
520520
*/
521521
export const getGitBranchUrl = (gitUrl: string, branchName: string): string | null => {
522522
if (!gitUrl) return null
523-
const trimmedGitUrl = gitUrl.trim().replace(/\.git$/, '').replace(/\/$/, '') // Remove any trailing slash
523+
const trimmedGitUrl = gitUrl
524+
.trim()
525+
.replace(/\.git$/, '')
526+
.replace(/\/$/, '') // Remove any trailing slash
524527
if (trimmedGitUrl.includes(GitProviderType.GITLAB)) return `${trimmedGitUrl}/-/tree/${branchName}`
525528
else if (trimmedGitUrl.includes(GitProviderType.GITHUB)) return `${trimmedGitUrl}/tree/${branchName}`
526529
else if (trimmedGitUrl.includes(GitProviderType.BITBUCKET)) return `${trimmedGitUrl}/branch/${branchName}`

src/Common/Types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { TippyProps } from '@tippyjs/react'
1919
import { Placement } from 'tippy.js'
2020
import { UserGroupDTO } from '@Pages/GlobalConfigurations'
2121
import { ImageComment, ReleaseTag } from './ImageTags.Types'
22-
import { MandatoryPluginBaseStateType, RegistryType, RuntimeParamsListItemType, Severity } from '../Shared'
22+
import { MandatoryPluginBaseStateType, RegistryType, RuntimePluginVariables, Severity } from '../Shared'
2323
import {
2424
ACTION_STATE,
2525
ConsequenceType,
@@ -697,7 +697,7 @@ export interface CDMaterialsMetaInfo {
697697
* This is the ID of user that has request the material
698698
*/
699699
requestedUserId: number
700-
runtimeParams: RuntimeParamsListItemType[]
700+
runtimeParams: RuntimePluginVariables[]
701701
}
702702

703703
export interface ImagePromotionMaterialInfo {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from './types'
2+
export * from './services'
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { MutableRefObject } from 'react'
2+
3+
import { getIsRequestAborted, post } from '@Common/Api'
4+
import { ROUTES } from '@Common/Constants'
5+
import { getUrlWithSearchParams, showError } from '@Common/Helper'
6+
import { UploadFileDTO } from '@Shared/types'
7+
8+
export const uploadCDPipelineFile = async ({
9+
file,
10+
appId,
11+
envId,
12+
allowedExtensions,
13+
maxUploadSize,
14+
abortControllerRef,
15+
}: {
16+
file: File[]
17+
appId: number
18+
envId: number
19+
allowedExtensions?: string[]
20+
maxUploadSize?: number
21+
abortControllerRef?: MutableRefObject<AbortController>
22+
}): Promise<UploadFileDTO> => {
23+
const formData = new FormData()
24+
formData.append('file', file[0])
25+
26+
try {
27+
const { result } = await post(
28+
getUrlWithSearchParams(`${ROUTES.CD_CONFIG}/${appId}/${envId}/${ROUTES.FILE_UPLOAD}`, {
29+
allowedExtensions,
30+
maxUploadSize,
31+
}),
32+
formData,
33+
{ abortControllerRef },
34+
true,
35+
)
36+
37+
return result
38+
} catch (err) {
39+
if (getIsRequestAborted(err)) {
40+
return null
41+
}
42+
showError(err)
43+
throw err
44+
}
45+
}

0 commit comments

Comments
 (0)