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

Remove AngularJS controller of blank screen #6538

Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -22,6 +22,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Change the view of API is down and check connection to Server APIs application [#6337](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6337)
- Changed the usage of the endpoint GET /groups/{group_id}/files/{file_name} [#6385](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6385)
- Refactoring and redesign endpoints summary visualizations [#6268](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6268)
- Move the AngularJS controller and template of blank screen to ReactJS component [#6538](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6538)

### Fixed

Expand Down
66 changes: 62 additions & 4 deletions plugins/main/public/components/wz-blank-screen/wz-blank-screen.js
Expand Up @@ -12,19 +12,77 @@
import React, { Component } from 'react';
import { EuiButton, EuiSpacer, EuiLink } from '@elastic/eui';
import { ErrorComponentPrompt } from '../common/error-boundary-prompt/error-boundary-prompt';
import { PLUGIN_PLATFORM_WAZUH_DOCUMENTATION_URL_PATH_TROUBLESHOOTING, PLUGIN_PLATFORM_URL_GUIDE, PLUGIN_PLATFORM_URL_GUIDE_TITLE } from '../../../common/constants';
import {
PLUGIN_PLATFORM_WAZUH_DOCUMENTATION_URL_PATH_TROUBLESHOOTING,
PLUGIN_PLATFORM_URL_GUIDE,
PLUGIN_PLATFORM_URL_GUIDE_TITLE,
UI_LOGGER_LEVELS,
} from '../../../common/constants';
import { webDocumentationLink } from '../../../common/services/web_documentation';
import { AppState } from '../../react-services/app-state';
import { WzMisc } from '../../factories/misc';
import { getAngularModule } from '../../kibana-services';
import { ErrorHandler } from '../../react-services/error-handler';
import { UI_ERROR_SEVERITIES } from '../../react-services/error-orchestrator/types';
import { getErrorOrchestrator } from '../../react-services/common-services';

export class WzBlankScreen extends Component {
constructor(props) {
super(props);
this.state = {};
this.state = {
errorToShow: null,
};

// Get $location forom AngularJS
const $injector = getAngularModule().$injector;
Desvelao marked this conversation as resolved.
Show resolved Hide resolved
this.$location = $injector.get('$location');

// Create instance of WzMisc that stores the error
this.wzMisc = new WzMisc();
}

componentDidMount() {
AppState.setWzMenu();
const catchedError = this.wzMisc.getBlankScr();
if (catchedError) {
let parsed = null;
try {
parsed = ErrorHandler.handle(catchedError, '', { silent: true });
} catch (error) {
const options = {
context: `${WzBlankScreen.name}.componentDidMount`,
level: UI_LOGGER_LEVELS.ERROR,
severity: UI_ERROR_SEVERITIES.UI,
error: {
error: error,
message: error.message || error,
title: error.name,
},
};
getErrorOrchestrator().handleError(options);
}

this.setState({ errorToShow: parsed || catchedError });
this.wzMisc.setBlankScr(false);
} else {
this.goOverview();
}
}

/**
* This navigate to overview
*/
goOverview() {
this.$location.path('/overview');
Desvelao marked this conversation as resolved.
Show resolved Hide resolved
}

render() {
if (!this.state.errorToShow) {
return null;
}
return (
<ErrorComponentPrompt
errorTitle={this.props.errorToShow}
errorTitle={this.state.errorToShow}
errorInfo={''}
action={
<>
Expand Down Expand Up @@ -52,7 +110,7 @@ export class WzBlankScreen extends Component {
</p>
<EuiSpacer />

<EuiButton onClick={this.props.goToOverview} color="primary" fill>
<EuiButton onClick={() => this.goToOverview()} color='primary' fill>
Refresh
</EuiButton>
</>
Expand Down
1 change: 0 additions & 1 deletion plugins/main/public/controllers/index.ts
Expand Up @@ -16,4 +16,3 @@ import './agent';
import './settings';
import './security';
import './tools';
import './misc';
80 changes: 0 additions & 80 deletions plugins/main/public/controllers/misc/blank-screen-controller.js

This file was deleted.

18 changes: 0 additions & 18 deletions plugins/main/public/controllers/misc/index.js

This file was deleted.

@@ -1,5 +1 @@
<div ng-controller="blankScreenController as ctrl">
<div ng-if="ctrl.showErrorPage">
<react-component name="WzBlankScreen" props="blankScreenProps" ></react-component>
</div>
</div>
<react-component name="WzBlankScreen"></react-component>