parent
73e7ac28f5
commit
73df41bd70
|
@ -5,13 +5,14 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Switch, Route } from 'react-router-dom';
|
||||
import { Switch, Route, Redirect } from 'react-router-dom';
|
||||
import { BASE_PATH } from '../common/constants';
|
||||
import { IndexList } from './sections/index_list';
|
||||
|
||||
export const App = () => (
|
||||
<div>
|
||||
<Switch>
|
||||
<Redirect exact from={`${BASE_PATH}`} to={`${BASE_PATH}indices`}/>
|
||||
<Route exact path={`${BASE_PATH}indices`} component={IndexList} />
|
||||
<Route path={`${BASE_PATH}indices/filter/:filter?`} component={IndexList}/>
|
||||
</Switch>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { render } from 'react-dom';
|
||||
import { render, unmountComponentAtNode } from 'react-dom';
|
||||
import { Provider } from 'react-redux';
|
||||
import { HashRouter } from 'react-router-dom';
|
||||
import { I18nProvider } from '@kbn/i18n/react';
|
||||
|
@ -21,6 +21,7 @@ import template from './main.html';
|
|||
import { manageAngularLifecycle } from './lib/manage_angular_lifecycle';
|
||||
import { indexManagementStore } from './store';
|
||||
|
||||
let elem;
|
||||
const renderReact = async (elem) => {
|
||||
render(
|
||||
<I18nProvider>
|
||||
|
@ -39,6 +40,9 @@ routes.when(`${BASE_PATH}:view?/:action?/:id?`, {
|
|||
controllerAs: 'indexManagement',
|
||||
controller: class IndexManagementController {
|
||||
constructor($scope, $route, $http, kbnUrl, $rootScope) {
|
||||
// clean up previously rendered React app if one exists
|
||||
// this happens because of React Router redirects
|
||||
elem && unmountComponentAtNode(elem);
|
||||
// NOTE: We depend upon Angular's $http service because it's decorated with interceptors,
|
||||
// e.g. to check license status per request.
|
||||
setHttpClient($http);
|
||||
|
@ -49,7 +53,7 @@ routes.when(`${BASE_PATH}:view?/:action?/:id?`, {
|
|||
}
|
||||
});
|
||||
$scope.$$postDigest(() => {
|
||||
const elem = document.getElementById('indexManagementReactRoot');
|
||||
elem = document.getElementById('indexManagementReactRoot');
|
||||
renderReact(elem);
|
||||
manageAngularLifecycle($scope, $route, elem);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue