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

turning it all into one React app #35185

Merged
merged 16 commits into from
Apr 19, 2019
155 changes: 0 additions & 155 deletions x-pack/plugins/translations/translations/zh-CN.json

Large diffs are not rendered by default.

12 changes: 3 additions & 9 deletions x-pack/plugins/watcher/plugin_definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,8 @@ export const pluginDefinition = {
publicDir: resolve(__dirname, 'public'),
require: ['kibana', 'elasticsearch', 'xpack_main'],
uiExports: {
managementSections: [
'plugins/watcher/sections/watch_detail',
'plugins/watcher/sections/watch_edit',
'plugins/watcher/sections/watch_list',
'plugins/watcher/sections/watch_history_item',
],
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
home: ['plugins/watcher/register_feature']
managementSections: ['plugins/watcher'],
home: ['plugins/watcher/register_feature'],
},
init: function (server) {
registerLicenseChecker(server);
Expand All @@ -40,5 +34,5 @@ export const pluginDefinition = {
registerSettingsRoutes(server);
registerWatchesRoutes(server);
registerWatchRoutes(server);
}
},
};
3 changes: 3 additions & 0 deletions x-pack/plugins/watcher/public/app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<kbn-management-app section="elasticsearch/watcher">
<div id="watchReactRoot"></div>
</kbn-management-app>
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: no new line

59 changes: 59 additions & 0 deletions x-pack/plugins/watcher/public/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { HashRouter, Switch, Route, Redirect } from 'react-router-dom';
import { WatchStatus } from './sections/watch_status/watch_status';
import { WatchEdit } from './sections/watch_edit/components/watch_edit';
import { WatchList } from './sections/watch_list/components/watch_list';
import { registerRouter } from './lib/navigation';
import { BASE_PATH } from './constants';

class ShareRouter extends Component {
static contextTypes = {
router: PropTypes.shape({
history: PropTypes.shape({
push: PropTypes.func.isRequired,
createHref: PropTypes.func.isRequired
}).isRequired
}).isRequired
}
constructor(...args) {
super(...args);
this.registerRouter();
}

registerRouter() {
// Share the router with the app without requiring React or context.
const { router } = this.context;
registerRouter(router);
}

render() {
return this.props.children;
}
}
export const App = () => {
return (
<HashRouter>
<ShareRouter>
<AppWithoutRouter />
</ShareRouter>
</HashRouter>
);
};

// Export this so we can test it with a different router.
export const AppWithoutRouter = () => (
<Switch>
<Redirect exact from={`${BASE_PATH}`} to={`${BASE_PATH}watches`} />
<Route exact path={`${BASE_PATH}watches`} component={WatchList} />
<Route exact path={`${BASE_PATH}watches/watch/:id/status`} component={WatchStatus} />
<Route exact path={`${BASE_PATH}watches/watch/:id/edit`} component={WatchEdit} />
<Route exact path={`${BASE_PATH}watches/new-watch/:type`} component={WatchEdit} />
</Switch>
);

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading