Skip to content

Commit 539b058

Browse files
committed
refactor: ci/cd pipeline services, types, FileUpload - remove className support
1 parent 1a8b855 commit 539b058

File tree

7 files changed

+24
-38
lines changed

7 files changed

+24
-38
lines changed

src/Common/CIPipeline.Types.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,19 @@ export enum RefVariableStageType {
9797
POST_CI = 'POST_CI',
9898
}
9999

100-
export interface FileProperty {
100+
export interface FilePropertyType {
101101
allowedExtensions: string[]
102102
maxUploadSize: number
103103
}
104104

105-
export interface Constraint {
106-
fileProperty: FileProperty
105+
export interface ConstraintType {
106+
fileProperty: FilePropertyType
107107
}
108108

109-
export interface ValueConstraint {
109+
export interface ValueConstraintType {
110110
choices: string[]
111111
blockCustomValue: boolean
112-
constraint: Constraint
112+
constraint: ConstraintType
113113
}
114114

115115
export enum VariableTypeFormat {
@@ -136,7 +136,7 @@ export interface VariableType {
136136
fileMountDir: string
137137
fileReferenceId: number
138138
valueConstraintId: number
139-
valueConstraint: ValueConstraint
139+
valueConstraint: ValueConstraintType
140140
isRuntimeArg: boolean
141141
refVariableUsed: boolean
142142
}

src/Pages/Applications/DevtronApps/Details/CDPipeline/services.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { MutableRefObject } from 'react'
33
import { getIsRequestAborted, post } from '@Common/Api'
44
import { ROUTES } from '@Common/Constants'
55
import { getUrlWithSearchParams, showError } from '@Common/Helper'
6-
import { UploadFileDTO } from '@Shared/types'
6+
import { UploadFileDTO, UploadFileProps } from '@Shared/types'
77

88
export const uploadCDPipelineFile = async ({
99
file,
@@ -12,12 +12,9 @@ export const uploadCDPipelineFile = async ({
1212
allowedExtensions,
1313
maxUploadSize,
1414
abortControllerRef,
15-
}: {
16-
file: File[]
15+
}: UploadFileProps & {
1716
appId: number
1817
envId: number
19-
allowedExtensions?: string[]
20-
maxUploadSize?: number
2118
abortControllerRef?: MutableRefObject<AbortController>
2219
}): Promise<UploadFileDTO> => {
2320
const formData = new FormData()
@@ -36,10 +33,9 @@ export const uploadCDPipelineFile = async ({
3633

3734
return result
3835
} catch (err) {
39-
if (getIsRequestAborted(err)) {
40-
return null
36+
if (!getIsRequestAborted(err)) {
37+
showError(err)
4138
}
42-
showError(err)
4339
throw err
4440
}
4541
}

src/Pages/Applications/DevtronApps/Details/CIPipeline/services.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ export const uploadCIPipelineFile = async ({
3939

4040
return result
4141
} catch (err) {
42-
if (getIsRequestAborted(err)) {
43-
return null
42+
if (!getIsRequestAborted(err)) {
43+
showError(err)
4444
}
45-
showError(err)
4645
throw err
4746
}
4847
}

src/Shared/Components/DynamicDataTable/DynamicDataTableRow.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,9 @@ export const DynamicDataTableRow = <K extends string, CustomStateType = Record<s
181181
)
182182
case DynamicDataTableRowDataType.FILE_UPLOAD:
183183
return (
184-
<div className="w-100 h-100 flex top left">
184+
<div className={`w-100 h-100 flex top left px-8 min-w-0 ${row.data[key].value ? 'py-3' : 'py-8'}`}>
185185
<FileUpload
186186
{...row.data[key].props}
187-
className={`px-8 min-w-0 ${row.data[key].value ? 'py-3' : 'py-8'}`}
188187
fileName={row.data[key].value}
189188
onUpload={onChange(row, key)}
190189
/>

src/Shared/Components/FileUpload/FileUpload.tsx

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
import { ChangeEvent } from 'react'
22

33
import { ReactComponent as ICCloudUpload } from '@Icons/ic-cloud-upload.svg'
4-
import { ReactComponent as ICClose } from '@Icons/ic-close.svg'
4+
import { ReactComponent as ICCross } from '@Icons/ic-cross.svg'
55
import { Tooltip } from '@Common/Tooltip'
66

77
import { FileUploadProps } from './types'
88

9-
export const FileUpload = ({
10-
label,
11-
fileName = '',
12-
multiple = false,
13-
fileTypes = [],
14-
className,
15-
onUpload,
16-
}: FileUploadProps) => {
9+
export const FileUpload = ({ label, fileName = '', multiple = false, fileTypes = [], onUpload }: FileUploadProps) => {
1710
// METHODS
1811
const handleFileChange = (event: ChangeEvent<HTMLInputElement>) => {
1912
if (event.target.files) {
@@ -25,8 +18,12 @@ export const FileUpload = ({
2518
e.target.value = ''
2619
}
2720

21+
const onClearUpload = () => {
22+
onUpload([])
23+
}
24+
2825
return (
29-
<div className={className || ''}>
26+
<div>
3027
{fileName ? (
3128
<div className="dc__border br-4 dc__overflow-hidden flexbox">
3229
<div className="flexbox dc__align-items-center dc__gap-8 px-8 py-4 min-w-0">
@@ -35,12 +32,8 @@ export const FileUpload = ({
3532
<span className="fs-12 lh-20 dc__ellipsis-right">{fileName}</span>
3633
</Tooltip>
3734
</div>
38-
<button
39-
type="button"
40-
className="dc__transparent flex p-6 dc__hover-n50"
41-
onClick={() => onUpload([])}
42-
>
43-
<ICClose className="icon-dim-16 fcn-6" />
35+
<button type="button" className="dc__transparent flex p-6 dc__hover-n50" onClick={onClearUpload}>
36+
<ICCross className="icon-dim-16 fcn-6" />
4437
</button>
4538
</div>
4639
) : (

src/Shared/Components/FileUpload/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ export interface FileUploadProps {
33
onUpload: (files: File[]) => void
44
multiple?: boolean
55
label?: string
6-
className?: string
76
// Array of allowed MIME types (e.g., ["image/png", "image/jpeg"])
87
fileTypes?: string[]
98
}

src/Shared/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
DeploymentAppTypes,
2525
ServerErrors,
2626
SortingParams,
27-
ValueConstraint,
27+
ValueConstraintType,
2828
VariableType,
2929
RefVariableType,
3030
PluginType,
@@ -342,7 +342,7 @@ export interface GitTriggers {
342342
export interface RuntimePluginVariables
343343
extends Pick<VariableType, 'name' | 'value' | 'format' | 'fileReferenceId' | 'fileMountDir'> {
344344
variableStepScope: string
345-
valueConstraint: ValueConstraint & { id: number }
345+
valueConstraint: ValueConstraintType & { id: number }
346346
stepVariableId: number
347347
valueType: RefVariableType
348348
stepName: string

0 commit comments

Comments
 (0)