Skip to content

Commit

Permalink
disabling switch when running
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic committed Sep 16, 2020
1 parent ced6f1b commit 2ec87e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ import { EuiSwitch, EuiFormRow, EuiSpacer } from '@elastic/eui';
interface Props {
startDatafeed: boolean;
setStartDatafeed(start: boolean): void;
disabled?: boolean;
}

export const StartDatafeedSwitch: FC<Props> = ({ startDatafeed, setStartDatafeed }) => {
export const StartDatafeedSwitch: FC<Props> = ({
startDatafeed,
setStartDatafeed,
disabled = false,
}) => {
return (
<>
<EuiSpacer />
Expand All @@ -31,6 +36,7 @@ export const StartDatafeedSwitch: FC<Props> = ({ startDatafeed, setStartDatafeed
})}
checked={startDatafeed}
onChange={(e) => setStartDatafeed(e.target.checked)}
disabled={disabled}
/>
</EuiFormRow>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const SummaryStep: FC<StepProps> = ({ setCurrentStep, isCurrentStep }) =>
}, []);

async function start() {
setCreatingJob(true);
if (isAdvanced) {
await createAdvancedJob();
} else if (startDatafeed === true) {
Expand All @@ -71,7 +72,6 @@ export const SummaryStep: FC<StepProps> = ({ setCurrentStep, isCurrentStep }) =>
}

async function createAndStartJob() {
setCreatingJob(true);
try {
const jr = await jobCreator.createAndStartJob();
setJobRunner(jr);
Expand All @@ -81,7 +81,6 @@ export const SummaryStep: FC<StepProps> = ({ setCurrentStep, isCurrentStep }) =>
}

async function createAdvancedJob(showStartModal: boolean = true) {
setCreatingJob(true);
try {
await jobCreator.createJob();
await jobCreator.createDatafeed();
Expand Down Expand Up @@ -139,6 +138,7 @@ export const SummaryStep: FC<StepProps> = ({ setCurrentStep, isCurrentStep }) =>
<StartDatafeedSwitch
startDatafeed={startDatafeed}
setStartDatafeed={setStartDatafeed}
disabled={creatingJob}
/>
)}

Expand Down

0 comments on commit 2ec87e1

Please sign in to comment.