Skip to content

Commit 59a1889

Browse files
committed
Fix passing a debug data
1 parent 88cb2ee commit 59a1889

6 files changed

Lines changed: 104 additions & 130 deletions

File tree

src/framework/components/PageComposer/ComponentWrapper.js

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -250,27 +250,7 @@ class ComponentWrapper extends Component {
250250
}
251251

252252
render() {
253-
const wrapperPicked = pickInObject(this.props, ['elementKey', 'wrappedComponent', 'wrappedProps', 'children']);
254-
const restPicked = omitInObject(
255-
this.props,
256-
[
257-
'isSelected',
258-
'elementKey',
259-
'wrappedComponent',
260-
'wrappedProps',
261-
'cloneProps',
262-
'children',
263-
'itemWasDropped',
264-
'draggedItem',
265-
'draggedItemPosition',
266-
'onMouseDown',
267-
'onContextMenuClick',
268-
'onComponentInstanceInitialize',
269-
'onComponentInstanceDestroy',
270-
'doNotUseInFlows'
271-
]
272-
);
273-
const {elementKey, wrappedComponent, wrappedProps, children} = wrapperPicked;
253+
const {elementKey, wrappedComponent, wrappedProps, children} = this.props;
274254
if (!wrappedComponent) {
275255
return (
276256
<div key={elementKey} style={style}>
@@ -285,7 +265,7 @@ class ComponentWrapper extends Component {
285265
</div>
286266
);
287267
}
288-
return React.createElement(wrappedComponent, {...restPicked, ...wrappedProps}, children);
268+
return React.createElement(wrappedComponent, wrappedProps, children);
289269
}
290270
}
291271

src/framework/components/PageComposer/PageComposer.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ class PageComposer extends React.Component {
414414
draggedItemPosition
415415
} = this.state;
416416
selectedKeys = [];
417-
const rootComponent = renderComponent(userComponents, componentsTree, {
417+
return renderComponent(userComponents, componentsTree, {
418418
itemWasDropped: this.itemWasDropped,
419419
draggedItem,
420420
draggedItemPosition,
@@ -423,7 +423,6 @@ class PageComposer extends React.Component {
423423
onComponentInstanceInitialize: this.handleComponentInstanceInitialize,
424424
onComponentInstanceDestroy: this.handleComponentInstanceDestroy
425425
});
426-
return rootComponent;
427426
}
428427

429428
render () {

src/framework/components/PageComposition/Container.js

Lines changed: 27 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import cloneDeep from 'lodash/cloneDeep';
12
import React from 'react';
2-
import { pickInObject, omitInObject } from '../../commons/utilities';
33
import { connect } from 'react-redux';
44
import { bindActionCreators } from 'redux';
55
import { createStructuredSelector } from 'reselect';
@@ -30,15 +30,17 @@ class Container extends React.Component {
3030
const handlerAction = actions[eventHandler.name];
3131
if (handlerAction) {
3232
if (process.env.NODE_ENV !== 'production') {
33-
sendDebugMessage({
34-
key: componentKey,
35-
eventType: constants.DEBUG_MSG_COMPONENT_FIRE_EVENT,
36-
eventName: eventHandler.name,
37-
outputData: args && args.length > 0 ? args[0] : undefined,
38-
componentName,
39-
componentInstance,
40-
timestamp: Date.now(),
41-
});
33+
if (window.__webcodeskIsListeningToFramework && window.__sendFrameworkMessage) {
34+
sendDebugMessage({
35+
key: componentKey,
36+
eventType: constants.DEBUG_MSG_COMPONENT_FIRE_EVENT,
37+
eventName: eventHandler.name,
38+
outputData: args && args.length > 0 ? cloneDeep(args[0]) : undefined,
39+
componentName,
40+
componentInstance,
41+
timestamp: Date.now(),
42+
});
43+
}
4244
}
4345
handlerAction.apply(null, [args[0], args[1]]);
4446
} else {
@@ -54,72 +56,48 @@ class Container extends React.Component {
5456
shouldComponentUpdate (nextProps, nextState, nextContext) {
5557
if (process.env.NODE_ENV !== 'production') {
5658
if (nextProps.stateProps !== this.props.stateProps) {
57-
const { componentName, componentInstance, componentKey } = this.props;
58-
sendDebugMessage({
59-
key: componentKey,
60-
eventType: constants.DEBUG_MSG_NEW_PROPS_EVENT,
61-
inputData: nextProps.stateProps,
62-
componentName,
63-
componentInstance,
64-
timestamp: Date.now(),
65-
});
59+
if (window.__webcodeskIsListeningToFramework && window.__sendFrameworkMessage) {
60+
const { componentName, componentInstance, componentKey } = this.props;
61+
sendDebugMessage({
62+
key: componentKey,
63+
eventType: constants.DEBUG_MSG_NEW_PROPS_EVENT,
64+
inputData: cloneDeep(nextProps.stateProps),
65+
componentName,
66+
componentInstance,
67+
timestamp: Date.now(),
68+
});
69+
}
6670
}
6771
}
6872
return true;
6973
}
7074

7175
render () {
72-
const wrapperPicked = pickInObject(
73-
this.props,
74-
['wrappedComponent', 'wrappedProps', 'stateProps', 'populatedProps', 'children']
75-
);
76-
const restPicked = omitInObject(
77-
this.props,
78-
[
79-
'componentKey',
80-
'componentName',
81-
'componentInstance',
82-
'containerEventHandlers',
83-
'containerProperties',
84-
'wrappedProps',
85-
'populatedProps',
86-
'wrappedComponent',
87-
'children'
88-
]
89-
);
9076
const {
9177
wrappedComponent,
9278
wrappedProps,
9379
stateProps,
9480
populatedProps,
9581
children
96-
} = wrapperPicked;
82+
} = this.props;
9783
return React.createElement(
9884
wrappedComponent,
99-
{ ...restPicked, ...wrappedProps, ...this.wrappedHandlers, ...populatedProps, ...stateProps },
85+
{ ...wrappedProps, ...this.wrappedHandlers, ...populatedProps, ...stateProps },
10086
children
10187
);
10288
}
10389
}
10490

10591
class Component extends React.Component {
10692
render () {
107-
const wrapperPicked = pickInObject(
108-
this.props,
109-
['wrappedComponent', 'wrappedProps', 'children']
110-
);
111-
const restPicked = omitInObject(
112-
this.props,
113-
['wrappedComponent', 'wrappedProps', 'children']
114-
);
11593
const {
11694
wrappedComponent,
11795
wrappedProps,
11896
children
119-
} = wrapperPicked;
97+
} = this.props;
12098
return React.createElement(
12199
wrappedComponent,
122-
{ ...restPicked, ...wrappedProps },
100+
wrappedProps,
123101
children
124102
);
125103
}

src/framework/components/PageComposition/PageComposition.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import get from 'lodash/get';
66
import isUndefined from 'lodash/isUndefined';
77
import isArray from 'lodash/isArray';
88
import isPlainObject from 'lodash/isObject';
9+
import cloneDeep from 'lodash/cloneDeep';
910
import React, { Component } from 'react';
1011
import PropTypes from 'prop-types';
1112
import ErrorBoundary from './ErrorBoundary';
@@ -179,17 +180,19 @@ class PageComposition extends Component {
179180
}
180181
}
181182
if (process.env.NODE_ENV !== 'production') {
182-
if (!isEmpty(populatedProps)) {
183-
sendDebugMessage({
184-
key: componentKey,
185-
eventType: constants.DEBUG_MSG_CREATE_CONTAINER_EVENT,
186-
inputData: populatedProps,
187-
populatePath: normalizedRoutePath,
188-
propertyName,
189-
componentName: type,
190-
componentInstance: instance,
191-
timestamp: Date.now(),
192-
});
183+
if (window.__webcodeskIsListeningToFramework && window.__sendFrameworkMessage) {
184+
if (!isEmpty(populatedProps)) {
185+
sendDebugMessage({
186+
key: componentKey,
187+
eventType: constants.DEBUG_MSG_CREATE_CONTAINER_EVENT,
188+
inputData: cloneDeep(populatedProps),
189+
populatePath: normalizedRoutePath,
190+
propertyName,
191+
componentName: type,
192+
componentInstance: instance,
193+
timestamp: Date.now(),
194+
});
195+
}
193196
}
194197
}
195198
return createContainer(

src/framework/components/StartWrapper/StartWrapper.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import cloneDeep from 'lodash/cloneDeep';
12
import React from 'react';
23
import PropTypes from 'prop-types';
34
import createContainerActions from '../../store/actions';
@@ -33,13 +34,15 @@ class StartWrapper extends React.Component {
3334
const onDidMountAction = actions['onApplicationStart'];
3435
if (onDidMountAction) {
3536
if (process.env.NODE_ENV !== 'production') {
36-
sendDebugMessage({
37-
key: componentKey,
38-
eventType: constants.DEBUG_MSG_APPLICATION_START_EVENT,
39-
componentName,
40-
componentInstance,
41-
timestamp: Date.now(),
42-
});
37+
if (window.__webcodeskIsListeningToFramework && window.__sendFrameworkMessage) {
38+
sendDebugMessage({
39+
key: componentKey,
40+
eventType: constants.DEBUG_MSG_APPLICATION_START_EVENT,
41+
componentName,
42+
componentInstance,
43+
timestamp: Date.now(),
44+
});
45+
}
4346
}
4447
store.dispatch(onDidMountAction.apply(null, null));
4548
}

src/framework/store/actions.js

Lines changed: 50 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import isString from 'lodash/isString';
55
import isNumber from 'lodash/isNumber';
66
import isFunction from 'lodash/isFunction';
77
import isUndefined from 'lodash/isUndefined';
8+
import cloneDeep from 'lodash/cloneDeep';
89
import { COMPONENT_TYPE, USER_FUNCTION_TYPE, DISPATCH_ERROR_TYPE} from './constants';
910
import { getUserFunctionByName } from './sequences';
1011

@@ -76,45 +77,51 @@ function dispatchToComponent (props, payload, dispatch, helpers) {
7677
}
7778
}
7879
if (process.env.NODE_ENV !== 'production') {
79-
sendDebugMessage({
80-
key: componentKey,
81-
eventType: constants.DEBUG_MSG_FORWARD_EVENT,
82-
forwardPath,
83-
inputData: transformedPayload,
84-
propertyName,
85-
pathString,
86-
timestamp: Date.now(),
87-
});
80+
if (window.__webcodeskIsListeningToFramework && window.__sendFrameworkMessage) {
81+
sendDebugMessage({
82+
key: componentKey,
83+
eventType: constants.DEBUG_MSG_FORWARD_EVENT,
84+
forwardPath,
85+
inputData: cloneDeep(transformedPayload),
86+
propertyName,
87+
pathString,
88+
timestamp: Date.now(),
89+
});
90+
}
8891
}
8992
history.push(pathString);
9093
} else if (propertyName) {
9194
// hmmm... why there can not be the history helper?
9295
const targetKey = `${componentName}_${componentInstance}`;
9396
if (process.env.NODE_ENV !== 'production') {
97+
if (window.__webcodeskIsListeningToFramework && window.__sendFrameworkMessage) {
98+
sendDebugMessage({
99+
key: componentKey,
100+
eventType: constants.DEBUG_MSG_REDUCE_DATA_EVENT,
101+
inputData: cloneDeep(transformedPayload),
102+
componentName,
103+
componentInstance,
104+
propertyName,
105+
timestamp: Date.now(),
106+
});
107+
}
108+
}
109+
dispatch({ type: targetKey, payload: { [propertyName]: transformedPayload } });
110+
}
111+
} else {
112+
const targetKey = `${componentName}_${componentInstance}`;
113+
if (process.env.NODE_ENV !== 'production') {
114+
if (window.__webcodeskIsListeningToFramework && window.__sendFrameworkMessage) {
94115
sendDebugMessage({
95116
key: componentKey,
96117
eventType: constants.DEBUG_MSG_REDUCE_DATA_EVENT,
97-
inputData: transformedPayload,
118+
inputData: cloneDeep(transformedPayload),
98119
componentName,
99120
componentInstance,
100121
propertyName,
101122
timestamp: Date.now(),
102123
});
103124
}
104-
dispatch({ type: targetKey, payload: { [propertyName]: transformedPayload } });
105-
}
106-
} else {
107-
const targetKey = `${componentName}_${componentInstance}`;
108-
if (process.env.NODE_ENV !== 'production') {
109-
sendDebugMessage({
110-
key: componentKey,
111-
eventType: constants.DEBUG_MSG_REDUCE_DATA_EVENT,
112-
inputData: transformedPayload,
113-
componentName,
114-
componentInstance,
115-
propertyName,
116-
timestamp: Date.now(),
117-
});
118125
}
119126
dispatch({ type: targetKey, payload: { [propertyName]: transformedPayload } });
120127
}
@@ -151,14 +158,16 @@ function executeUserFunctionDispatch (
151158
if (eventTargets && eventTargets.length > 0) {
152159
payload = dispatchPayloads[dispatchType];
153160
if (process.env.NODE_ENV !== 'production') {
154-
sendDebugMessage({
155-
key: functionKey,
156-
eventType: constants.DEBUG_MSG_FUNCTION_FIRE_EVENT,
157-
eventName: dispatchType,
158-
outputData: payload,
159-
functionName: functionName,
160-
timestamp: Date.now(),
161-
});
161+
if (window.__webcodeskIsListeningToFramework && window.__sendFrameworkMessage) {
162+
sendDebugMessage({
163+
key: functionKey,
164+
eventType: constants.DEBUG_MSG_FUNCTION_FIRE_EVENT,
165+
eventName: dispatchType,
166+
outputData: cloneDeep(payload),
167+
functionName: functionName,
168+
timestamp: Date.now(),
169+
});
170+
}
162171
}
163172
eventTargets.forEach(eventTarget => {
164173
const { type: eventTargetType, props: eventTargetProps } = eventTarget;
@@ -240,13 +249,15 @@ function createTasks (targets) {
240249
transformFirstArgument(props.functionKey, props.transformScript, args[0]);
241250
// execute user function with passed in args
242251
if (process.env.NODE_ENV !== 'production') {
243-
sendDebugMessage({
244-
key: props.functionKey,
245-
eventType: constants.DEBUG_MSG_FUNCTION_CALL_EVENT,
246-
inputData: firstArgument,
247-
functionName: props.functionName,
248-
timestamp: Date.now(),
249-
});
252+
if (window.__webcodeskIsListeningToFramework && window.__sendFrameworkMessage) {
253+
sendDebugMessage({
254+
key: props.functionKey,
255+
eventType: constants.DEBUG_MSG_FUNCTION_CALL_EVENT,
256+
inputData: cloneDeep(firstArgument),
257+
functionName: props.functionName,
258+
timestamp: Date.now(),
259+
});
260+
}
250261
}
251262
// the secondary argument is used in the store items function
252263
// to determine if we are reading from the store item or writing to it

0 commit comments

Comments
 (0)