14
14
* limitations under the License.
15
15
*/
16
16
17
- import React , { useEffect , useRef , useState } from 'react'
17
+ import React , { useEffect , useState } from 'react'
18
18
import { Prompt , Route , Switch , useHistory , useLocation , useParams , useRouteMatch } from 'react-router-dom'
19
19
import Tippy from '@tippyjs/react'
20
20
@@ -29,7 +29,6 @@ import {
29
29
DEFAULT_ROUTE_PROMPT_MESSAGE ,
30
30
DeploymentNodeType ,
31
31
ErrorScreenManager ,
32
- handleAnalyticsEvent ,
33
32
PopupMenu ,
34
33
Progressing ,
35
34
ServerErrors ,
@@ -43,7 +42,7 @@ import {
43
42
} from '@devtron-labs/devtron-fe-common-lib'
44
43
45
44
import { BuildImageModal , BulkBuildImageModal } from '@Components/app/details/triggerView/BuildImageModal'
46
- import { BulkDeployModal , DeployImageModal } from '@Components/app/details/triggerView/DeployImageModal'
45
+ import { BulkDeployModal } from '@Components/app/details/triggerView/DeployImageModal'
47
46
import { shouldRenderWebhookAddImageModal } from '@Components/app/details/triggerView/TriggerView.utils'
48
47
import { getExternalCIConfig } from '@Components/ciPipeline/Webhook/webhook.service'
49
48
@@ -58,7 +57,7 @@ import { TRIGGER_VIEW_PARAMS } from '../../../app/details/triggerView/Constants'
58
57
import { CIMaterialRouterProps , MATERIAL_TYPE } from '../../../app/details/triggerView/types'
59
58
import { Workflow } from '../../../app/details/triggerView/workflow/Workflow'
60
59
import { triggerBranchChange } from '../../../app/service'
61
- import { getCDPipelineURL , importComponentFromFELibrary , sortObjectArrayAlphabetically } from '../../../common'
60
+ import { importComponentFromFELibrary , sortObjectArrayAlphabetically } from '../../../common'
62
61
import { getModuleInfo } from '../../../v2/devtronStackManager/DevtronStackManager.service'
63
62
import { getWorkflows , getWorkflowStatus } from '../../AppGroup.service'
64
63
import {
@@ -70,16 +69,15 @@ import {
70
69
import { processWorkflowStatuses } from '../../AppGroup.utils'
71
70
import {
72
71
BulkResponseStatus ,
73
- ENV_TRIGGER_VIEW_GA_EVENTS ,
74
72
GetBranchChangeStatus ,
75
73
SKIPPED_RESOURCES_MESSAGE ,
76
74
SKIPPED_RESOURCES_STATUS_TEXT ,
77
75
} from '../../Constants'
78
76
import BulkSourceChange from './BulkSourceChange'
79
- import { RenderCDMaterialContentProps } from './types'
80
- import { getSelectedNodeAndAppId , getSelectedNodeAndMeta } from './utils'
77
+ import { getSelectedNodeAndAppId } from './utils'
81
78
82
79
import './EnvTriggerView.scss'
80
+ import CDMaterial from '@Components/app/details/triggerView/CDMaterial'
83
81
84
82
const ApprovalMaterialModal = importComponentFromFELibrary ( 'ApprovalMaterialModal' )
85
83
const processDeploymentWindowStateAppGroup = importComponentFromFELibrary (
@@ -529,86 +527,10 @@ const EnvTriggerView = ({ filteredAppIds, isVirtualEnv }: AppGroupDetailDefaultT
529
527
)
530
528
}
531
529
532
- const renderCDMaterialContent = ( {
533
- node,
534
- appId,
535
- workflowId,
536
- selectedAppName,
537
- doesWorkflowContainsWebhook,
538
- ciNodeId,
539
- } : RenderCDMaterialContentProps ) => {
540
- const configurePluginURL = getCDPipelineURL (
541
- String ( appId ) ,
542
- workflowId ,
543
- doesWorkflowContainsWebhook ? '0' : ciNodeId ,
544
- doesWorkflowContainsWebhook ,
545
- node ?. id ,
546
- true ,
547
- )
548
-
549
- const cdMaterialType = location . search . includes ( TRIGGER_VIEW_PARAMS . CD_NODE )
550
- ? MATERIAL_TYPE . inputMaterialList
551
- : MATERIAL_TYPE . rollbackMaterialList
552
-
553
- return (
554
- < DeployImageModal
555
- appId = { appId }
556
- envId = { node ?. environmentId }
557
- appName = { selectedAppName }
558
- stageType = { node . type as DeploymentNodeType }
559
- envName = { node ?. environmentName }
560
- pipelineId = { + node . id }
561
- materialType = { cdMaterialType }
562
- handleClose = { revertToPreviousURL }
563
- handleSuccess = { getWorkflowStatusData }
564
- deploymentAppType = { node ?. deploymentAppType }
565
- isVirtualEnvironment = { isVirtualEnv }
566
- showPluginWarningBeforeTrigger = { node ?. showPluginWarning }
567
- consequence = { node ?. pluginBlockState }
568
- configurePluginURL = { configurePluginURL }
569
- isTriggerBlockedDueToPlugin = { node ?. showPluginWarning && node ?. isTriggerBlocked }
570
- triggerType = { node ?. triggerType }
571
- parentEnvironmentName = { node ?. parentEnvironmentName }
572
- />
573
- )
574
- }
575
-
576
- const renderCDMaterial = ( ) : JSX . Element | null => {
577
- if (
578
- location . search . includes ( TRIGGER_VIEW_PARAMS . CD_NODE ) ||
579
- location . search . includes ( TRIGGER_VIEW_PARAMS . ROLLBACK_NODE )
580
- ) {
581
- const { node, appId, workflowId, appName, selectedCINode } = getSelectedNodeAndMeta (
582
- filteredWorkflows ,
583
- location . search ,
584
- )
585
-
586
- if ( ! node ?. id ) {
587
- return null
588
- }
589
-
590
- return renderCDMaterialContent ( {
591
- node,
592
- appId,
593
- selectedAppName : appName ,
594
- workflowId,
595
- doesWorkflowContainsWebhook : selectedCINode ?. type === WorkflowNodeType . WEBHOOK ,
596
- ciNodeId : selectedCINode ?. id ,
597
- } )
598
- }
599
-
600
- return null
601
- }
602
-
603
530
const renderApprovalMaterial = ( ) => {
604
531
if ( ApprovalMaterialModal && location . search . includes ( TRIGGER_VIEW_PARAMS . APPROVAL_NODE ) ) {
605
532
const { node, appId } = getSelectedNodeAndAppId ( filteredWorkflows , location . search )
606
533
607
- if ( ! node ?. id || ! appId ) {
608
- showError ( 'Invalid node id' )
609
- return null
610
- }
611
-
612
534
return (
613
535
< ApprovalMaterialModal
614
536
isLoading = { false }
@@ -617,7 +539,7 @@ const EnvTriggerView = ({ filteredAppIds, isVirtualEnv }: AppGroupDetailDefaultT
617
539
stageType = { DeploymentNodeType . CD }
618
540
closeApprovalModal = { closeApprovalModal }
619
541
appId = { appId }
620
- pipelineId = { node . id }
542
+ pipelineId = { node ? .id }
621
543
getModuleInfo = { getModuleInfo }
622
544
ciPipelineId = { node ?. connectingCiPipelineId }
623
545
history = { history }
@@ -831,7 +753,11 @@ const EnvTriggerView = ({ filteredAppIds, isVirtualEnv }: AppGroupDetailDefaultT
831
753
/>
832
754
</ Route >
833
755
</ Switch >
834
- { renderCDMaterial ( ) }
756
+ < CDMaterial
757
+ workflows = { filteredWorkflows }
758
+ handleClose = { revertToPreviousURL }
759
+ handleSuccess = { getWorkflowStatusData }
760
+ />
835
761
{ renderBulkCDMaterial ( ) }
836
762
{ renderBulkCIMaterial ( ) }
837
763
{ renderApprovalMaterial ( ) }
0 commit comments