@@ -33092,11 +33092,9 @@ Object.defineProperty(exports, "__esModule", {
33092
33092
value: true
33093
33093
});
33094
33094
33095
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
33096
-
33097
- var _ramda = __webpack_require__(/*! ramda */ "./node_modules/ramda/index.js");
33095
+ var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
33098
33096
33099
- var _ramda2 = _interopRequireDefault(_ramda );
33097
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }( );
33100
33098
33101
33099
var _react = __webpack_require__(/*! react */ "react");
33102
33100
@@ -33114,6 +33112,12 @@ var _NotifyObservers = __webpack_require__(/*! ./components/core/NotifyObservers
33114
33112
33115
33113
var _NotifyObservers2 = _interopRequireDefault(_NotifyObservers);
33116
33114
33115
+ var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/lib/index.js");
33116
+
33117
+ var _ramda = __webpack_require__(/*! ramda */ "./node_modules/ramda/index.js");
33118
+
33119
+ var _constants = __webpack_require__(/*! ./constants/constants */ "./src/constants/constants.js");
33120
+
33117
33121
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33118
33122
33119
33123
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
@@ -33141,68 +33145,120 @@ var TreeContainer = function (_Component) {
33141
33145
}, {
33142
33146
key: 'render',
33143
33147
value: function render() {
33144
- return _render (this.props.layout);
33148
+ return recursivelyRender (this.props.layout, this.props.requestQueue );
33145
33149
}
33146
33150
}]);
33147
33151
33148
33152
return TreeContainer;
33149
33153
}(_react.Component);
33150
33154
33151
- exports.default = TreeContainer;
33152
-
33153
-
33154
33155
TreeContainer.propTypes = {
33155
- layout: _propTypes2.default.object
33156
+ layout: _propTypes2.default.object,
33157
+ requestQueue: _propTypes2.default.object
33156
33158
};
33157
33159
33158
- function _render (component) {
33159
- if (_ramda2.default. contains(_ramda2.default. type(component), ['String', 'Number', 'Null', 'Boolean'])) {
33160
+ function recursivelyRender (component, requestQueue ) {
33161
+ if ((0, _ramda. contains)((0, _ramda. type) (component), ['String', 'Number', 'Null', 'Boolean'])) {
33160
33162
return component;
33161
33163
}
33162
33164
33165
+ if ((0, _ramda.isEmpty)(component)) {
33166
+ return null;
33167
+ }
33168
+
33163
33169
// Create list of child elements
33164
33170
var children = void 0;
33165
33171
33166
- var componentProps = _ramda2.default. propOr({}, 'props', component);
33172
+ var componentProps = (0, _ramda. propOr) ({}, 'props', component);
33167
33173
33168
- if (!_ramda2.default. has('props', component) || !_ramda2.default. has('children', component.props) || typeof component.props.children === 'undefined') {
33174
+ if (!(0, _ramda. has) ('props', component) || !(0, _ramda. has) ('children', component.props) || typeof component.props.children === 'undefined') {
33169
33175
// No children
33170
33176
children = [];
33171
- } else if (_ramda2.default. contains(_ramda2.default. type(component.props.children), ['String', 'Number', 'Null', 'Boolean'])) {
33177
+ } else if ((0, _ramda. contains)((0, _ramda. type) (component.props.children), ['String', 'Number', 'Null', 'Boolean'])) {
33172
33178
children = [component.props.children];
33173
33179
} else {
33174
33180
// One or multiple objects
33175
33181
// Recursively render the tree
33176
33182
// TODO - I think we should pass in `key` here.
33177
- children = (Array.isArray(componentProps.children) ? componentProps.children : [componentProps.children]).map(_render);
33183
+ children = (Array.isArray(componentProps.children) ? componentProps.children : [componentProps.children]).map(function (child) {
33184
+ return recursivelyRender(child, requestQueue);
33185
+ });
33178
33186
}
33179
33187
33180
33188
if (!component.type) {
33181
33189
/* eslint-disable no-console */
33182
- console.error(_ramda2.default. type(component), component);
33190
+ console.error((0, _ramda. type) (component), component);
33183
33191
/* eslint-enable no-console */
33184
33192
throw new Error('component.type is undefined');
33185
33193
}
33186
33194
if (!component.namespace) {
33187
33195
/* eslint-disable no-console */
33188
- console.error(_ramda2.default. type(component), component);
33196
+ console.error((0, _ramda. type) (component), component);
33189
33197
/* eslint-enable no-console */
33190
33198
throw new Error('component.namespace is undefined');
33191
33199
}
33192
33200
var element = _registry2.default.resolve(component.type, component.namespace);
33193
33201
33194
- var parent = _react2.default.createElement.apply(_react2.default, [element, _ramda2.default.omit(['children'], component.props)].concat(_toConsumableArray(children)));
33202
+ var parent = _react2.default.createElement.apply(_react2.default, [element, (0, _ramda.omit)(['children'], component.props)].concat(_toConsumableArray(children)));
33203
+
33204
+ // loading prop coming from TreeContainer
33205
+ var isLoading = false;
33206
+ var loadingProp = void 0;
33207
+ var loadingComponent = void 0;
33208
+
33209
+ var id = componentProps.id;
33210
+
33211
+ if (requestQueue && requestQueue.filter) {
33212
+ (0, _ramda.forEach)(function (r) {
33213
+ var controllerId = (0, _ramda.isNil)(r.controllerId) ? '' : r.controllerId;
33214
+ if (r.status === 'loading' && (0, _ramda.contains)(id, controllerId)) {
33215
+ isLoading = true;
33216
+
33217
+ var _r$controllerId$split = r.controllerId.split('.');
33218
+
33219
+ var _r$controllerId$split2 = _slicedToArray(_r$controllerId$split, 2);
33220
+
33221
+ loadingComponent = _r$controllerId$split2[0];
33222
+ loadingProp = _r$controllerId$split2[1];
33223
+ }
33224
+ }, requestQueue);
33225
+
33226
+ var thisRequest = requestQueue.filter(function (r) {
33227
+ var controllerId = (0, _ramda.isNil)(r.controllerId) ? '' : r.controllerId;
33228
+ return (0, _ramda.contains)(id, controllerId);
33229
+ });
33230
+ if (thisRequest.status === _constants.STATUS.OK) {
33231
+ isLoading = false;
33232
+ }
33233
+ }
33234
+
33235
+ // Set loading state
33236
+ var loading_state = {
33237
+ is_loading: isLoading,
33238
+ prop_name: loadingProp,
33239
+ component_name: loadingComponent
33240
+ };
33195
33241
33196
33242
return _react2.default.createElement(
33197
33243
_NotifyObservers2.default,
33198
- { key: componentProps.id, id: componentProps.id },
33244
+ {
33245
+ key: componentProps.id,
33246
+ id: componentProps.id,
33247
+ loading_state: loading_state
33248
+ },
33199
33249
parent
33200
33250
);
33201
33251
}
33202
33252
33203
- _render.propTypes = {
33204
- children: _propTypes2.default.object
33205
- };
33253
+ function mapStateToProps(state, ownProps) {
33254
+ return {
33255
+ layout: ownProps.layout,
33256
+ loading: ownProps.loading,
33257
+ requestQueue: state.requestQueue
33258
+ };
33259
+ }
33260
+
33261
+ exports.default = (0, _reactRedux.connect)(mapStateToProps)(TreeContainer);
33206
33262
33207
33263
/***/ }),
33208
33264
@@ -34182,8 +34238,6 @@ Object.defineProperty(exports, "__esModule", {
34182
34238
34183
34239
var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/lib/index.js");
34184
34240
34185
- var _ramda = __webpack_require__(/*! ramda */ "./node_modules/ramda/index.js");
34186
-
34187
34241
var _actions = __webpack_require__(/*! ../../actions */ "./src/actions/index.js");
34188
34242
34189
34243
var _react = __webpack_require__(/*! react */ "react");
@@ -34194,6 +34248,8 @@ var _propTypes = __webpack_require__(/*! prop-types */ "./node_modules/prop-type
34194
34248
34195
34249
var _propTypes2 = _interopRequireDefault(_propTypes);
34196
34250
34251
+ var _ramda = __webpack_require__(/*! ramda */ "./node_modules/ramda/index.js");
34252
+
34197
34253
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
34198
34254
34199
34255
/*
@@ -34220,6 +34276,8 @@ function mergeProps(stateProps, dispatchProps, ownProps) {
34220
34276
children: ownProps.children,
34221
34277
dependencies: stateProps.dependencies,
34222
34278
paths: stateProps.paths,
34279
+ loading_state: ownProps.loading_state,
34280
+ requestQueue: stateProps.requestQueue,
34223
34281
34224
34282
setProps: function setProps(newProps) {
34225
34283
var payload = {
@@ -34242,7 +34300,8 @@ function NotifyObserversComponent(_ref) {
34242
34300
id = _ref.id,
34243
34301
paths = _ref.paths,
34244
34302
dependencies = _ref.dependencies,
34245
- setProps = _ref.setProps;
34303
+ setProps = _ref.setProps,
34304
+ loading_state = _ref.loading_state;
34246
34305
34247
34306
var thisComponentSharesState = dependencies && dependencies.find(function (dependency) {
34248
34307
return dependency.inputs.find(function (input) {
@@ -34275,6 +34334,10 @@ function NotifyObserversComponent(_ref) {
34275
34334
extraProps.setProps = setProps;
34276
34335
}
34277
34336
34337
+ if (children.props && !children.props.loading_state) {
34338
+ extraProps.loading_state = loading_state;
34339
+ }
34340
+
34278
34341
if (!(0, _ramda.isEmpty)(extraProps)) {
34279
34342
return _react2.default.cloneElement(children, extraProps);
34280
34343
}
@@ -34284,7 +34347,8 @@ function NotifyObserversComponent(_ref) {
34284
34347
NotifyObserversComponent.propTypes = {
34285
34348
id: _propTypes2.default.string.isRequired,
34286
34349
children: _propTypes2.default.node.isRequired,
34287
- path: _propTypes2.default.array.isRequired
34350
+ path: _propTypes2.default.array.isRequired,
34351
+ loading_state: _propTypes2.default.object
34288
34352
};
34289
34353
34290
34354
exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps, mergeProps)(NotifyObserversComponent);
0 commit comments