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

Feature/implement error boundary hoc #3367

Merged
merged 25 commits into from Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7fdbe56
Feature/3316 error handler orchestrator (#3327)
Machi3mfl Jun 7, 2021
fcef3c7
Added ErrorBoundary HOC and component. (#3321)
gabiwassan Jun 7, 2021
5feef14
feature(logger-service): PR comments
gabiwassan Jun 8, 2021
457e0e5
feature(logger-orchestrator): Refactors on management of severity.
gabiwassan Jun 8, 2021
76b1009
feature(logger-orchestrator): Refactor on wz-blank-screen component.
gabiwassan Jun 8, 2021
f6d115c
feature(logger-orchestrator): Separated prompt component from error-b…
gabiwassan Jun 8, 2021
5b64c9c
feature(logger-orchestrator): Typo.
gabiwassan Jun 8, 2021
123e950
test(error-boundary): Update snapshots.
gabiwassan Jun 8, 2021
bfc6dfa
test(error-boundary): Update snapshots
gabiwassan Jun 8, 2021
d8c0f96
fix(logger-orchestrator): PR comments and refactors, fix unit tests.
gabiwassan Jun 9, 2021
05a95a4
test(error-orchestrator-base): Added simple unit test. Fixed licence …
gabiwassan Jun 9, 2021
e481167
test(error-orchestrator-base): Added simple unit test to ErrorOrchest…
gabiwassan Jun 9, 2021
dd5ba35
test(error-orchestrator-ui): Added simple unit test to ErrorOrchestra…
gabiwassan Jun 9, 2021
ba214d5
Create new backend service (#3324)
pablomarga Jun 9, 2021
dc8a304
bugfix(error-orchestrator): Added some improvements and fixes.
gabiwassan Jun 10, 2021
3ba96f4
test(ui-logs-controller): Updated unit test.
gabiwassan Jun 10, 2021
ec219f5
Settings
pablomarga Jun 11, 2021
5ae8a91
Added hoc
pablomarga Jun 14, 2021
b0d519c
Before rebase
pablomarga Jun 14, 2021
e4e73ee
rebase 4.3-7.10
pablomarga Jun 14, 2021
bd94b37
Merge 4.3-7.10
pablomarga Jun 14, 2021
d9697be
Feature/3316 error handler orchestrator (#3327)
Machi3mfl Jun 7, 2021
1706f56
Final implementations
pablomarga Jun 14, 2021
0edc654
Fix errors and apply prettier
pablomarga Jun 15, 2021
f227ee3
Added changelog
pablomarga Jun 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion CHANGELOG.md
Expand Up @@ -15,7 +15,6 @@ All notable changes to the Wazuh app project will be documented in this file.
- Changed ossec to wazuh in sample-data [#3121](https://github.com/wazuh/wazuh-kibana-app/pull/3121)
- Changed empty fields in FIM tables and `syscheck.value_name` in discovery now show an empty tag for visual clarity [#3279](https://github.com/wazuh/wazuh-kibana-app/pull/3279)


## Wazuh v4.2.0 - Kibana 7.10.2 , 7.11.2 - Revision 4201

### Added
Expand Down
20 changes: 8 additions & 12 deletions public/components/add-modules-data/WzSampleDataWrapper.js
Expand Up @@ -24,8 +24,9 @@ import {
} from '@elastic/eui';
import WzSampleData from './sample-data'
import WzReduxProvider from '../../redux/wz-redux-provider';
import { withUserAuthorizationPrompt } from '../../components/common/hocs/withUserAuthorization';
import { withUserAuthorizationPrompt, withErrorBoundary, withReduxProvider } from '../../components/common/hocs';
import store from '../../redux/store';
import { compose } from 'redux';
import { updateSelectedSettingsSection } from '../../redux/actions/appStateActions';
import { WAZUH_ROLE_ADMINISTRATOR_NAME } from '../../../common/constants';

Expand Down Expand Up @@ -61,9 +62,7 @@ export class WzSampleDataProvider extends Component {
<EuiSpacer size='xl'/>
<EuiFlexGroup>
<EuiFlexItem>
<WzReduxProvider>
<WzSampleData {...this.props} />
</WzReduxProvider>
<WzSampleData {...this.props} />
</EuiFlexItem>
</EuiFlexGroup>
</EuiPageBody>
Expand All @@ -73,11 +72,8 @@ export class WzSampleDataProvider extends Component {
}
}

const WzSampleDataWrapperWithAdministrator = withUserAuthorizationPrompt(null, [WAZUH_ROLE_ADMINISTRATOR_NAME])(WzSampleDataProvider);
export function WzSampleDataWrapper() {
return (
<WzReduxProvider>
<WzSampleDataWrapperWithAdministrator />
</WzReduxProvider>
)
}
export const WzSampleDataWrapper = compose(
withErrorBoundary,
withReduxProvider,
withUserAuthorizationPrompt(null, [WAZUH_ROLE_ADMINISTRATOR_NAME])
)(WzSampleDataProvider);
3 changes: 2 additions & 1 deletion public/components/agents/stats/agent-stats.tsx
Expand Up @@ -21,7 +21,7 @@ import {
EuiText
} from '@elastic/eui';

import { withGlobalBreadcrumb, withReduxProvider, withGuard, withUserAuthorizationPrompt } from '../../common/hocs';
import { withGlobalBreadcrumb, withReduxProvider, withGuard, withUserAuthorizationPrompt, withErrorBoundary } from '../../common/hocs';
import { compose } from 'redux';
import { WzRequest, formatUIDate } from '../../../react-services';
import { AgentStatTable } from './table';
Expand Down Expand Up @@ -80,6 +80,7 @@ const statsAgents: {title: string, field: string, render?: (value) => any}[] = [
];

export const MainAgentStats = compose(
withErrorBoundary,
withReduxProvider,
withGlobalBreadcrumb(({agent}) => [
{
Expand Down
18 changes: 7 additions & 11 deletions public/components/agents/syscollector/main.tsx
Expand Up @@ -10,16 +10,12 @@
* Find more information about this on the LICENSE file.
*/

import React, { Component } from 'react';
import { SyscollectorInventory } from './inventory'
import React from 'react';
import { withErrorBoundary } from '../../common/hocs';
import { SyscollectorInventory } from './inventory';

export class MainSyscollector extends Component {

constructor(props) {
super(props);
}

render() {
return (<SyscollectorInventory agent={this.props.agent}></SyscollectorInventory> )
}
function MainSyscollectorClass(props) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could be better like arrow functions
const MainSyscollectorClass = (props) => {

return <SyscollectorInventory agent={props.agent}></SyscollectorInventory>;
}

export const MainSyscollector = withErrorBoundary (MainSyscollectorClass);
Expand Up @@ -10,20 +10,8 @@
*
* Find more information about this on the LICENSE file.
*/
import React, { Component } from 'react';
import WzReduxProvider from '../../../redux/wz-redux-provider';
import WzCurrentAgentsSection from './agents-current-section'
import WzCurrentAgentsSection from './agents-current-section';
import { compose } from 'redux';
import { withErrorBoundary, withReduxProvider } from '../hocs';

export class WzCurrentAgentsSectionWrapper extends Component {
constructor(props) {
super(props);
}

render() {
return (
<WzReduxProvider>
<WzCurrentAgentsSection {...this.props}/>
</WzReduxProvider>
);
}
}
export const WzCurrentAgentsSectionWrapper = compose (withErrorBoundary, withReduxProvider) (WzCurrentAgentsSection);
3 changes: 2 additions & 1 deletion public/components/common/modules/discover/discover.tsx
Expand Up @@ -21,7 +21,7 @@ import { WazuhConfig } from '../../../../react-services/wazuh-config';
import { formatUIDate } from '../../../../react-services/time-service';
import { KbnSearchBar } from '../../../kbn-search-bar';
import { FlyoutTechnique } from '../../../../components/overview/mitre/components/techniques/components/flyout-technique';
import { withReduxProvider } from '../../../common/hocs';
import { withErrorBoundary, withReduxProvider } from '../../../common/hocs';
import { connect } from 'react-redux';
import { compose } from 'redux';
import _ from 'lodash';
Expand Down Expand Up @@ -57,6 +57,7 @@ const mapStateToProps = state => ({
});

export const Discover = compose(
withErrorBoundary,
withReduxProvider,
connect(mapStateToProps)
)(class Discover extends Component {
Expand Down
11 changes: 6 additions & 5 deletions public/components/common/modules/main.tsx
Expand Up @@ -27,9 +27,10 @@ import { getAngularModule, getDataPlugin, getUiSettings } from '../../../kibana-
import { MainModuleAgent } from './main-agent'
import { MainModuleOverview } from './main-overview';
import store from '../../../redux/store';
import WzReduxProvider from '../../../redux/wz-redux-provider.js';
import { compose } from 'redux';
import { withReduxProvider,withErrorBoundary } from '../hocs';

export class MainModule extends Component {
export const MainModule = compose (withErrorBoundary,withReduxProvider) (class MainModule extends Component {
Copy link
Contributor

Choose a reason for hiding this comment

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

Check prettier here

constructor(props) {
super(props);
this.reportingService = new ReportingService();
Expand Down Expand Up @@ -211,13 +212,13 @@ export class MainModule extends Component {
onSelectedTabChanged: (id) => this.onSelectedTabChanged(id)
}
return (
<WzReduxProvider>
<>
{agent &&
<MainModuleAgent {...{ ...this.props, ...mainProps }}></MainModuleAgent>
|| ((this.props.section && this.props.section !== 'welcome') &&
<MainModuleOverview {...{ ...this.props, ...mainProps }}></MainModuleOverview>)
}
</WzReduxProvider>
</>
);
}
}
})
Expand Up @@ -10,20 +10,8 @@
*
* Find more information about this on the LICENSE file.
*/
import React, { Component } from 'react';
import WzReduxProvider from '../../../redux/wz-redux-provider';
import WzCurrentOverviewSection from './overview-current-section'
import { compose } from 'redux';
import { withErrorBoundary, withReduxProvider } from '../hocs';
import WzCurrentOverviewSection from './overview-current-section';

export class WzCurrentOverviewSectionWrapper extends Component {
constructor(props) {
super(props);
}

render() {
return (
<WzReduxProvider>
<WzCurrentOverviewSection {...this.props}/>
</WzReduxProvider>
);
}
}
export const WzCurrentOverviewSectionWrapper = compose (withErrorBoundary, withReduxProvider) (WzCurrentOverviewSection);
13 changes: 5 additions & 8 deletions public/components/common/permissions/prompt.tsx
Expand Up @@ -16,15 +16,16 @@ import { useUserRolesRequirements } from '../hooks/useUserRoles';
import { EuiEmptyPrompt, EuiSpacer, EuiPanel } from '@elastic/eui';
import { TUserPermissions, TUserPermissionsFunction, TUserRoles, TUserRolesFunction } from '../permissions/button';
import { WzPermissionsFormatted } from './format';
import { withErrorBoundary } from '../hocs';

interface IEmptyPromptNoPermissions{
permissions?: TUserPermissions
roles?: TUserRoles
actions?: React.ReactNode
}

export const WzEmptyPromptNoPermissions = ({permissions, roles, actions}: IEmptyPromptNoPermissions) => {
const prompt = (<EuiEmptyPrompt
export const WzEmptyPromptNoPermissions = withErrorBoundary (({permissions, roles, actions}: IEmptyPromptNoPermissions) => {
return <EuiEmptyPrompt
iconType="securityApp"
title={<h2>You have no permissions</h2>}
body={
Expand All @@ -44,12 +45,8 @@ export const WzEmptyPromptNoPermissions = ({permissions, roles, actions}: IEmpty
</Fragment>
}
actions={actions}
/>)
return (
// <EuiPanel>{prompt}</EuiPanel>
prompt
)
}
/>
});

interface IPromptNoPermissions{
permissions?: TUserPermissions | TUserPermissionsFunction
Expand Down
10 changes: 4 additions & 6 deletions public/components/common/welcome/agents-welcome.js
Expand Up @@ -23,12 +23,9 @@ import {
EuiFlexGrid,
EuiButtonEmpty,
EuiTitle,
EuiHealth,
EuiHorizontalRule,
EuiPage,
EuiButton,
EuiPopover,
EuiSelect,
EuiLoadingChart,
EuiToolTip,
EuiButtonIcon,
Expand All @@ -54,8 +51,9 @@ import { updateCurrentAgentData } from '../../../redux/actions/appStateActions';
import WzTextWithTooltipIfTruncated from '../wz-text-with-tooltip-if-truncated';
import { getAngularModule } from '../../../kibana-services';
import { hasAgentSupportModule } from '../../../react-services/wz-agents';
import { withErrorBoundary } from '../hocs';

export class AgentsWelcome extends Component {
export const AgentsWelcome = withErrorBoundary (class AgentsWelcome extends Component {
_isMount = false;
constructor(props) {
super(props);
Expand Down Expand Up @@ -329,7 +327,7 @@ export class AgentsWelcome extends Component {
</EuiFlexGroup>
</EuiFlexItem>
</EuiFlexGroup>
);
);withErrorBoundary
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe type error?


}

Expand Down Expand Up @@ -614,4 +612,4 @@ export class AgentsWelcome extends Component {
</div>
);
}
}
})
19 changes: 3 additions & 16 deletions public/components/common/welcome/management-welcome-wrapper.js
Expand Up @@ -12,22 +12,9 @@
*
* DELETE THIS WRAPPER WHEN WELCOME SCREEN WAS NOT BE CALLED FROM ANGULARJS
*/
import React, { Component } from 'react';
import ManagementWelcome from './management-welcome';
import WzReduxProvider from '../../../redux/wz-redux-provider';
import './welcome.scss';
import { compose } from 'redux';
import { withErrorBoundary, withReduxProvider } from '../hocs';

export class ManagementWelcomeWrapper extends Component {
constructor(props) {
super(props);
this.state = {};
}

render() {
return (
<WzReduxProvider>
<ManagementWelcome {...this.props} />
</WzReduxProvider>
);
}
}
export const ManagementWelcomeWrapper = compose (withErrorBoundary,withReduxProvider)(ManagementWelcome)
5 changes: 3 additions & 2 deletions public/components/common/welcome/overview-welcome.js
Expand Up @@ -31,8 +31,9 @@ import { updateCurrentTab } from '../../../redux/actions/appStateActions';
import store from '../../../redux/store';
import './welcome.scss';
import { WAZUH_MODULES } from '../../../../common/wazuh-modules';
import { withErrorBoundary } from '../hocs';

export class OverviewWelcome extends Component {
export const OverviewWelcome = withErrorBoundary (class OverviewWelcome extends Component {
constructor(props) {
super(props);
this.strtools = new StringsTools();
Expand Down Expand Up @@ -186,4 +187,4 @@ export class OverviewWelcome extends Component {
</Fragment>
);
}
}
})
5 changes: 3 additions & 2 deletions public/components/health-check/health-check.tsx
Expand Up @@ -13,8 +13,9 @@ import { WAZUH_ERROR_DAEMONS_NOT_READY, WAZUH_INDEX_TYPE_STATISTICS, WAZUH_INDEX
import { checkKibanaSettings, checkKibanaSettingsTimeFilter, checkKibanaSettingsMaxBuckets } from './lib';
import store from '../../redux/store';
import { updateWazuhNotReadyYet } from '../../redux/actions/appStateActions.js';
import { withErrorBoundary } from '../common/hocs';

export class HealthCheck extends Component {
export const HealthCheck = withErrorBoundary (class HealthCheck extends Component {
checkPatternCount = 0;
constructor(props) {
super(props);
Expand Down Expand Up @@ -502,4 +503,4 @@ export class HealthCheck extends Component {
</div >
);
}
};
});
6 changes: 3 additions & 3 deletions public/components/management/cluster/cluster-disabled.js
@@ -1,7 +1,7 @@
import React, { Component, Fragment } from 'react';
import { EuiPage, EuiPageContent, EuiEmptyPrompt } from '@elastic/eui';

export class ClusterDisabled extends Component {
import { withErrorBoundary } from '../../common/hocs'
export const ClusterDisabled = withErrorBoundary (class ClusterDisabled extends Component {
constructor(props) {
super(props);
this.state = {};
Expand Down Expand Up @@ -43,4 +43,4 @@ export class ClusterDisabled extends Component {
</EuiPage>
);
}
}
})