-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pipeline edit modal with parallelism control
Add an "Edit" button on the job details page that opens up a modal. The modal contains a form that can be used to change the parallelism. Resolves: #74
- Loading branch information
Showing
2 changed files
with
151 additions
and
8 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
101 changes: 101 additions & 0 deletions
101
arroyo-console/src/routes/pipelines/PipelineConfigModal.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,101 @@ | ||
import React, { useState } from "react"; | ||
import { | ||
Alert, | ||
AlertDescription, | ||
AlertIcon, | ||
Button, | ||
FormControl, | ||
FormHelperText, | ||
FormLabel, | ||
Input, | ||
Modal, | ||
ModalBody, | ||
ModalCloseButton, | ||
ModalContent, | ||
ModalFooter, | ||
ModalHeader, | ||
ModalOverlay, | ||
} from "@chakra-ui/react"; | ||
|
||
export interface PipelineConfigModalProps { | ||
isOpen: boolean; | ||
parallelism: number; | ||
onClose: () => void; | ||
updateJobParallelism: (parallelism: number) => void; | ||
} | ||
|
||
const PipelineConfigModal: React.FC<PipelineConfigModalProps> = ({ | ||
isOpen, | ||
parallelism, | ||
onClose, | ||
updateJobParallelism, | ||
}) => { | ||
const [parallelismInputValue, setParallelismInputValue] = useState<number | undefined>( | ||
parallelism | ||
); | ||
|
||
const onConfirm = () => { | ||
if (parallelismInputValue) { | ||
updateJobParallelism(parallelismInputValue); | ||
} | ||
onClose(); | ||
}; | ||
|
||
const pipelineRequiresRestart = parallelismInputValue != parallelism; | ||
|
||
let changeAlert = <></>; | ||
if (pipelineRequiresRestart) { | ||
changeAlert = ( | ||
<Alert status="warning"> | ||
<AlertIcon /> | ||
<AlertDescription>These changes require a pipeline restart.</AlertDescription> | ||
</Alert> | ||
); | ||
} | ||
|
||
const parallelismInput = ( | ||
<Input | ||
onChange={event => { | ||
if (!event.target.value) { | ||
setParallelismInputValue(undefined); | ||
} | ||
|
||
const parsedNumber = parseInt(event.target.value); | ||
if (!isNaN(parsedNumber)) { | ||
setParallelismInputValue(parsedNumber); | ||
} | ||
}} | ||
value={parallelismInputValue} | ||
/> | ||
); | ||
|
||
const form = ( | ||
<FormControl isRequired> | ||
<FormLabel>Parallelism</FormLabel> | ||
{parallelismInput} | ||
<FormHelperText>Number of parallel substacks for each node</FormHelperText> | ||
</FormControl> | ||
); | ||
|
||
return ( | ||
<Modal isOpen={isOpen} onClose={onClose}> | ||
<ModalOverlay /> | ||
<ModalContent> | ||
<ModalHeader>Edit Pipeline Configuration</ModalHeader> | ||
<ModalCloseButton /> | ||
{changeAlert} | ||
<ModalBody>{form}</ModalBody> | ||
<ModalFooter> | ||
<Button variant="ghost" onClick={onClose}> | ||
Cancel | ||
</Button> | ||
<Button colorScheme="blue" mr={3} onClick={onConfirm}> | ||
Save | ||
</Button> | ||
</ModalFooter> | ||
</ModalContent> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default PipelineConfigModal; |