Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix API Key flyout double submit #167468

Merged
merged 18 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 36 additions & 39 deletions x-pack/plugins/security/public/components/form_flyout.tsx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's another consumer of the FormFlyout component anymore so it would be best to remove it from the codebase

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thomheymann Thanks for confirming, Thom!

@SiddharthMantri Looks like it's used in the 7.17 branch. So if we have the double submit issue in 7.17 and it's worth fixing, we can open a PR against that branch with the changes to FormFlyout.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
EuiFlyoutBody,
EuiFlyoutFooter,
EuiFlyoutHeader,
EuiPortal,
EuiTitle,
} from '@elastic/eui';
import type { FunctionComponent, RefObject } from 'react';
Expand Down Expand Up @@ -59,46 +58,44 @@ export const FormFlyout: FunctionComponent<FormFlyoutProps> = ({
const titleId = useHtmlId('formFlyout', 'title');

return (
<EuiPortal>
<EuiFlyout onClose={onCancel} aria-labelledby={titleId} {...rest}>
<EuiFlyoutHeader hasBorder>
<EuiTitle size="m">
<h2 id={titleId}>{title}</h2>
</EuiTitle>
</EuiFlyoutHeader>
<EuiFlyoutBody>{children}</EuiFlyoutBody>
<EuiFlyoutFooter>
<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlyout onClose={onCancel} aria-labelledby={titleId} {...rest}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these changes necessary? Does api_key_flyout use FormFlyout? Or is this to just keep things consistent?
Note: I couldn't find any uses of FormFlyout.

<EuiFlyoutHeader hasBorder>
<EuiTitle size="m">
<h2 id={titleId}>{title}</h2>
</EuiTitle>
</EuiFlyoutHeader>
<EuiFlyoutBody>{children}</EuiFlyoutBody>
<EuiFlyoutFooter>
<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem grow={false}>
<EuiButtonEmpty
data-test-subj="formFlyoutCancelButton"
flush="right"
isDisabled={isLoading}
onClick={onCancel}
>
<FormattedMessage
id="xpack.security.formFlyout.cancelButton"
defaultMessage="Cancel"
/>
</EuiButtonEmpty>
</EuiFlexItem>
{!isSubmitButtonHidden && (
<EuiFlexItem grow={false}>
<EuiButtonEmpty
data-test-subj="formFlyoutCancelButton"
flush="right"
isDisabled={isLoading}
onClick={onCancel}
<EuiButton
data-test-subj="formFlyoutSubmitButton"
isLoading={isLoading}
isDisabled={isDisabled}
color={submitButtonColor}
fill
onClick={onSubmit}
>
<FormattedMessage
id="xpack.security.formFlyout.cancelButton"
defaultMessage="Cancel"
/>
</EuiButtonEmpty>
{submitButtonText}
</EuiButton>
</EuiFlexItem>
{!isSubmitButtonHidden && (
<EuiFlexItem grow={false}>
<EuiButton
data-test-subj="formFlyoutSubmitButton"
isLoading={isLoading}
isDisabled={isDisabled}
color={submitButtonColor}
fill
onClick={onSubmit}
>
{submitButtonText}
</EuiButton>
</EuiFlexItem>
)}
</EuiFlexGroup>
</EuiFlyoutFooter>
</EuiFlyout>
</EuiPortal>
)}
</EuiFlexGroup>
</EuiFlyoutFooter>
</EuiFlyout>
);
};
Loading