-
Notifications
You must be signed in to change notification settings - Fork 900
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(core): Reactify enable pipeline modal (#7360)
* refactor(core): Reactify enable pipeline modal * remove wrapper function
- Loading branch information
1 parent
5155ba1
commit 450d681
Showing
7 changed files
with
83 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
app/scripts/modules/core/src/pipeline/config/actions/enable/EnablePipelineModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import * as React from 'react'; | ||
import { Modal } from 'react-bootstrap'; | ||
|
||
import { IPipeline } from 'core/domain'; | ||
import { ModalClose } from 'core/modal'; | ||
import { IModalComponentProps } from 'core/presentation'; | ||
import { PipelineConfigService } from 'core/pipeline/config/services/PipelineConfigService'; | ||
|
||
export interface IEnablePipelineModalProps extends IModalComponentProps { | ||
pipeline: IPipeline; | ||
} | ||
|
||
export function EnablePipelineModal(props: IEnablePipelineModalProps) { | ||
const [errorMessage, setErrorMessage] = React.useState<string>(null); | ||
const [saveError, setSaveError] = React.useState<boolean>(false); | ||
const { closeModal, dismissModal, pipeline } = props; | ||
|
||
function enablePipeline() { | ||
PipelineConfigService.savePipeline({ ...pipeline, disabled: false }).then( | ||
() => closeModal(), | ||
response => { | ||
setSaveError(true); | ||
setErrorMessage(response.message || 'No message provided'); | ||
}, | ||
); | ||
} | ||
|
||
return ( | ||
<> | ||
<Modal key="modal" show={true} onHide={() => {}}> | ||
<ModalClose dismiss={dismissModal} /> | ||
<Modal.Header> | ||
<h3>Really Enable Pipeline?</h3> | ||
</Modal.Header> | ||
<Modal.Body> | ||
{saveError && ( | ||
<div className="alert alert-danger"> | ||
<p>Could not enable pipeline.</p> | ||
<p> | ||
<b>Reason: </b> | ||
{errorMessage} | ||
</p> | ||
<p> | ||
<a | ||
className="btn btn-link" | ||
onClick={e => { | ||
e.preventDefault(); | ||
setSaveError(false); | ||
}} | ||
> | ||
[dismiss] | ||
</a> | ||
</p> | ||
</div> | ||
)} | ||
<form role="form" name="form" className="form-horizontal"> | ||
<div className="form-group"> | ||
<div className="col-md-12"> | ||
<p>Are you sure you want to enable {pipeline.name}?</p> | ||
</div> | ||
</div> | ||
</form> | ||
</Modal.Body> | ||
<Modal.Footer> | ||
<button className="btn btn-default" onClick={dismissModal} type="button"> | ||
Cancel | ||
</button> | ||
<button className="btn btn-primary" onClick={enablePipeline} type="button"> | ||
Enable pipeline | ||
</button> | ||
</Modal.Footer> | ||
</Modal> | ||
</> | ||
); | ||
} |
30 changes: 0 additions & 30 deletions
30
app/scripts/modules/core/src/pipeline/config/actions/enable/enable.module.js
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
app/scripts/modules/core/src/pipeline/config/actions/enable/enablePipelineModal.html
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters