From 04758022f5aa96528fc78553fd1cdffacfac58a0 Mon Sep 17 00:00:00 2001 From: Mukul Tayal Date: Tue, 28 Nov 2023 14:00:21 +0530 Subject: [PATCH 1/6] temp git optional --- .../Details/EnvCIDetails/EnvCIDetails.tsx | 1 + src/components/CIPipelineN/Build.tsx | 66 ++++++++++++++----- src/components/CIPipelineN/CIPipeline.tsx | 5 +- .../app/details/cIDetails/CIDetails.tsx | 29 ++++---- .../app/details/cIDetails/types.tsx | 2 + .../app/details/triggerView/types.ts | 1 + .../details/triggerView/workflow.service.ts | 6 +- .../ciPipeline/ciPipeline.service.ts | 6 +- src/components/ciPipeline/types.ts | 4 ++ src/components/workflowEditor/Workflow.tsx | 26 ++++++-- 10 files changed, 107 insertions(+), 39 deletions(-) diff --git a/src/components/ApplicationGroup/Details/EnvCIDetails/EnvCIDetails.tsx b/src/components/ApplicationGroup/Details/EnvCIDetails/EnvCIDetails.tsx index 4730ed06b3..3d1de66e35 100644 --- a/src/components/ApplicationGroup/Details/EnvCIDetails/EnvCIDetails.tsx +++ b/src/components/ApplicationGroup/Details/EnvCIDetails/EnvCIDetails.tsx @@ -207,6 +207,7 @@ export default function EnvCIDetails({ filteredAppIds }: AppGroupDetailDefaultTy hideImageTaggingHardDelete={hideImageTaggingHardDelete} fetchIdData={fetchBuildIdData} isJobCI={pipeline.pipelineType === CIPipelineBuildType.CI_JOB} + pipeline={pipeline} /> ) diff --git a/src/components/CIPipelineN/Build.tsx b/src/components/CIPipelineN/Build.tsx index 80687f9753..3cd12919cf 100644 --- a/src/components/CIPipelineN/Build.tsx +++ b/src/components/CIPipelineN/Build.tsx @@ -1,10 +1,10 @@ -import React, { useContext } from 'react' +import React, { useContext, useEffect } from 'react' import { SourceTypeMap, ViewType } from '../../config' import { createWebhookConditionList } from '../ciPipeline/ciPipeline.service' import { SourceMaterials } from '../ciPipeline/SourceMaterials' import { ValidationRules } from '../ciPipeline/validationRules' import { Progressing, Toggle, CiPipelineSourceTypeOption } from '@devtron-labs/devtron-fe-common-lib' -import { BuildType, WebhookCIProps } from '../ciPipeline/types' +import { BuildType, CIPipelineBuildType, WebhookCIProps } from '../ciPipeline/types' import { ReactComponent as AlertTriangle } from '../../assets/icons/ic-alert-triangle.svg' import { ReactComponent as BugScanner } from '../../assets/icons/scanner.svg' import AdvancedConfigOptions from './AdvancedConfigOptions' @@ -13,12 +13,14 @@ import { pipelineContext } from '../workflowEditor/workflowEditor' export function Build({ showFormError, isAdvanced, - ciPipeline, + ciPipeline, pageState, isSecurityModuleInstalled, setDockerConfigOverridden, isJobView, getPluginData, + setCIPipeline, + isJobCI, }: BuildType) { const { formData, @@ -26,6 +28,12 @@ export function Build({ formDataErrorObj, setFormDataErrorObj, } = useContext(pipelineContext) + const [isGitRequired, setIsGitRequired] = React.useState(false) + + useEffect(() => { + setIsGitRequired(ciPipeline.isGitRequired) + },[ciPipeline]) + const validationRules = new ValidationRules() const handleSourceChange = (event, gitMaterialId: number, sourceType: string): void => { const _formData = { ...formData } @@ -169,23 +177,25 @@ export function Build({ onWebhookConditionSelectorChange: onWebhookConditionSelectorChange, onWebhookConditionSelectorValueChange: onWebhookConditionSelectorValueChange, } - return ( <> {isAdvanced && renderPipelineName()} - + {isJobCI && renderGitRepoToggle()} + {((isJobCI && isGitRequired) || !isJobCI) && ( + + )} ) } @@ -223,6 +233,28 @@ export function Build({ ) } + const renderGitRepoToggle = () => { + return ( +
+
+
Pull code from git respository
+
+ { + setIsGitRequired(!isGitRequired) + setCIPipeline({ ...ciPipeline, isGitRequired: !isGitRequired }) + }} + /> +
+
+
+ When enabled, Devtron pulls code from the git repository which can be used by tasks in this pipeline +
+
+ ) + } + const renderScanner = () => { return ( <> diff --git a/src/components/CIPipelineN/CIPipeline.tsx b/src/components/CIPipelineN/CIPipeline.tsx index 0af2c448d0..7afd4c35fa 100644 --- a/src/components/CIPipelineN/CIPipeline.tsx +++ b/src/components/CIPipelineN/CIPipeline.tsx @@ -577,6 +577,7 @@ export default function CIPipeline({ false, formData.webhookConditionList, formData.ciPipelineSourceTypeOptions, + ) .then((response) => { if (response) { @@ -814,7 +815,9 @@ export default function CIPipeline({ setDockerConfigOverridden={setDockerConfigOverridden} isJobView={isJobCard} getPluginData={getPluginData} - /> + setCIPipeline={setCIPipeline} + isJobCI={isJobCI} + /> diff --git a/src/components/app/details/cIDetails/CIDetails.tsx b/src/components/app/details/cIDetails/CIDetails.tsx index cdc953316d..83cec24c37 100644 --- a/src/components/app/details/cIDetails/CIDetails.tsx +++ b/src/components/app/details/cIDetails/CIDetails.tsx @@ -52,6 +52,7 @@ export default function CIDetails({ isJobView, filteredEnvIds }: { isJobView?: b ]), [appId, filteredEnvIds], ) + console.log(initDataResults) const [loading, triggerHistoryResult, , , , dependencyState] = useAsync( () => getTriggerHistory(+pipelineId, pagination), [pipelineId, pagination], @@ -224,6 +225,8 @@ export default function CIDetails({ isJobView, filteredEnvIds }: { isJobView?: b hideImageTaggingHardDelete={hideImageTaggingHardDelete} fetchIdData={fetchBuildIdData} isJobCI={pipeline.pipelineType === CIPipelineBuildType.CI_JOB} + pipeline={pipeline} + /> ) : pipeline.parentCiPipeline || pipeline.pipelineType === 'LINKED' ? ( @@ -268,6 +271,7 @@ export const Details = ({ appReleaseTags, hideImageTaggingHardDelete, fetchIdData, + pipeline }: BuildDetails) => { const isJobCard: boolean = isJobView || isJobCI const { pipelineId, appId, buildId } = useParams<{ appId: string; buildId: string; pipelineId: string }>() @@ -353,6 +357,7 @@ export const Details = ({ if (!areTagDetailsRequired && !triggerDetailsLoading && !triggerDetails) return if (areTagDetailsRequired && !(tagDetailsLoading || triggerDetailsLoading) && !triggerDetails) return if (triggerDetails.id !== +buildId) return null + console.log('sdfsdf',pipeline.isGitRequired) return ( <>
@@ -386,17 +391,19 @@ export const Details = ({ Logs -
  • - - Source - -
  • + {isJobCI && pipeline.isGitRequired && ( +
  • + + Source + +
  • + )}
  • @@ -20,6 +21,7 @@ export interface BuildDetails { tagsEditable: boolean hideImageTaggingHardDelete: boolean fetchIdData: FetchIdDataStatus + pipeline:CIPipeline } export interface HistoryLogsType { diff --git a/src/components/app/details/triggerView/types.ts b/src/components/app/details/triggerView/types.ts index 2a97f5c2ef..205cfe79cd 100644 --- a/src/components/app/details/triggerView/types.ts +++ b/src/components/app/details/triggerView/types.ts @@ -532,6 +532,7 @@ export interface CiPipeline { } isOffendingMandatoryPlugin?: boolean pipelineType?: string + isGitRequired?: boolean } export interface Material { diff --git a/src/components/app/details/triggerView/workflow.service.ts b/src/components/app/details/triggerView/workflow.service.ts index 76f6d05547..06c83e224f 100644 --- a/src/components/app/details/triggerView/workflow.service.ts +++ b/src/components/app/details/triggerView/workflow.service.ts @@ -80,6 +80,7 @@ const getInitialWorkflows = ( } else { return Promise.all([getWorkflowList(id, filteredEnvIds), getCIConfig(id), getCDConfig(id), getExternalCIList(id)]).then( ([workflow, ciConfig, cdConfig, externalCIConfig]) => { + console.log('ciConfig', ciConfig) return processWorkflow( workflow.result as WorkflowResult, ciConfig.result as CiPipelineResult, @@ -156,7 +157,7 @@ export function processWorkflow( ) const appName = workflow.appName let workflows = new Array() - + console.log("workflow.workflows",workflow.workflows) //populate workflows with CI and CD nodes, sourceNodes are inside CI nodes and PreCD and PostCD nodes are inside CD nodes workflow.workflows ?.sort((a, b) => a.id - b.id) @@ -443,7 +444,8 @@ function ciPipelineToNode(ciPipeline: CiPipeline, dimensions: WorkflowDimensions isRegex: ciMaterial?.isRegex, primaryBranchAfterRegex: ciMaterial?.source?.value, cipipelineId: ciMaterial?.id, - isJobCI: ciPipeline?.pipelineType === CIPipelineBuildType.CI_JOB + isJobCI: ciPipeline?.pipelineType === CIPipelineBuildType.CI_JOB, + isGitRequired: ciPipeline?.isGitRequired } as NodeAttr }) let trigger = ciPipeline.isManual ? TriggerType.Manual.toLocaleLowerCase() : TriggerType.Auto.toLocaleLowerCase() diff --git a/src/components/ciPipeline/ciPipeline.service.ts b/src/components/ciPipeline/ciPipeline.service.ts index 4f17280678..e443b8178d 100644 --- a/src/components/ciPipeline/ciPipeline.service.ts +++ b/src/components/ciPipeline/ciPipeline.service.ts @@ -156,7 +156,7 @@ export function getInitDataWithCIPipeline( ]).then(([ciPipelineRes, pipelineMetaConfig]) => { const ciPipeline = ciPipelineRes?.result const pipelineMetaConfigResult = pipelineMetaConfig?.result - return parseCIResponse( + const x= parseCIResponse( pipelineMetaConfig.code, ciPipeline, pipelineMetaConfigResult.materials, @@ -164,6 +164,8 @@ export function getInitDataWithCIPipeline( pipelineMetaConfigResult.webhookEvents, pipelineMetaConfigResult.ciPipelineSourceTypeOptions, ) + console.log('sdfsdf',x) + return x; }) } @@ -476,6 +478,8 @@ function parseCIResponse( ciPipeline: ciPipeline, form: { name: ciPipeline.name, + pipelineType: ciPipeline.pipelineType, + isGitRequired: ciPipeline.isGitRequired, triggerType: ciPipeline.isManual ? TriggerType.Manual : TriggerType.Auto, materials: materials, args: args.length ? args : [], diff --git a/src/components/ciPipeline/types.ts b/src/components/ciPipeline/types.ts index f2537c2555..abf7f71a1d 100644 --- a/src/components/ciPipeline/types.ts +++ b/src/components/ciPipeline/types.ts @@ -283,6 +283,7 @@ export interface CIPipelineDataType { environmentId?: any pipelineType?: string customTag?: CustomTagType + isGitRequired?: boolean } export interface CIPipelineState { code: number @@ -367,6 +368,7 @@ export interface SourceMaterialsProps { isBranchRegex?: (material) => boolean isAdvanced?: boolean handleOnBlur?: (event) => void + isGitRequired?: boolean } export interface WebhookCIProps { @@ -389,6 +391,8 @@ export interface BuildType { setDockerConfigOverridden: React.Dispatch> isJobView?: boolean getPluginData: (_formData?: PipelineFormType) => void + setCIPipeline: React.Dispatch> + isJobCI?: boolean } export interface PreBuildType { diff --git a/src/components/workflowEditor/Workflow.tsx b/src/components/workflowEditor/Workflow.tsx index 81c4580624..c71ddfb5ec 100644 --- a/src/components/workflowEditor/Workflow.tsx +++ b/src/components/workflowEditor/Workflow.tsx @@ -151,14 +151,16 @@ export class Workflow extends Component { const webhook = this.props.nodes.find((node) => node.type == WorkflowNodeType.WEBHOOK) const _nodesData = this.getNodesData(ci?.id || webhook?.id || '') const _nodes = _nodesData.nodes - if (ci) { return _nodes.map((node: NodeAttr) => { if (node.type == WorkflowNodeType.GIT) { - return this.renderSourceNode(node, ci) + console.log('1') + return ((node.isJobCI && node.isGitRequired) || !node.isJobCI) && this.renderSourceNode(node, ci) } else if (node.type == WorkflowNodeType.CI) { + console.log('2;') return this.renderCINodes(node) } else if (_nodesData.cdNamesList.length > 0) { + console.log('3') return ( <> {this.renderAdditionalEdge()} @@ -166,6 +168,7 @@ export class Workflow extends Component { ) } + console.log('4') return this.renderCDNodes(node, ci.id, false) }) @@ -374,6 +377,7 @@ export class Workflow extends Component { } getEdges() { + console.log('this.props.nodes', this.props.nodes) return this.props.nodes.reduce((edgeList, node) => { node.downstreams.forEach((downStreamNodeId) => { const endNode = this.props.nodes.find((val) => val.type + '-' + val.id == downStreamNodeId) @@ -381,6 +385,9 @@ export class Workflow extends Component { startNode: node, endNode: endNode, }) + if (node.type === WorkflowNodeType.GIT && node.isJobCI && !node.isGitRequired) { + edgeList.pop() + } }) return edgeList }, []) @@ -393,6 +400,7 @@ export class Workflow extends Component { renderEdgeList() { const edges = this.getEdges() + console.log('edges', edges.length,edges); return this.getEdges().map((edgeNode) => { if (ApprovalNodeEdge) { return ( @@ -405,7 +413,7 @@ export class Workflow extends Component { /> ) } - + console.log('edgeNode', edgeNode) return ( {
  • {isExternalCiWorkflow && }
    - - {this.renderEdgeList()} - {this.renderNodes()} - + {this.getEdges().length == 0 ? ( + this.emptyWorkflow() + ) : ( + + {this.renderEdgeList()} + {this.renderNodes()} + + )} {!configDiffView && ( Date: Wed, 29 Nov 2023 09:34:54 +0530 Subject: [PATCH 2/6] positioning of nodes in workflow editor --- src/components/CIPipelineN/CIPipeline.tsx | 3 ++ .../details/triggerView/workflow.service.ts | 6 ++-- src/components/ciPipeline/validationRules.ts | 1 + src/components/workflowEditor/Workflow.tsx | 36 ++++++++++++------- .../workflowEditor/workflowEditor.tsx | 1 + 5 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/components/CIPipelineN/CIPipeline.tsx b/src/components/CIPipelineN/CIPipeline.tsx index 7afd4c35fa..98ae078191 100644 --- a/src/components/CIPipelineN/CIPipeline.tsx +++ b/src/components/CIPipelineN/CIPipeline.tsx @@ -516,6 +516,7 @@ export default function CIPipeline({ toast.error('Scanning is mandatory, please enable scanning') return } + console.log('materials', formData) if ( !formDataErrorObj.buildStage.isValid || @@ -523,6 +524,7 @@ export default function CIPipeline({ !formDataErrorObj.postBuildStage.isValid ) { setApiInProgress(false) + console.log('materials', formData) const branchNameNotPresent = formData.materials.some((_mat) => !_mat.value) if (formData.name === '' || branchNameNotPresent) { toast.error(MULTI_REQUIRED_FIELDS_MSG) @@ -605,6 +607,7 @@ export default function CIPipeline({ isValid = isValid && validationRules.sourceValue(mat.regex || mat.value, mat.type !== SourceTypeMap.WEBHOOK).isValid + console.log('isValid', isValid,mat) return isValid }, true) if (_formData.materials.length > 1) { diff --git a/src/components/app/details/triggerView/workflow.service.ts b/src/components/app/details/triggerView/workflow.service.ts index 06c83e224f..63b2d3ed90 100644 --- a/src/components/app/details/triggerView/workflow.service.ts +++ b/src/components/app/details/triggerView/workflow.service.ts @@ -220,7 +220,7 @@ export function processWorkflow( if (dimensions.type == WorkflowDimensionType.TRIGGER) { workflows = workflows.filter((wf) => wf.nodes.length > 0) } - + console.log('workflows before', workflows) addDimensions(workflows, workflowOffset, dimensions) return { appName, workflows, filteredCIPipelines } } @@ -235,11 +235,13 @@ function addDimensions(workflows: WorkflowType[], workflowOffset: Offset, dimens if (workflow.nodes.length == 0) { return } - + console.log('each workflow', workflow) const ciNode = workflow.nodes.find( (node) => node.type == WorkflowNodeType.CI || node.type == WorkflowNodeType.WEBHOOK, ) + console.log('ciNode', ciNode.sourceNodes) ciNode.sourceNodes?.forEach((s, si) => { + console.log('s', s) const sourceNodeY = startY + workflowOffset.offsetY + diff --git a/src/components/ciPipeline/validationRules.ts b/src/components/ciPipeline/validationRules.ts index 7e4cd6556a..58f0b41868 100644 --- a/src/components/ciPipeline/validationRules.ts +++ b/src/components/ciPipeline/validationRules.ts @@ -112,6 +112,7 @@ export class ValidationRules { sourceValue = (value: string, doRegexValidation = true): { message: string | null; isValid: boolean } => { if (!value) { + console.log('value here', value) return { message: `This is required`, isValid: false } } else { if (doRegexValidation) { diff --git a/src/components/workflowEditor/Workflow.tsx b/src/components/workflowEditor/Workflow.tsx index c71ddfb5ec..979f44e0b6 100644 --- a/src/components/workflowEditor/Workflow.tsx +++ b/src/components/workflowEditor/Workflow.tsx @@ -145,22 +145,31 @@ export class Workflow extends Component { ) } + getPositionedNodes(nodes) { + let offsetx = 0 + return nodes.reduce((newNodes, node) => { + node.x -= offsetx + newNodes.push(node) + if (node.type === WorkflowNodeType.GIT && node.isJobCI && !node.isGitRequired) { + newNodes.pop() + offsetx += node.width + 60 + } + return newNodes + }, []) + } renderNodes() { const ci = this.props.nodes.find((node) => node.type == WorkflowNodeType.CI) const webhook = this.props.nodes.find((node) => node.type == WorkflowNodeType.WEBHOOK) const _nodesData = this.getNodesData(ci?.id || webhook?.id || '') - const _nodes = _nodesData.nodes + const _nodes =this.getPositionedNodes( JSON.parse(JSON.stringify(_nodesData.nodes))) if (ci) { return _nodes.map((node: NodeAttr) => { if (node.type == WorkflowNodeType.GIT) { - console.log('1') return ((node.isJobCI && node.isGitRequired) || !node.isJobCI) && this.renderSourceNode(node, ci) } else if (node.type == WorkflowNodeType.CI) { - console.log('2;') return this.renderCINodes(node) } else if (_nodesData.cdNamesList.length > 0) { - console.log('3') return ( <> {this.renderAdditionalEdge()} @@ -168,8 +177,6 @@ export class Workflow extends Component { ) } - console.log('4') - return this.renderCDNodes(node, ci.id, false) }) } else if (webhook) { @@ -377,16 +384,20 @@ export class Workflow extends Component { } getEdges() { - console.log('this.props.nodes', this.props.nodes) - return this.props.nodes.reduce((edgeList, node) => { + const nodes = JSON.parse(JSON.stringify(this.props.nodes)) + let offsetx = 0 + return nodes.reduce((edgeList, node) => { node.downstreams.forEach((downStreamNodeId) => { - const endNode = this.props.nodes.find((val) => val.type + '-' + val.id == downStreamNodeId) + const endNode = nodes.find((val) => val.type + '-' + val.id == downStreamNodeId) + node.x -= offsetx + endNode.x -= offsetx edgeList.push({ startNode: node, endNode: endNode, }) if (node.type === WorkflowNodeType.GIT && node.isJobCI && !node.isGitRequired) { edgeList.pop() + offsetx += node.width + 60 } }) return edgeList @@ -400,8 +411,8 @@ export class Workflow extends Component { renderEdgeList() { const edges = this.getEdges() - console.log('edges', edges.length,edges); - return this.getEdges().map((edgeNode) => { + console.log('edges', edges) + return edges.map((edgeNode) => { if (ApprovalNodeEdge) { return ( { /> ) } - console.log('edgeNode', edgeNode) return ( {
    {isExternalCiWorkflow && }
    - {this.getEdges().length == 0 ? ( + {this.props.nodes.length == 0 ? ( this.emptyWorkflow() ) : ( diff --git a/src/components/workflowEditor/workflowEditor.tsx b/src/components/workflowEditor/workflowEditor.tsx index b0a07e95ac..9ea6697c73 100644 --- a/src/components/workflowEditor/workflowEditor.tsx +++ b/src/components/workflowEditor/workflowEditor.tsx @@ -112,6 +112,7 @@ class WorkflowEdit extends Component { const allDeploymentNodeMap = new Map() let isDeletionInProgress const _envIds = [] + console.log('workflow',result) for (const workFlow of result.workflows) { for (const node of workFlow.nodes) { if (node.type === WorkflowNodeType.CI) { From f1356819af6d8805d77a97dcb367d698fcdc8def Mon Sep 17 00:00:00 2001 From: Mukul Tayal Date: Wed, 29 Nov 2023 16:58:49 +0530 Subject: [PATCH 3/6] git node not visible in case of git not required --- src/components/CIPipelineN/Build.tsx | 7 ++----- src/components/CIPipelineN/CIPipeline.tsx | 15 ++++++++++++--- .../app/details/cIDetails/CIDetails.tsx | 2 -- .../app/details/triggerView/workflow.service.ts | 6 ------ src/components/ciPipeline/ciPipeline.service.ts | 1 - src/components/ciPipeline/types.ts | 2 ++ src/components/ciPipeline/validationRules.ts | 1 - src/components/workflowEditor/Workflow.tsx | 1 - src/components/workflowEditor/workflowEditor.tsx | 1 - 9 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/components/CIPipelineN/Build.tsx b/src/components/CIPipelineN/Build.tsx index 3cd12919cf..035b57cdea 100644 --- a/src/components/CIPipelineN/Build.tsx +++ b/src/components/CIPipelineN/Build.tsx @@ -21,6 +21,8 @@ export function Build({ getPluginData, setCIPipeline, isJobCI, + isGitRequired, + setIsGitRequired }: BuildType) { const { formData, @@ -28,11 +30,6 @@ export function Build({ formDataErrorObj, setFormDataErrorObj, } = useContext(pipelineContext) - const [isGitRequired, setIsGitRequired] = React.useState(false) - - useEffect(() => { - setIsGitRequired(ciPipeline.isGitRequired) - },[ciPipeline]) const validationRules = new ValidationRules() const handleSourceChange = (event, gitMaterialId: number, sourceType: string): void => { diff --git a/src/components/CIPipelineN/CIPipeline.tsx b/src/components/CIPipelineN/CIPipeline.tsx index 98ae078191..f97bfb83f7 100644 --- a/src/components/CIPipelineN/CIPipeline.tsx +++ b/src/components/CIPipelineN/CIPipeline.tsx @@ -110,6 +110,7 @@ export default function CIPipeline({ const [isSecurityModuleInstalled, setSecurityModuleInstalled] = useState(false) const [selectedEnv, setSelectedEnv] = useState() const [environments, setEnvironments] = useState([]) + const [isGitRequired, setIsGitRequired] = useState(true) const [formData, setFormData] = useState({ name: '', args: [], @@ -181,6 +182,11 @@ export default function CIPipeline({ const [isDockerConfigOverridden, setDockerConfigOverridden] = useState(false) const [mandatoryPluginData, setMandatoryPluginData] = useState(null) const selectedBranchRef = useRef(null) + + useEffect(() => { + setIsGitRequired(ciPipeline?.isGitRequired ?? true) + }, [ciPipeline]) + const mandatoryPluginsMap: Record = useMemo(() => { const _mandatoryPluginsMap: Record = {} @@ -516,7 +522,6 @@ export default function CIPipeline({ toast.error('Scanning is mandatory, please enable scanning') return } - console.log('materials', formData) if ( !formDataErrorObj.buildStage.isValid || @@ -524,7 +529,6 @@ export default function CIPipeline({ !formDataErrorObj.postBuildStage.isValid ) { setApiInProgress(false) - console.log('materials', formData) const branchNameNotPresent = formData.materials.some((_mat) => !_mat.value) if (formData.name === '' || branchNameNotPresent) { toast.error(MULTI_REQUIRED_FIELDS_MSG) @@ -563,6 +567,7 @@ export default function CIPipeline({ ciPipelineType = CIPipelineBuildType.CI_EXTERNAL } else if (isJobCI) { ciPipelineType = CIPipelineBuildType.CI_JOB + _ciPipeline.isGitRequired = isGitRequired } _ciPipeline.pipelineType = ciPipeline.id ? ciPipeline.pipelineType : ciPipelineType } @@ -579,6 +584,7 @@ export default function CIPipeline({ false, formData.webhookConditionList, formData.ciPipelineSourceTypeOptions, + ) .then((response) => { @@ -607,9 +613,10 @@ export default function CIPipeline({ isValid = isValid && validationRules.sourceValue(mat.regex || mat.value, mat.type !== SourceTypeMap.WEBHOOK).isValid - console.log('isValid', isValid,mat) return isValid }, true) + const skipValidationForGitNotRequired = isJobCI && !isGitRequired + valid = valid || skipValidationForGitNotRequired if (_formData.materials.length > 1) { const _isWebhook = _formData.materials.some((_mat) => _mat.type === SourceTypeMap.WEBHOOK) if (_isWebhook) { @@ -820,6 +827,8 @@ export default function CIPipeline({ getPluginData={getPluginData} setCIPipeline={setCIPipeline} isJobCI={isJobCI} + isGitRequired={isGitRequired} + setIsGitRequired={setIsGitRequired} /> diff --git a/src/components/app/details/cIDetails/CIDetails.tsx b/src/components/app/details/cIDetails/CIDetails.tsx index 83cec24c37..ffc5ae0de0 100644 --- a/src/components/app/details/cIDetails/CIDetails.tsx +++ b/src/components/app/details/cIDetails/CIDetails.tsx @@ -52,7 +52,6 @@ export default function CIDetails({ isJobView, filteredEnvIds }: { isJobView?: b ]), [appId, filteredEnvIds], ) - console.log(initDataResults) const [loading, triggerHistoryResult, , , , dependencyState] = useAsync( () => getTriggerHistory(+pipelineId, pagination), [pipelineId, pagination], @@ -357,7 +356,6 @@ export const Details = ({ if (!areTagDetailsRequired && !triggerDetailsLoading && !triggerDetails) return if (areTagDetailsRequired && !(tagDetailsLoading || triggerDetailsLoading) && !triggerDetails) return if (triggerDetails.id !== +buildId) return null - console.log('sdfsdf',pipeline.isGitRequired) return ( <>
    diff --git a/src/components/app/details/triggerView/workflow.service.ts b/src/components/app/details/triggerView/workflow.service.ts index 63b2d3ed90..f2382eeffa 100644 --- a/src/components/app/details/triggerView/workflow.service.ts +++ b/src/components/app/details/triggerView/workflow.service.ts @@ -80,7 +80,6 @@ const getInitialWorkflows = ( } else { return Promise.all([getWorkflowList(id, filteredEnvIds), getCIConfig(id), getCDConfig(id), getExternalCIList(id)]).then( ([workflow, ciConfig, cdConfig, externalCIConfig]) => { - console.log('ciConfig', ciConfig) return processWorkflow( workflow.result as WorkflowResult, ciConfig.result as CiPipelineResult, @@ -157,7 +156,6 @@ export function processWorkflow( ) const appName = workflow.appName let workflows = new Array() - console.log("workflow.workflows",workflow.workflows) //populate workflows with CI and CD nodes, sourceNodes are inside CI nodes and PreCD and PostCD nodes are inside CD nodes workflow.workflows ?.sort((a, b) => a.id - b.id) @@ -220,7 +218,6 @@ export function processWorkflow( if (dimensions.type == WorkflowDimensionType.TRIGGER) { workflows = workflows.filter((wf) => wf.nodes.length > 0) } - console.log('workflows before', workflows) addDimensions(workflows, workflowOffset, dimensions) return { appName, workflows, filteredCIPipelines } } @@ -235,13 +232,10 @@ function addDimensions(workflows: WorkflowType[], workflowOffset: Offset, dimens if (workflow.nodes.length == 0) { return } - console.log('each workflow', workflow) const ciNode = workflow.nodes.find( (node) => node.type == WorkflowNodeType.CI || node.type == WorkflowNodeType.WEBHOOK, ) - console.log('ciNode', ciNode.sourceNodes) ciNode.sourceNodes?.forEach((s, si) => { - console.log('s', s) const sourceNodeY = startY + workflowOffset.offsetY + diff --git a/src/components/ciPipeline/ciPipeline.service.ts b/src/components/ciPipeline/ciPipeline.service.ts index e443b8178d..cf2eb5acce 100644 --- a/src/components/ciPipeline/ciPipeline.service.ts +++ b/src/components/ciPipeline/ciPipeline.service.ts @@ -164,7 +164,6 @@ export function getInitDataWithCIPipeline( pipelineMetaConfigResult.webhookEvents, pipelineMetaConfigResult.ciPipelineSourceTypeOptions, ) - console.log('sdfsdf',x) return x; }) } diff --git a/src/components/ciPipeline/types.ts b/src/components/ciPipeline/types.ts index abf7f71a1d..d58bc215e0 100644 --- a/src/components/ciPipeline/types.ts +++ b/src/components/ciPipeline/types.ts @@ -393,6 +393,8 @@ export interface BuildType { getPluginData: (_formData?: PipelineFormType) => void setCIPipeline: React.Dispatch> isJobCI?: boolean + isGitRequired?: boolean + setIsGitRequired?: React.Dispatch> } export interface PreBuildType { diff --git a/src/components/ciPipeline/validationRules.ts b/src/components/ciPipeline/validationRules.ts index 58f0b41868..7e4cd6556a 100644 --- a/src/components/ciPipeline/validationRules.ts +++ b/src/components/ciPipeline/validationRules.ts @@ -112,7 +112,6 @@ export class ValidationRules { sourceValue = (value: string, doRegexValidation = true): { message: string | null; isValid: boolean } => { if (!value) { - console.log('value here', value) return { message: `This is required`, isValid: false } } else { if (doRegexValidation) { diff --git a/src/components/workflowEditor/Workflow.tsx b/src/components/workflowEditor/Workflow.tsx index 979f44e0b6..9de3c15d6e 100644 --- a/src/components/workflowEditor/Workflow.tsx +++ b/src/components/workflowEditor/Workflow.tsx @@ -411,7 +411,6 @@ export class Workflow extends Component { renderEdgeList() { const edges = this.getEdges() - console.log('edges', edges) return edges.map((edgeNode) => { if (ApprovalNodeEdge) { return ( diff --git a/src/components/workflowEditor/workflowEditor.tsx b/src/components/workflowEditor/workflowEditor.tsx index 9ea6697c73..b0a07e95ac 100644 --- a/src/components/workflowEditor/workflowEditor.tsx +++ b/src/components/workflowEditor/workflowEditor.tsx @@ -112,7 +112,6 @@ class WorkflowEdit extends Component { const allDeploymentNodeMap = new Map() let isDeletionInProgress const _envIds = [] - console.log('workflow',result) for (const workFlow of result.workflows) { for (const node of workFlow.nodes) { if (node.type === WorkflowNodeType.CI) { From b652973759871de98a1992a148265c75dcaa463b Mon Sep 17 00:00:00 2001 From: Mukul Tayal Date: Wed, 29 Nov 2023 17:36:20 +0530 Subject: [PATCH 4/6] fix merge changes --- src/components/workflowEditor/Workflow.tsx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/components/workflowEditor/Workflow.tsx b/src/components/workflowEditor/Workflow.tsx index 9de3c15d6e..aedd8d82b4 100644 --- a/src/components/workflowEditor/Workflow.tsx +++ b/src/components/workflowEditor/Workflow.tsx @@ -498,14 +498,10 @@ export class Workflow extends Component {
    {isExternalCiWorkflow && }
    - {this.props.nodes.length == 0 ? ( - this.emptyWorkflow() - ) : ( - - {this.renderEdgeList()} - {this.renderNodes()} - - )} + + {this.renderEdgeList()} + {this.renderNodes()} + {!configDiffView && ( Date: Wed, 29 Nov 2023 18:42:25 +0530 Subject: [PATCH 5/6] common lib version change --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a0cdbfe5e2..fe2fbb039d 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "homepage": "/dashboard", "dependencies": { - "@devtron-labs/devtron-fe-common-lib": "0.0.41", + "@devtron-labs/devtron-fe-common-lib": "0.0.42-beta-2", "@sentry/browser": "^7.3.1", "@sentry/integrations": "^7.3.1", "@sentry/tracing": "^7.3.1", From 810aefa1b6ee5168796277f9e776559257a5767a Mon Sep 17 00:00:00 2001 From: Mukul Tayal Date: Wed, 29 Nov 2023 18:50:28 +0530 Subject: [PATCH 6/6] fix: formatting --- src/components/ciPipeline/ciPipeline.service.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/ciPipeline/ciPipeline.service.ts b/src/components/ciPipeline/ciPipeline.service.ts index cf2eb5acce..7593c9e48e 100644 --- a/src/components/ciPipeline/ciPipeline.service.ts +++ b/src/components/ciPipeline/ciPipeline.service.ts @@ -156,7 +156,7 @@ export function getInitDataWithCIPipeline( ]).then(([ciPipelineRes, pipelineMetaConfig]) => { const ciPipeline = ciPipelineRes?.result const pipelineMetaConfigResult = pipelineMetaConfig?.result - const x= parseCIResponse( + return parseCIResponse( pipelineMetaConfig.code, ciPipeline, pipelineMetaConfigResult.materials, @@ -164,7 +164,6 @@ export function getInitDataWithCIPipeline( pipelineMetaConfigResult.webhookEvents, pipelineMetaConfigResult.ciPipelineSourceTypeOptions, ) - return x; }) }