1- import cx from 'classnames'
21import React , { useState } from 'react'
32import { useDispatch , useSelector } from 'react-redux'
43import { useParams } from 'react-router-dom'
@@ -14,17 +13,14 @@ import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
1413import { createAxiosError , pipelineToJson } from 'uiSrc/utils'
1514import { addErrorNotification } from 'uiSrc/slices/app/notifications'
1615import { rdiErrorMessages } from 'uiSrc/pages/rdi/constants'
17- import { ColorText , Text } from 'uiSrc/components/base/text'
18- import { FlexItem , Row } from 'uiSrc/components/base/layout/flex'
19- import { Spacer } from 'uiSrc/components/base/layout/spacer'
20- import { OutsideClickDetector } from 'uiSrc/components/base/utils'
16+ import { Text } from 'uiSrc/components/base/text'
17+ import { Col , FlexItem , Row } from 'uiSrc/components/base/layout/flex'
2118import { PrimaryButton } from 'uiSrc/components/base/forms/buttons'
22- import { RocketIcon } from 'uiSrc/components/base/icons'
23- import { Title } from 'uiSrc/components/base/text/Title'
19+ import { Icon , RocketIcon , InfoIcon } from 'uiSrc/components/base/icons'
2420import { Checkbox } from 'uiSrc/components/base/forms/checkbox/Checkbox'
25- import { RiPopover , RiTooltip } from 'uiSrc/components/base'
26- import { RiIcon } from 'uiSrc/components/base/icons/RiIcon '
27- import styles from './ styles.module.scss '
21+ import { RiTooltip } from 'uiSrc/components/base'
22+ import { Modal } from 'uiSrc/components/base/display/modal '
23+ import { UploadWarningBanner } from 'uiSrc/components/upload-warning/ styles'
2824
2925export interface Props {
3026 loading : boolean
@@ -33,7 +29,6 @@ export interface Props {
3329}
3430
3531const DeployPipelineButton = ( { loading, disabled, onReset } : Props ) => {
36- const [ isPopoverOpen , setIsPopoverOpen ] = useState ( false )
3732 const [ resetPipeline , setResetPipeline ] = useState ( false )
3833
3934 const { config, jobs, resetChecked, isPipelineValid } =
@@ -60,7 +55,6 @@ const DeployPipelineButton = ({ loading, disabled, onReset }: Props) => {
6055 jobsNumber : jobs ?. length ,
6156 } ,
6257 } )
63- setIsPopoverOpen ( false )
6458 setResetPipeline ( false )
6559 const JSONValues = pipelineToJson ( { config, jobs } , ( errors ) => {
6660 dispatch (
@@ -87,107 +81,64 @@ const DeployPipelineButton = ({ loading, disabled, onReset }: Props) => {
8781 )
8882 }
8983
90- const handleClosePopover = ( ) => {
91- setIsPopoverOpen ( false )
92- }
93-
94- const handleClickDeploy = ( ) => {
95- setIsPopoverOpen ( true )
96- }
97-
9884 const handleSelectReset = ( reset : boolean ) => {
9985 setResetPipeline ( reset )
10086 dispatch ( resetPipelineChecked ( reset ) )
10187 }
10288
10389 return (
104- < OutsideClickDetector onOutsideClick = { handleClosePopover } >
105- < RiPopover
106- closePopover = { handleClosePopover }
107- ownFocus
108- initialFocus = { false }
109- className = { styles . popoverAnchor }
110- panelClassName = { cx ( 'popoverLikeTooltip' , styles . popover ) }
111- anchorClassName = { styles . popoverAnchor }
112- anchorPosition = "upLeft"
113- isOpen = { isPopoverOpen }
114- panelPaddingSize = "m"
115- focusTrapProps = { {
116- scrollLock : true ,
117- } }
118- button = {
119- < PrimaryButton
120- onClick = { handleClickDeploy }
121- icon = { RocketIcon }
122- disabled = { disabled }
123- loading = { loading }
124- data-testid = "deploy-rdi-pipeline"
125- >
126- Deploy
127- </ PrimaryButton >
128- }
129- >
130- < Title size = "XS" >
131- { isPipelineValid ? (
132- < ColorText color = "default" >
133- Are you sure you want to deploy the pipeline?
134- </ ColorText >
135- ) : (
136- < ColorText color = "warning" >
137- < RiIcon type = "ToastDangerIcon" size = "L" color = "attention500" />
138- Your RDI pipeline contains errors. Are you sure you want to
139- continue?
140- </ ColorText >
141- ) }
142- </ Title >
143- < Spacer size = "s" />
144- < Text size = "s" >
145- When deployed, this local configuration will overwrite any existing
146- pipeline.
147- </ Text >
148- < Spacer size = "s" />
149- < Text size = "s" >
150- After deployment, consider flushing the target Redis database and
151- resetting the pipeline to ensure that all data is reprocessed.
152- </ Text >
153- < Spacer size = "s" />
154- < div className = { styles . checkbox } >
155- < Checkbox
156- id = "resetPipeline"
157- name = "resetPipeline"
158- label = "Reset"
159- className = { cx ( styles . resetPipelineCheckbox , {
160- [ styles . checked ] : resetPipeline ,
161- } ) }
162- checked = { resetPipeline }
163- onChange = { ( e ) => handleSelectReset ( e . target . checked ) }
164- data-testid = "reset-pipeline-checkbox"
165- />
166-
167- < RiTooltip content = "The pipeline will take a new snapshot of the data and process it, then continue tracking changes." >
168- < RiIcon
169- type = "InfoIcon"
170- size = "m"
171- style = { { cursor : 'pointer' } }
172- data-testid = "reset-checkbox-info-icon"
90+ < Modal
91+ id = "deploy-pipeline-modal"
92+ title = "Are you sure you want to deploy the pipeline?"
93+ content = {
94+ < Col gap = "l" >
95+ { ! isPipelineValid && (
96+ < UploadWarningBanner
97+ message = "Your RDI pipeline contains errors. Are you sure you want to continue?"
98+ show
99+ showIcon
100+ variant = "attention"
173101 />
174- </ RiTooltip >
175- </ div >
176- < Row gap = "m" responsive justify = "end" >
102+ ) }
177103 < FlexItem >
178- < PrimaryButton
179- size = "s"
180- color = "secondary"
181- className = { styles . popoverBtn }
182- onClick = { handleDeployPipeline }
183- data-testid = "deploy-confirm-btn"
184- >
185- Deploy
186- </ PrimaryButton >
104+ < Text >
105+ When deployed, this local configuration will overwrite any
106+ existing pipeline.
107+ </ Text >
108+ < Text >
109+ After deployment, consider flushing the target Redis database and
110+ resetting the pipeline to ensure that all data is reprocessed.
111+ </ Text >
187112 </ FlexItem >
188- </ Row >
189- </ RiPopover >
190- </ OutsideClickDetector >
113+ < Row align = "center" >
114+ < Checkbox
115+ id = "resetPipeline"
116+ name = "resetPipeline"
117+ label = "Reset"
118+ labelSize = "M"
119+ checked = { resetPipeline }
120+ onChange = { ( e ) => handleSelectReset ( e . target . checked ) }
121+ data-testid = "reset-pipeline-checkbox"
122+ />
123+
124+ < RiTooltip content = "The pipeline will take a new snapshot of the data and process it, then continue tracking changes." >
125+ < Icon icon = { InfoIcon } data-testid = "reset-checkbox-info-icon" />
126+ </ RiTooltip >
127+ </ Row >
128+ </ Col >
129+ }
130+ primaryButtonText = "Deploy"
131+ onPrimaryButtonClick = { handleDeployPipeline }
132+ >
133+ < PrimaryButton
134+ icon = { RocketIcon }
135+ disabled = { disabled }
136+ loading = { loading }
137+ data-testid = "deploy-rdi-pipeline"
138+ >
139+ Deploy
140+ </ PrimaryButton >
141+ </ Modal >
191142 )
192143}
193144
0 commit comments