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 Flyout component in Wazuh Dashboard 2.x #4638

Merged
merged 13 commits into from
Oct 20, 2022
Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Fixed rendering problems of the `Agent Overview` section in low resolutions [#4516](https://github.com/wazuh/wazuh-kibana-app/pull/4516)
- Fixed issue when logging out from Wazuh when SAML is enabled [#4595](https://github.com/wazuh/wazuh-kibana-app/issues/4595)
- Fixed pagination to SCA table [#4653](https://github.com/wazuh/wazuh-kibana-app/issues/4653)
- Fixed a bug that caused the flyouts to close when clicking inside them [#4638](https://github.com/wazuh/wazuh-kibana-app/pull/4638)

## Wazuh v4.3.9 - OpenSearch Dashboards 1.2.0 - Revision 4310

Expand Down
41 changes: 27 additions & 14 deletions public/components/common/flyouts/wz-flyout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,34 @@
* Find more information about this on the LICENSE file.
*/

import React, { Component, Fragment } from 'react';
import { EuiFlyout, EuiOverlayMask, EuiOutsideClickDetector } from '@elastic/eui';
import React from 'react';
import { EuiFlyout, EuiOutsideClickDetector } from '@elastic/eui';

export const WzFlyout = ({children, flyoutProps = {}, overlayMaskProps = {}, outsideClickDetectorProps = {}, onClose}) => (
<EuiOverlayMask headerZindexLocation="below" {...overlayMaskProps}>
<EuiOutsideClickDetector
onOutsideClick={onClose}
{...outsideClickDetectorProps}
>
<EuiFlyout
onClose={onClose}
{...flyoutProps}
>
export const WzFlyout = ({ children, flyoutProps = {}, onClose }) => {
const closeFlyout = (ev) => {
// Clicking on the flyout or on the flyout selector should not close the flyout.
if (
ev &&
ev.path.some(
(element) =>
element.classList?.contains('euiFlyout') || element.classList?.contains('euiPanel')
)
) {
return;
}
onClose();
};

return (
<EuiOutsideClickDetector onOutsideClick={closeFlyout}>
{/*
As the version of Elastic EUI (v34.6.0) has a bug in the EuiOverlayMask component,
maskProps is added to avoid the closing of the overlay by the native function, as it contains the bug
This bug is fixed in the Elastic EUI version 36.0.0
*/}
<EuiFlyout onClose={onClose} maskProps={{ onClick: () => {} }} {...flyoutProps}>
{children}
</EuiFlyout>
</EuiOutsideClickDetector>
</EuiOverlayMask>
);
);
};
20 changes: 8 additions & 12 deletions public/components/security/policies/create-policy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,14 @@ export const CreatePolicyFlyout = ({ closeFlyout }) => {

const createPolicy = async () => {
try {
const result = await WzRequest.apiReq(
'POST',
'/security/policies',
{
name: policyName,
policy: {
actions: addedActions.map((x) => x.action),
resources: addedResources.map((x) => x.resource),
effect: effectValue,
},
}
);
const result = await WzRequest.apiReq('POST', '/security/policies', {
name: policyName,
policy: {
actions: addedActions.map((x) => x.action),
resources: addedResources.map((x) => x.resource),
effect: effectValue,
},
});
const resultData = (result.data || {}).data;
if (resultData.failed_items && resultData.failed_items.length) {
return;
Expand Down