Skip to content

Commit 55cf9b5

Browse files
committed
chore: code refactoring
1 parent d7a949f commit 55cf9b5

File tree

7 files changed

+119
-117
lines changed

7 files changed

+119
-117
lines changed

src/components/app/details/appDetails/DeployedCommitCard.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ const DeployedCommitCard = ({ cardLoading, showCommitInfoDrawer, envId, ciArtifa
7878
</div>
7979
<GitProviderIcon gitRepoUrl={lastCommit?.commitURL} size={24} />
8080
{/* @TODO: This should be dynamic, dependent on the source */}
81-
{/* <GitHub className="github-icon" /> */}
8281
</div>
8382
<div className="app-details-info-card__bottom-container dc__content-space">
8483
<span className="app-details-info-card__bottom-container__message fs-12 fw-4">

src/components/ciPipeline/ciPipeline.service.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ export function getInitDataWithCIPipeline(
242242
},
243243
]) => {
244244
const ciPipeline = ciPipelineRes?.result
245-
console.log('pipelineMetaConfig from getPipelineMetaConfiguration', pipelineMetaConfig)
246245
const pipelineMetaConfigResult = pipelineMetaConfig?.result
247246
return parseCIResponse(
248247
pipelineMetaConfig.code,
@@ -456,7 +455,7 @@ function createMaterialList(ciPipeline, gitMaterials: MaterialType[], gitHost: G
456455
gitHostId: gitHost ? gitHost.id : 0,
457456
regex: mat.source.regex,
458457
isRegex: mat.isRegex,
459-
url: mat.url || gitMaterials[0].url, // Required BE support till then will be getting url from another api
458+
url: mat.url || gitMaterials?.[0].url, // Required BE support till then will be getting url from another api
460459
}
461460
}) || []
462461
}
@@ -573,7 +572,6 @@ function parseCIResponse(
573572
isSecurityModuleInstalled?: boolean,
574573
appWorkflowId?: number,
575574
) {
576-
console.log('gitMaterials', gitMaterials)
577575
if (ciPipeline) {
578576
if (ciPipeline.beforeDockerBuildScripts) {
579577
ciPipeline.preBuildStage = migrateOldData(ciPipeline.beforeDockerBuildScripts)

src/components/workflowEditor/Workflow.tsx

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
import { Component } from 'react'
18-
import { RouteComponentProps, Link, generatePath } from 'react-router-dom'
18+
import { Link, generatePath } from 'react-router-dom'
1919
import Tippy from '@tippyjs/react'
2020
import { CINode } from './nodes/CINode'
2121
import { CDNode } from './nodes/CDNode'
@@ -40,19 +40,15 @@ import {
4040
noop,
4141
WorkflowNodeType,
4242
PipelineType,
43-
AddPipelineType,
44-
SelectedNode,
4543
ConditionalWrap,
4644
ChangeCIPayloadType,
47-
CIPipelineNodeType,
4845
URLS as CommonURLS,
49-
AppConfigProps,
5046
} from '@devtron-labs/devtron-fe-common-lib'
5147
import { ReactComponent as ICInput } from '../../assets/icons/ic-input.svg'
5248
import { ReactComponent as ICMoreOption } from '../../assets/icons/ic-more-option.svg'
5349
import { ReactComponent as ICDelete } from '../../assets/icons/ic-delete-interactive.svg'
5450
import { ReactComponent as ICEdit } from '../../assets/icons/ic-pencil.svg'
55-
import { WorkflowPositionState } from './types'
51+
import { WorkflowProps, WorkflowState } from './types'
5652
import { CHANGE_CI_TOOLTIP } from './constants'
5753

5854
const ApprovalNodeEdge = importComponentFromFELibrary('ApprovalNodeEdge')
@@ -63,55 +59,6 @@ const getParsedPluginPolicyConsequenceData = importComponentFromFELibrary(
6359
'function',
6460
)
6561

66-
export interface WorkflowProps
67-
extends RouteComponentProps<{ appId: string; workflowId?: string; ciPipelineId?: string; cdPipelineId?: string }>,
68-
Required<Pick<AppConfigProps, 'isTemplateView'>> {
69-
nodes: CommonNodeAttr[]
70-
id: number
71-
name: string
72-
startX: number
73-
startY: number
74-
width: number | string
75-
height: number | string
76-
showDeleteDialog: (workflowId: number) => void
77-
handleCDSelect: (
78-
workflowId: number | string,
79-
ciPipelineId: number | string,
80-
parentPipelineType: string,
81-
parentPipelineId: number | string,
82-
isWebhookCD?: boolean,
83-
childPipelineId?: number | string,
84-
addType?: AddPipelineType,
85-
) => void
86-
openEditWorkflow: (event, workflowId: number) => string
87-
handleCISelect: (workflowId: string | number, type: CIPipelineNodeType) => void
88-
addCIPipeline: (type: CIPipelineNodeType) => void
89-
addWebhookCD: (workflowId?: number | string) => void
90-
cdWorkflowList?: any[]
91-
showWebhookTippy?: boolean
92-
hideWebhookTippy?: () => void
93-
isJobView?: boolean
94-
envList?: any[]
95-
filteredCIPipelines?: any[]
96-
addNewPipelineBlocked?: boolean
97-
handleChangeCI?: (changeCIPayload: ChangeCIPayloadType) => void
98-
selectedNode?: SelectedNode
99-
handleSelectedNodeChange?: (selectedNode: SelectedNode) => void
100-
appName?: string
101-
getWorkflows?: () => void
102-
refreshParentWorkflows?: () => void
103-
reloadEnvironments?: () => void
104-
workflowPositionState?: WorkflowPositionState
105-
handleDisplayLoader?: () => void
106-
isOffendingPipelineView?: boolean
107-
}
108-
109-
interface WorkflowState {
110-
top: number
111-
left: number
112-
showCIMenu: boolean
113-
}
114-
11562
export class Workflow extends Component<WorkflowProps, WorkflowState> {
11663
constructor(props) {
11764
super(props)
@@ -931,6 +878,8 @@ export class Workflow extends Component<WorkflowProps, WorkflowState> {
931878
}
932879

933880
render() {
881+
{ console.log('props', this.props)}
882+
934883
return <>{this.renderWorkflow()}</>
935884
}
936885
}

src/components/workflowEditor/nodes/CINode.tsx

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,54 +17,19 @@
1717
import { Component, ReactElement } from 'react'
1818
import {
1919
WorkflowNodeType,
20-
SelectedNode,
21-
CommonNodeAttr,
2220
ConditionalWrap,
2321
Icon,
2422
} from '@devtron-labs/devtron-fe-common-lib'
2523
import Tippy from '@tippyjs/react'
26-
import { Link, RouteComponentProps } from 'react-router-dom'
24+
import { Link } from 'react-router-dom'
2725
import ToggleCDSelectButton from '../ToggleCDSelectButton'
2826
import { ReactComponent as Warning } from '../../../assets/icons/ic-warning.svg'
2927
import { ReactComponent as ICLinkedCINode } from '../../../assets/icons/ic-node-build-linked.svg'
3028
import { ReactComponent as IcLink } from '../../../assets/icons/ic-link.svg'
3129
import { DEFAULT_ENV } from '../../app/details/triggerView/Constants'
3230
import { URLS } from '../../../config'
3331
import { getLinkedCITippyContent } from '../../../Pages/Shared/LinkedCIDetailsModal/utils'
34-
import { WorkflowProps } from '../Workflow'
35-
36-
export interface CINodeProps extends RouteComponentProps<{}>, Pick<WorkflowProps, 'isOffendingPipelineView' | 'isTemplateView'> {
37-
x: number
38-
y: number
39-
width: number
40-
height: number
41-
id: number
42-
title: string
43-
type: string
44-
description: string
45-
workflowId: number
46-
triggerType: string
47-
isLinkedCI: boolean
48-
isExternalCI: boolean
49-
isJobCI: boolean
50-
isTrigger: boolean
51-
linkedCount: number
52-
downstreams: CommonNodeAttr[]
53-
to: string
54-
toggleCDMenu: () => void
55-
configDiffView?: boolean
56-
hideWebhookTippy?: () => void
57-
isJobView?: boolean
58-
showPluginWarning?: boolean
59-
envList?: any[]
60-
filteredCIPipelines?: any[]
61-
addNewPipelineBlocked?: boolean
62-
handleSelectedNodeChange?: (selectedNode: SelectedNode) => void
63-
selectedNode?: SelectedNode
64-
isLastNode?: boolean
65-
appId: string
66-
getWorkflows: () => void
67-
}
32+
import { CINodeProps } from './types'
6833

6934
export class CINode extends Component<CINodeProps> {
7035
handleLinkedCIWorkflowChipClick = (e) => {

src/components/workflowEditor/nodes/StaticNode.tsx

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,14 @@
1414
* limitations under the License.
1515
*/
1616

17-
import React, { Component } from 'react'
17+
import { Component } from 'react'
1818
import { GIT_BRANCH_NOT_CONFIGURED } from '../../../config'
1919
import { CiPipelineSourceConfig, GitProviderIcon, GitProviderType } from '@devtron-labs/devtron-fe-common-lib'
20-
21-
export interface StaticNodeProps {
22-
x: number
23-
y: number
24-
branch: string
25-
icon: string
26-
id: string
27-
url: string
28-
title: string
29-
height: number
30-
width: number
31-
downstreams: any[]
32-
sourceType: string
33-
regex?: string
34-
primaryBranchAfterRegex?: string
35-
to?: string
36-
handleGoToWorkFlowEditor?: (e?: any) => void
37-
}
38-
20+
import { StaticNodeProps } from './types'
3921
export class StaticNode extends Component<StaticNodeProps> {
4022
renderCardContent() {
23+
console.log('props',this.props.url)
24+
4125
return (
4226
<div
4327
className={`workflow-node workflow-node--static ${
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { RouteComponentProps } from 'react-router-dom'
2+
3+
import { CommonNodeAttr, SelectedNode } from '@devtron-labs/devtron-fe-common-lib'
4+
5+
import { WorkflowProps } from '../types'
6+
7+
export interface StaticNodeProps {
8+
x: number
9+
y: number
10+
branch: string
11+
icon: string
12+
id: string
13+
url: string
14+
title: string
15+
height: number
16+
width: number
17+
downstreams: any[]
18+
sourceType: string
19+
regex?: string
20+
primaryBranchAfterRegex?: string
21+
to?: string
22+
handleGoToWorkFlowEditor?: (e?: any) => void
23+
}
24+
25+
export interface CINodeProps
26+
extends RouteComponentProps<{}>,
27+
Pick<WorkflowProps, 'isOffendingPipelineView' | 'isTemplateView'> {
28+
x: number
29+
y: number
30+
width: number
31+
height: number
32+
id: number
33+
title: string
34+
type: string
35+
description: string
36+
workflowId: number
37+
triggerType: string
38+
isLinkedCI: boolean
39+
isExternalCI: boolean
40+
isJobCI: boolean
41+
isTrigger: boolean
42+
linkedCount: number
43+
downstreams: CommonNodeAttr[]
44+
to: string
45+
toggleCDMenu: () => void
46+
configDiffView?: boolean
47+
hideWebhookTippy?: () => void
48+
isJobView?: boolean
49+
showPluginWarning?: boolean
50+
envList?: any[]
51+
filteredCIPipelines?: any[]
52+
addNewPipelineBlocked?: boolean
53+
handleSelectedNodeChange?: (selectedNode: SelectedNode) => void
54+
selectedNode?: SelectedNode
55+
isLastNode?: boolean
56+
appId: string
57+
getWorkflows: () => void
58+
}

src/components/workflowEditor/types.ts

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import { RouteComponentProps } from 'react-router-dom'
1818

1919
import {
20+
AddPipelineType,
2021
AppConfigProps,
2122
ChangeCIPayloadType,
2223
CiPipeline,
@@ -40,7 +41,6 @@ import { CdPipelineResult } from '../app/details/triggerView/types'
4041
import { InputVariablesFromInputListType } from '../cdPipeline/cdPipeline.types'
4142
import { DeleteDialogType, ForceDeleteMessageType } from '../cdPipeline/types'
4243
import { LoadingState } from '../ciConfig/types'
43-
import { WorkflowProps } from './Workflow'
4444

4545
export interface BlackListedCI {
4646
[key: number]: CiPipeline
@@ -352,3 +352,52 @@ export interface ToggleCDSelectButtonProps extends Required<Pick<AppConfigProps,
352352
getWorkflows?: () => void
353353
hideDeleteButton?: boolean
354354
}
355+
356+
export interface WorkflowProps
357+
extends RouteComponentProps<{ appId: string; workflowId?: string; ciPipelineId?: string; cdPipelineId?: string }>,
358+
Required<Pick<AppConfigProps, 'isTemplateView'>> {
359+
nodes: CommonNodeAttr[]
360+
id: number
361+
name: string
362+
startX: number
363+
startY: number
364+
width: number | string
365+
height: number | string
366+
showDeleteDialog: (workflowId: number) => void
367+
handleCDSelect: (
368+
workflowId: number | string,
369+
ciPipelineId: number | string,
370+
parentPipelineType: string,
371+
parentPipelineId: number | string,
372+
isWebhookCD?: boolean,
373+
childPipelineId?: number | string,
374+
addType?: AddPipelineType,
375+
) => void
376+
openEditWorkflow: (event, workflowId: number) => string
377+
handleCISelect: (workflowId: string | number, type: CIPipelineNodeType) => void
378+
addCIPipeline: (type: CIPipelineNodeType) => void
379+
addWebhookCD: (workflowId?: number | string) => void
380+
cdWorkflowList?: any[]
381+
showWebhookTippy?: boolean
382+
hideWebhookTippy?: () => void
383+
isJobView?: boolean
384+
envList?: any[]
385+
filteredCIPipelines?: any[]
386+
addNewPipelineBlocked?: boolean
387+
handleChangeCI?: (changeCIPayload: ChangeCIPayloadType) => void
388+
selectedNode?: SelectedNode
389+
handleSelectedNodeChange?: (selectedNode: SelectedNode) => void
390+
appName?: string
391+
getWorkflows?: () => void
392+
refreshParentWorkflows?: () => void
393+
reloadEnvironments?: () => void
394+
workflowPositionState?: WorkflowPositionState
395+
handleDisplayLoader?: () => void
396+
isOffendingPipelineView?: boolean
397+
}
398+
399+
export interface WorkflowState {
400+
top: number
401+
left: number
402+
showCIMenu: boolean
403+
}

0 commit comments

Comments
 (0)