import { get } from 'lodash'; import React from 'react'; import { Modal } from 'react-bootstrap'; import type { IPipeline, IPipelineLock } from '../../../../domain'; import { HelpField } from '../../../../help'; import { ModalClose } from '../../../../modal'; import type { IModalComponentProps } from '../../../../presentation'; import { CheckboxInput, FormField, TextInput } from '../../../../presentation'; import { PipelineConfigService } from '../../services/PipelineConfigService'; export interface ILockPipelineModalProps extends IModalComponentProps { pipeline: IPipeline; } export function LockPipelineModal(props: ILockPipelineModalProps) { const [errorMessage, setErrorMessage] = React.useState(null); const [saveError, setSaveError] = React.useState(false); const [allowUnlockUi, setAllowUnlockUi] = React.useState(true); const [description, setDescription] = React.useState(''); const { closeModal, dismissModal, pipeline } = props; function lockPipeline() { const locked: IPipelineLock = { ui: true, allowUnlockUi, description, }; const newPipeline = { ...pipeline, locked }; PipelineConfigService.savePipeline(newPipeline).then( () => closeModal(newPipeline), (response) => { setSaveError(true); setErrorMessage(get(response, 'data.message', 'No message provided')); }, ); } return ( <> {}}> Really Lock Pipeline? {saveError && (

Could not lock pipeline.

Reason: {errorMessage}

{ e.preventDefault(); setSaveError(false); }} > [dismiss]

)}

Are you sure you want to lock {pipeline.name}?

This will prevent any further modification to this pipeline made via the Spinnaker UI.

} input={(inputProps) => } onChange={() => setAllowUnlockUi(!allowUnlockUi)} value={allowUnlockUi} /> } input={(inputProps) => ( )} onChange={(e) => setDescription(e.target.value)} value={description} />
); }