Skip to content

Commit

Permalink
Feature/implement error boundary hoc (#3367)
Browse files Browse the repository at this point in the history
* Feature/3316 error handler orchestrator (#3327)

* feat(errorBoundary): Added ErrorBoundary HOC and component and added loglevel dependency

* feature(errorBoundary): Moved with the others HOCs.

* feature(errorBoundary): Typo refactor.

* First attempt LoggerService

* Merged error boundary, integrated loggerService.

* changed logger name, create logger-service test file

* Updated CHANGELOG

* Moved to react-services, changed name, traslates comments

* feat(errorBoundary): Removed old integration

* refactor(loggerService): Changed class for function methods.

* test(logger-service): Added basic unit test to logger-service

* refactor(logger-service): Applied new implementation of error-orchestrator service.

* feature(logger-service): PR comments and some refactors.

Co-authored-by: gabiwassan <gabriel.wassan@wazuh.com>
Co-authored-by: Ibarra Maximiliano <maximiliano.ibarra@wazuh.com>

* Added ErrorBoundary HOC and component. (#3321)

* feat(errorBoundary): Added ErrorBoundary HOC and component and added loglevel dependency

* feature(errorBoundary): Moved with the others HOCs.

* feature(errorBoundary): Typo refactor.

* feature(errorBoundary): Some refactors

* feat(errorBoundary): PR comments and rollback agent-preview

* doc(changelog): Update changelog

* feat(errorBoundary): Rollback

* feat(errorBoundary): Rollback

* feat(errorBoundary): Rollback

* feat(errorBoundary): Rollback

* feat(errorBoundary): Refactor props, pr comments.

* feat(errorBoundary): Added unit test for error boundary.

* feat(errorBoundary): Separated error boundary component of hoc

* doc(error-boundary): Fixed and added licenses blocks.

* feature(logger-service): PR comments

* feature(logger-orchestrator): Refactors on management of severity.

* feature(logger-orchestrator): Refactor on wz-blank-screen component.

* feature(logger-orchestrator): Separated prompt component from error-boundary.

* feature(logger-orchestrator): Typo.

* test(error-boundary): Update snapshots.

* test(error-boundary): Update snapshots

* fix(logger-orchestrator): PR comments and refactors, fix unit tests.

* test(error-orchestrator-base): Added simple unit test. Fixed licence block.

* test(error-orchestrator-base): Added simple unit test to ErrorOrchestratorCritical

* test(error-orchestrator-ui): Added simple unit test to ErrorOrchestratorUi

* Create new backend service (#3324)

* Add endpoint

* Create new backend service

* Add changelog

* Renamed constants

* Added interfaces, created new controller and renamed

* Created ui-logged, to prevent logger superclass

* Added types, fixed responses types

* Added new route file to ui-logs, changed method put to post, added in index,ts

* Added test files, we must create all unit tests to those new features

* Fixed if condition

* Rename tests files, created endpoints test

* Changed controller name ui-logs, removed duplicated export

* Fixed file comments

* Applied prettier formater

* Added new base class base-logger

* Remove wrong constants and fix errors

* test(ui-logger-controller): Added simple unit test.

* test(ui-logs-controller): Fix params.

* Added test to ui-logs controller

* Renamed test files

* test(logs-controller): Added mock to function checkFileExist + prettier.

* Solve comments

* Add copyright and remove unused import

Co-authored-by: Ibarra Maximiliano <maximiliano.ibarra@wazuh.com>
Co-authored-by: gabiwassan <gabriel.wassan@wazuh.com>

* bugfix(error-orchestrator): Added some improvements and fixes.

* test(ui-logs-controller): Updated unit test.

* Settings

* Added hoc

* Before rebase

* rebase 4.3-7.10

* Feature/3316 error handler orchestrator (#3327)

* feat(errorBoundary): Added ErrorBoundary HOC and component and added loglevel dependency

* feature(errorBoundary): Moved with the others HOCs.

* feature(errorBoundary): Typo refactor.

* First attempt LoggerService

* Merged error boundary, integrated loggerService.

* changed logger name, create logger-service test file

* Updated CHANGELOG

* Moved to react-services, changed name, traslates comments

* feat(errorBoundary): Removed old integration

* refactor(loggerService): Changed class for function methods.

* test(logger-service): Added basic unit test to logger-service

* refactor(logger-service): Applied new implementation of error-orchestrator service.

* feature(logger-service): PR comments and some refactors.

Co-authored-by: gabiwassan <gabriel.wassan@wazuh.com>
Co-authored-by: Ibarra Maximiliano <maximiliano.ibarra@wazuh.com>

* Final implementations

* Fix errors and apply prettier

* Added changelog

Co-authored-by: Maximiliano Ibarra <maximilianoaibarra@gmail.com>
Co-authored-by: gabiwassan <gabriel.wassan@wazuh.com>
Co-authored-by: Ibarra Maximiliano <maximiliano.ibarra@wazuh.com>
  • Loading branch information
4 people committed Jun 15, 2021
1 parent fa6ec97 commit 2a52655
Show file tree
Hide file tree
Showing 42 changed files with 481 additions and 556 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -9,13 +9,13 @@ All notable changes to the Wazuh app project will be documented in this file.
- Added new endpoint service to collect the frontend logs into a file [#3324](https://github.com/wazuh/wazuh-kibana-app/pull/3324)
- Added new error handler to be responsible for the error orchestration [#3327](https://github.com/wazuh/wazuh-kibana-app/pull/3327)
- Added `Error Boundary` HOC and Component to handle render errors. [#3321](https://github.com/wazuh/wazuh-kibana-app/pull/3321)
- Implemented `Error Boundary` HOC in each main react-component. [#3367](https://github.com/wazuh/wazuh-kibana-app/pull/3367)

### Changed

- 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
16 changes: 4 additions & 12 deletions public/components/agents/syscollector/main.tsx
Expand Up @@ -10,16 +10,8 @@
* 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> )
}
}
export const MainSyscollector = withErrorBoundary(SyscollectorInventory);
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

0 comments on commit 2a52655

Please sign in to comment.