Skip to content

Commit

Permalink
Add spinner for environments button
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenlouv committed Jul 9, 2020
1 parent 4124e70 commit fa78f82
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export const AddEnvironments = ({
disabled: currentEnvironments.includes(env),
}));

const [isSaving, setIsSaving] = useState(false);

const [selectedOptions, setSelected] = useState<
Array<EuiComboBoxOptionOption<string>>
>([]);
Expand Down Expand Up @@ -127,9 +129,12 @@ export const AddEnvironments = ({
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton
isLoading={isSaving}
isDisabled={isSaving || selectedOptions.length === 0}
fill
disabled={selectedOptions.length === 0}
onClick={async () => {
setIsSaving(true);

const selectedEnvironments = selectedOptions.map(
({ value }) => value as string
);
Expand All @@ -140,6 +145,7 @@ export const AddEnvironments = ({
if (success) {
onCreateJobSuccess();
}
setIsSaving(false);
}}
>
{i18n.translate(
Expand Down

0 comments on commit fa78f82

Please sign in to comment.