UNPKG

inversify-devtools

Version:
59 lines (58 loc) 2.99 kB
"use strict"; var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; var React = require("react"); var panel_1 = require("./panel"); var tip_1 = require("./tip"); var RequestTree = (function (_super) { __extends(RequestTree, _super); function RequestTree(props) { _super.call(this, props); } RequestTree.prototype.render = function () { return (React.createElement(panel_1.default, {title: "Composition Tree", subtitle: "Explorer", columnSize: this.props.columnSize, height: this.props.height}, this._render())); }; RequestTree.prototype._render = function () { var entry = this.props.entry; if (entry) { if (entry.details.error) { return this._renderError(); } else { return (React.createElement("div", {style: { overflowX: "scroll", width: "200%" }}, this._renderTree(entry))); } } else { return this._renderTip(); } }; RequestTree.prototype._renderTip = function () { return (React.createElement(tip_1.default, null, "Click on one of the requests on the request log to see its details!")); }; RequestTree.prototype._renderError = function () { return (React.createElement("div", {className: "customErrorAlert"}, React.createElement("i", {className: "fa fa-exclamation-circle", "aria-hidden": "true"}), "The composition tree cannot be displayed due to an error during the" + ' ' + "resolution process. Please refer to the request details panel to" + ' ' + "find out more information.")); }; RequestTree.prototype._renderTree = function (entry) { var rootRequest = entry.details.rootRequest; return (React.createElement("div", {className: "tree", style: { width: "1000px" }}, React.createElement("ul", null, React.createElement("li", null, this._renderNode(rootRequest), this._renderLeaf(rootRequest.childRequests))))); }; RequestTree.prototype._renderNode = function (request) { var result = request.bindings[0].implementationType; return React.createElement("a", {href: "#"}, request.serviceIdentifier, " ", "\u279e", " ", result.name); }; RequestTree.prototype._renderLeaf = function (childRequests) { var _this = this; if (childRequests.length === 0) { return React.createElement("span", null); } return (React.createElement("ul", null, childRequests.map(function (childRequest) { return (React.createElement("li", null, _this._renderNode(childRequest), _this._renderLeaf(childRequest.childRequests))); }))); }; return RequestTree; }(React.Component)); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = RequestTree;