Skip to content

Commit 35937ed

Browse files
authored
Merge pull request #2548 from devtron-labs/feat/ci-node-delete
feat: ci node delete component added
2 parents 3aed947 + 06dd433 commit 35937ed

File tree

20 files changed

+227
-185
lines changed

20 files changed

+227
-185
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,6 @@ src/components/workflowEditor/EmptyWorkflow.tsx
393393
src/components/workflowEditor/NoGitOpsConfiguredWarning.tsx
394394
src/components/workflowEditor/NoGitOpsRepoConfiguredWarning.tsx
395395
src/components/workflowEditor/PipelineSelect.tsx
396-
src/components/workflowEditor/ToggleCDSelectButton.tsx
397396
src/components/workflowEditor/Workflow.tsx
398397
src/components/workflowEditor/nodes/CDNode.tsx
399398
src/components/workflowEditor/nodes/CINode.tsx

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"homepage": "/dashboard",
66
"dependencies": {
7-
"@devtron-labs/devtron-fe-common-lib": "1.9.3",
7+
"@devtron-labs/devtron-fe-common-lib": "1.9.4",
88
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
99
"@rjsf/core": "^5.13.3",
1010
"@rjsf/utils": "^5.13.3",

src/Pages/GlobalConfigurations/Authorization/Shared/components/K8sObjectPermissions/K8sListItemCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ const K8sListItemCard = ({
446446
hideSelectedOptions={false}
447447
size={ComponentSizeType.large}
448448
/>
449-
<div className="dc__grid-row-one-half dc__gap-12 w-100">
449+
<div className="dc__grid-cols-2 dc__gap-12 w-100">
450450
<SelectPicker
451451
inputId="k8s-permission-select-api-group-dropdown"
452452
placeholder="Select API group"

src/components/CIPipelineN/CIPipeline.tsx

Lines changed: 15 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ import {
4848
getGlobalVariables,
4949
FloatingVariablesSuggestions,
5050
TriggerType,
51-
ERROR_STATUS_CODE,
52-
DeleteConfirmationModal,
51+
DeleteCINodeButton,
5352
} from '@devtron-labs/devtron-fe-common-lib'
5453
import Tippy from '@tippyjs/react'
5554
import {
@@ -60,7 +59,6 @@ import {
6059
} from '../common'
6160
import { BuildStageVariable, BuildTabText, JobPipelineTabText, URLS, ViewType } from '../../config'
6261
import {
63-
deleteCIPipeline,
6462
getInitData,
6563
getInitDataWithCIPipeline,
6664
saveCIPipeline,
@@ -73,7 +71,6 @@ import { Sidebar } from './Sidebar'
7371
import { Build } from './Build'
7472
import { ReactComponent as WarningTriangle } from '../../assets/icons/ic-warning.svg'
7573
import { getModuleInfo } from '../v2/devtronStackManager/DevtronStackManager.service'
76-
import { DeleteComponentsName, MULTI_REQUIRED_FIELDS_MSG } from '../../config/constantMessaging'
7774
import { LoadingState } from '../ciConfig/types'
7875
import { pipelineContext } from '../workflowEditor/workflowEditor'
7976
import { calculateLastStepDetailsLogic, checkUniqueness, validateTask } from '../cdPipeline/cdpipeline.util'
@@ -88,7 +85,6 @@ export default function CIPipeline({
8885
connectCDPipelines,
8986
getWorkflows,
9087
close,
91-
deleteWorkflow,
9288
isJobView,
9389
isJobCI,
9490
changeCIPayload,
@@ -120,7 +116,6 @@ export default function CIPipeline({
120116
failed: false,
121117
})
122118
const [apiInProgress, setApiInProgress] = useState<boolean>(false)
123-
const [showDeleteModal, setShowDeleteModal] = useState<boolean>(false)
124119
const [selectedTaskIndex, setSelectedTaskIndex] = useState<number>(0)
125120
const [globalVariables, setGlobalVariables] = useState<PipelineContext['globalVariables']>([])
126121
const [inputVariablesListFromPrevStep, setInputVariablesListFromPrevStep] = useState<{
@@ -536,38 +531,11 @@ export default function CIPipeline({
536531
close()
537532
}
538533

539-
const onDelete = async () => {
540-
await deleteCIPipeline(
541-
formData,
542-
ciPipeline,
543-
formData.materials,
544-
Number(appId),
545-
Number(workflowId),
546-
false,
547-
formData.webhookConditionList,
548-
)
534+
const onClose = () => {
549535
setPageState(ViewType.FORM)
550536
handleClose()
551-
deleteWorkflow(appId, Number(workflowId))
552-
}
553-
554-
const closeCIDeleteModal = (): void => {
555-
setShowDeleteModal(false)
556537
}
557538

558-
const renderDeleteCIModal = () => (
559-
<DeleteConfirmationModal
560-
title={formData.name}
561-
component={isJobView ? DeleteComponentsName.Job : DeleteComponentsName.BuildPipeline}
562-
subtitle={`Are you sure you want to delete this pipeline from '${appName}' ?`}
563-
closeConfirmationModal={closeCIDeleteModal}
564-
onDelete={onDelete}
565-
errorCodeToShowCannotDeleteDialog={ERROR_STATUS_CODE.BAD_REQUEST}
566-
renderCannotDeleteConfirmationSubTitle="Please delete deployment pipelines for this workflow first and try again."
567-
successToastMessage="Pipeline Deleted"
568-
/>
569-
)
570-
571539
const renderSecondaryButton = () => {
572540
if (ciPipelineId) {
573541
const canDeletePipeline = connectCDPipelines === 0 && ciPipeline.linkedCount === 0
@@ -584,17 +552,21 @@ export default function CIPipeline({
584552
</Tippy>
585553
)}
586554
>
587-
<button
588-
data-testid="ci-delete-pipeline-button"
589-
type="button"
590-
className="cta cta--workflow delete mr-16"
555+
<DeleteCINodeButton
556+
testId="ci-delete-pipeline-button"
591557
disabled={!canDeletePipeline}
592-
onClick={() => {
593-
setShowDeleteModal(true)
558+
showIconOnly={false}
559+
isJobView={isJobView}
560+
title={ciPipeline.name}
561+
deletePayloadConfig={{
562+
appId: appId,
563+
appWorkflowId: Number(workflowId),
564+
pipelineId: Number(ciPipelineId),
565+
pipelineName: ciPipeline.name,
594566
}}
595-
>
596-
Delete Pipeline
597-
</button>
567+
onDelete={onClose}
568+
getWorkflows={getWorkflows}
569+
/>
598570
</ConditionalWrap>
599571
)
600572
}
@@ -921,7 +893,6 @@ export default function CIPipeline({
921893
)}
922894
</div>
923895
)}
924-
{ciPipelineId && showDeleteModal && renderDeleteCIModal()}
925896
</>
926897
)
927898
}

src/components/CIPipelineN/CreatePluginModal/CreatePluginFormContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ const CreatePluginFormContent = ({
234234
/>
235235
)}
236236

237-
<div className="dc__grid-row-one-half dc__column-gap-12">
237+
<div className="dc__grid-cols-2 dc__column-gap-12">
238238
{/* Existing plugin / display name */}
239239
{renderPluginName()}
240240

@@ -265,7 +265,7 @@ const CreatePluginFormContent = ({
265265
rootClassName: 'flex-grow-1',
266266
}}
267267
>
268-
<div className="dc__grid-row-one-half dc__column-gap-12">
268+
<div className="dc__grid-cols-2 dc__column-gap-12">
269269
{/* New Version / Plugin Version */}
270270
<CreatePluginFormField
271271
label={renderPluginVersionLabel()}

src/components/ClusterNodes/ClusterOverview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ function ClusterOverview({ selectedCluster, addTab }: ClusterOverviewProps) {
326326
<>
327327
{/* Commented to be used in future */}
328328
{/* {cardDetailsInBar()} */}
329-
<div className="dc__grid-row-one-half dc__gap-16 pb-16">
329+
<div className="dc__grid-cols-2 dc__gap-16 pb-16">
330330
<div className="flexbox dc__gap-12 dc__content-space dc__overflow-auto bg__primary br-4 en-2 bw-1 pt-16 pl-16 pb-16 pr-16">
331331
<div>
332332
<div className="dc__align-left fs-13 fw-4 cn-7 dc__ellipsis-right">CPU Usage</div>

src/components/ciPipeline/LinkedCIPipelineView.tsx

Lines changed: 41 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ import {
2828
ToastVariantType,
2929
ToastManager,
3030
TriggerType,
31-
DeleteConfirmationModal,
32-
ERROR_STATUS_CODE,
31+
Button,
32+
ButtonVariantType,
33+
ButtonStyleType,
34+
DeleteCINodeButton,
3335
} from '@devtron-labs/devtron-fe-common-lib'
3436
import { Link } from 'react-router-dom'
3537
import Tippy from '@tippyjs/react'
36-
import { getInitDataWithCIPipeline, deleteCIPipeline } from './ciPipeline.service'
38+
import { getInitDataWithCIPipeline } from './ciPipeline.service'
3739
import { ViewType, URLS } from '../../config'
3840
import { CIPipelineProps, CIPipelineState } from './types'
3941
import { getCIPipelineURL, Info } from '../common'
@@ -42,7 +44,6 @@ import { ReactComponent as Close } from '../../assets/icons/ic-close.svg'
4244
import { ReactComponent as Warning } from '../../assets/icons/ic-warning.svg'
4345
import { SourceMaterials } from './SourceMaterials'
4446
import './ciPipeline.scss'
45-
import { DeleteComponentsName } from '@Config/constantMessaging'
4647

4748
export default class LinkedCIPipelineView extends Component<CIPipelineProps, CIPipelineState> {
4849
constructor(props) {
@@ -103,7 +104,7 @@ export default class LinkedCIPipelineView extends Component<CIPipelineProps, CIP
103104
})
104105
.catch((error: ServerErrors) => {
105106
showError(error)
106-
this.setState({ loadingData: false })
107+
this.setState({ loadingData: false, view: ViewType.FORM })
107108
})
108109
}
109110

@@ -164,25 +165,6 @@ export default class LinkedCIPipelineView extends Component<CIPipelineProps, CIP
164165
}
165166
}
166167

167-
onDelete = async () => {
168-
await deleteCIPipeline(
169-
this.state.form,
170-
this.state.ciPipeline,
171-
this.state.form.materials,
172-
+this.props.match.params.appId,
173-
+this.props.match.params.workflowId,
174-
this.state.ciPipeline.isExternal,
175-
this.state.form.webhookConditionList,
176-
)
177-
this.props.close()
178-
179-
if (this.props.deleteWorkflow) {
180-
this.props.deleteWorkflow(this.props.match.params.appId, +this.props.match.params.workflowId)
181-
} else {
182-
this.props.getWorkflows()
183-
}
184-
}
185-
186168
renderInfoDialog() {
187169
return (
188170
<div className="dc__info-container info__container--linked-ci mb-16">
@@ -226,23 +208,36 @@ export default class LinkedCIPipelineView extends Component<CIPipelineProps, CIP
226208
)
227209
}
228210

211+
onClose = () => this.props.close() // Need to fix this: while direct use of close in onclick opening What do you want to do next? modal
212+
229213
renderHeader() {
230214
return (
231-
<>
232-
<div className="flex left pt-15 pb-15 pl-20 pr-20">
233-
<h2 className="fs-16 fw-6 m-0">Linked build pipeline</h2>
234-
<button type="button" className="dc__transparent ml-auto" onClick={() => this.props.close()}>
235-
<Close className="icon-dim-24" />
236-
</button>
237-
</div>
238-
<hr className="divider mt-0" />
239-
</>
215+
<div className="flex left py-16 px-20 dc__content-space dc__border-bottom">
216+
<h2 className="fs-16 fw-6 m-0">Linked build pipeline</h2>
217+
<Button
218+
dataTestId="linked-ci-pipeline-close-button"
219+
icon={<Close />}
220+
ariaLabel="Close"
221+
showAriaLabelInTippy={false}
222+
onClick={this.onClose}
223+
variant={ButtonVariantType.borderLess}
224+
style={ButtonStyleType.negativeGrey}
225+
/>
226+
</div>
240227
)
241228
}
242229

243-
renderSecondaryButtton() {
230+
renderDeleteButton() {
231+
const canDeletePipeline = this.props.connectCDPipelines === 0 && this.state.ciPipeline.linkedCount === 0
232+
233+
const deleteConfig = {
234+
appId: this.props.match.params.appId,
235+
pipelineId: this.state.ciPipeline.id,
236+
pipelineName: this.state.ciPipeline.name,
237+
appWorkflowId: Number(this.props.match.params.workflowId),
238+
}
239+
244240
if (this.props.match.params.ciPipelineId) {
245-
const canDeletePipeline = this.props.connectCDPipelines === 0 && this.state.ciPipeline.linkedCount === 0
246241
return (
247242
<ConditionalWrap
248243
condition={!canDeletePipeline}
@@ -255,17 +250,15 @@ export default class LinkedCIPipelineView extends Component<CIPipelineProps, CIP
255250
</Tippy>
256251
)}
257252
>
258-
<button
259-
type="button"
260-
className="cta cta--workflow delete mr-16"
253+
<DeleteCINodeButton
254+
testId="delete-linked-pipeline"
261255
disabled={!canDeletePipeline}
262-
onClick={() => {
263-
this.setState({ showDeleteModal: true })
264-
}}
265-
data-testid="delete-linked-pipeline"
266-
>
267-
Delete Pipeline
268-
</button>
256+
deletePayloadConfig={deleteConfig}
257+
title={this.state.form.name}
258+
getWorkflows={this.props.getWorkflows}
259+
showIconOnly={false}
260+
onDelete={this.onClose}
261+
/>
269262
</ConditionalWrap>
270263
)
271264
}
@@ -297,17 +290,6 @@ export default class LinkedCIPipelineView extends Component<CIPipelineProps, CIP
297290
</label>
298291
{this.renderTriggerType()}
299292
{this.renderMaterials()}
300-
{this.props.match.params.ciPipelineId && this.state.showDeleteModal && (
301-
<DeleteConfirmationModal
302-
title={this.state.form.name}
303-
component={DeleteComponentsName.LinkedBuildPipeline}
304-
subtitle={`Are you sure you want to delete this linked CI Pipeline from '${this.props.appName}' ?`}
305-
closeConfirmationModal={this.closeCIDeleteModal}
306-
onDelete={this.onDelete}
307-
successToastMessage="Pipeline Deleted"
308-
errorCodeToShowCannotDeleteDialog={ERROR_STATUS_CODE.BAD_REQUEST}
309-
/>
310-
)}
311293
</>
312294
)
313295
}
@@ -317,13 +299,13 @@ export default class LinkedCIPipelineView extends Component<CIPipelineProps, CIP
317299
<VisibleModal className="">
318300
<div className="modal__body p-0 br-0 modal__body--ci">
319301
{this.renderHeader()}
320-
<div className="pl-20 pr-20 pb-20">
302+
<div className="px-20 py-16">
321303
{this.renderInfoDialog()}
322304
{this.renderCIPipelineBody()}
323305
</div>
324306
{this.state.view !== ViewType.LOADING && (
325-
<div className="ci-button-container bg__primary pt-12 pb-12 pl-20 pr-20 flex flex-justify">
326-
{this.renderSecondaryButtton()}
307+
<div className="ci-button-container py-12 px-20 flex flex-justify dc__gap-16">
308+
{this.renderDeleteButton()}
327309
<Link
328310
to={this.state.sourcePipelineURL}
329311
target="_blank"

src/components/ciPipeline/ciPipeline.service.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,15 @@ export function deleteCIPipeline(
293293
isExternalCI: boolean,
294294
webhookConditionList,
295295
) {
296-
const ci = createCIPatchRequest(ciPipeline, formData, isExternalCI, webhookConditionList)
296+
const updatedCI = {
297+
id: ciPipeline.id,
298+
name: formData.name,
299+
}
297300
const request = {
298301
appId,
299302
appWorkflowId: workflowId,
300303
action: PatchAction.DELETE,
301-
ciPipeline: ci,
304+
ciPipeline: updatedCI,
302305
}
303306
return savePipeline(request).then((response) => {
304307
return parseCIResponse(

src/components/ciPipeline/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ export interface CIPipelineType {
278278
connectCDPipelines: number
279279
getWorkflows: () => void
280280
close: () => void
281-
deleteWorkflow: (appId?: string, workflowId?: number) => any
282281
isJobView?: boolean
283282
isJobCI?: boolean
284283
changeCIPayload?: ChangeCIPayloadType
@@ -344,7 +343,6 @@ export interface CIPipelineProps
344343
connectCDPipelines: number
345344
getWorkflows: () => void
346345
close: () => void
347-
deleteWorkflow?: (appId?: string, workflowId?: number) => any
348346
changeCIPayload?: ChangeCIPayloadType
349347
}
350348

src/components/globalConfigurations/GlobalConfiguration.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export default function GlobalConfiguration(props) {
157157
<section className="global-configuration__navigation">
158158
<NavItem serverMode={serverMode} />
159159
</section>
160-
<section className="global-configuration__component-wrapper">
160+
<section className="global-configuration__component-wrapper bg__secondary">
161161
<Suspense fallback={<Progressing pageLoader />}>
162162
<ErrorBoundary>
163163
<Body

0 commit comments

Comments
 (0)