mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* mobx: poc in using each store as individual prop on the react containers * prettier test * fix: end the war between prettier vs tslint. * mobx: Move stores into their own folders * mobx: Refactor the AlertRule into its own file and add a helper-file * mobx: Move NavItem out of NavStore and remove lodash dependancy * mobx: Move ResultItem and SearchResultSection models out of the SearchStore * mobx: ServerStatsStore rename .tsx => .ts. And move ServerStat-model to its own file. * mobx: Remove lodash and jquery dependancy from ViewStore * mobx: Remove issue with double question mark
34 lines
798 B
TypeScript
34 lines
798 B
TypeScript
import React from 'react';
|
|
import ReactDOM from 'react-dom';
|
|
import coreModule from 'app/core/core_module';
|
|
import { store } from 'app/stores/store';
|
|
import { Provider } from 'mobx-react';
|
|
|
|
function WrapInProvider(store, Component, props) {
|
|
return (
|
|
<Provider {...store}>
|
|
<Component {...props} />
|
|
</Provider>
|
|
);
|
|
}
|
|
|
|
/** @ngInject */
|
|
export function reactContainer($route, $location) {
|
|
return {
|
|
restrict: 'E',
|
|
template: '',
|
|
link(scope, elem) {
|
|
let component = $route.current.locals.component;
|
|
let props = {};
|
|
|
|
ReactDOM.render(WrapInProvider(store, component, props), elem[0]);
|
|
|
|
scope.$on('$destroy', function() {
|
|
ReactDOM.unmountComponentAtNode(elem[0]);
|
|
});
|
|
},
|
|
};
|
|
}
|
|
|
|
coreModule.directive('reactContainer', reactContainer);
|