abb-core
Version:
Application Build Butler Core
46 lines (45 loc) • 1.73 kB
JavaScript
import * as tslib_1 from "tslib";
import * as React from 'react';
import { ABBContainer, ABBTimedPromiseFactory, } from "../..";
import { connect } from "react-redux";
import { renderRoutes } from 'react-router-config';
import { Router } from 'react-router';
import { createMemoryHistory } from "history";
var ABBRouter = /** @class */ (function (_super) {
tslib_1.__extends(ABBRouter, _super);
function ABBRouter(props) {
var _this = _super.call(this, props) || this;
_this.routerInitialized = ABBTimedPromiseFactory.create();
_this._history = createMemoryHistory();
_this.state = {};
return _this;
}
Object.defineProperty(ABBRouter.prototype, "History", {
get: function () {
return this._history;
},
enumerable: true,
configurable: true
});
ABBRouter.prototype.render = function () {
var _this = this;
var Header = this.props.Header;
return (React.createElement(Router, { history: this._history, ref: function (routerComp) {
if (routerComp) {
_this.routerInitialized.resolve(routerComp);
}
} },
React.createElement(ABBContainer, null,
React.createElement(Header, { CoreAPI: this.props.CoreAPI }),
React.createElement(ABBContainer, null, renderRoutes(this.props.routes.toArray())))));
};
return ABBRouter;
}(React.Component));
// connect Redux
var RCABBRouter = connect(function (state) {
return {
headerLogoURL: state.settings.headerLogoURL,
routes: state.routes
};
}, undefined, undefined, { forwardRef: true })(ABBRouter);
export { RCABBRouter, ABBRouter };