[ML] Fixes watch creation for advanced job wizard. (#27594)

Fixes a regression where the advanced job creation wizard wouldn't trigger the watch creation flyout in the jobs list.

The advanced job creation wizard is still based on angularjs and triggered broadcast events to trigger the watch creation, but with the new React based jobs list the listeners for those events were gone.

This PR fixes it by passing on the jobs list wrapping angular scope to be able to subscribe to the events from the React based JobsListView component.

Passing on angular's scope down to React components should be considered a workaround so we don't have to refactor all affected code to use another event system. Once the advanced job wizard gets ported to React too this should be revisited.
This commit is contained in:
Walter Rafelsberger 2018-12-21 10:18:20 +01:00 committed by GitHub
parent 9b4a5a07d8
commit 8fb34fc752
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 4 deletions

View file

@ -62,6 +62,15 @@ export class JobsListView extends Component {
}
componentDidMount() {
// The advanced job wizard is still angularjs based and triggers
// broadcast events which it expects the jobs list to be subscribed to.
this.props.angularWrapperScope.$on('jobsUpdated', () => {
this.refreshJobSummaryList(true);
});
this.props.angularWrapperScope.$on('openCreateWatchWindow', (e, job) => {
this.showCreateWatchFlyout(job.job_id);
});
timefilter.disableTimeRangeSelector();
timefilter.enableAutoRefreshSelector();

View file

@ -46,7 +46,9 @@ module.directive('jobsPage', function () {
restrict: 'E',
link: (scope, element) => {
ReactDOM.render(
<I18nProvider>{React.createElement(JobsPage)}</I18nProvider>,
<I18nProvider>
{React.createElement(JobsPage, { angularWrapperScope: scope })}
</I18nProvider>,
element[0]
);
}

View file

@ -9,7 +9,6 @@ import { JobsListView } from './components/jobs_list_view';
import React from 'react';
export const JobsPage = () => (
<JobsListView />
export const JobsPage = (props) => (
<JobsListView {...props} />
);