Skip to content

Commit

Permalink
fixed props data that was passed
Browse files Browse the repository at this point in the history
  • Loading branch information
ritz078 committed Apr 8, 2016
1 parent 935f54c commit 27d7f94
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 26 deletions.
15 changes: 4 additions & 11 deletions dist/client/ui/action_logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _jsonStringifySafe = require('json-stringify-safe');

var _jsonStringifySafe2 = _interopRequireDefault(_jsonStringifySafe);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var preStyle = {
Expand Down Expand Up @@ -95,19 +91,16 @@ var ActionLogger = function (_Component) {
}, {
key: 'getActionData',
value: function getActionData() {
var _props$data$actions = this.props.data.actions;
var actions = _props$data$actions === undefined ? [] : _props$data$actions;

return actions.map(function (action, i) {
return this.props.actionLogs.map(function (action, i) {
// assuming that the first object in the array is the latest addition.
return i === 0 ? _react2.default.createElement(
'div',
{ style: latestActionLogStyle, ref: 'actionLogger', key: i },
(0, _jsonStringifySafe2.default)(action, null, 2)
action
) : _react2.default.createElement(
'div',
{ key: i },
(0, _jsonStringifySafe2.default)(action, null, 2)
action
);
});
}
Expand Down Expand Up @@ -142,7 +135,7 @@ var ActionLogger = function (_Component) {

ActionLogger.propTypes = {
onClear: _react2.default.PropTypes.func,
data: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.array.isRequired, _react2.default.PropTypes.object.isRequired])
actionLogs: _react2.default.PropTypes.array
};

exports.default = ActionLogger;
12 changes: 11 additions & 1 deletion dist/client/ui/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ var _reactDom = require('react-dom');

var _reactDom2 = _interopRequireDefault(_reactDom);

var _jsonStringifySafe = require('json-stringify-safe');

var _jsonStringifySafe2 = _interopRequireDefault(_jsonStringifySafe);

var _controls = require('./controls');

var _controls2 = _interopRequireDefault(_controls);
Expand Down Expand Up @@ -95,7 +99,13 @@ function getIframe(data) {
}

function getActionLogger(data) {
return _react2.default.createElement(_action_logger2.default, { data: data, onClear: clearLogs });
var _data$actions = data.actions;
var actions = _data$actions === undefined ? [] : _data$actions;

var logs = actions.map(function (action) {
return (0, _jsonStringifySafe2.default)(action, null, 2);
});
return _react2.default.createElement(_action_logger2.default, { actionLogs: logs, onClear: clearLogs });
}

function renderMain(data) {
Expand Down
17 changes: 4 additions & 13 deletions src/client/ui/action_logger.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { Component } from 'react';
import stringify from 'json-stringify-safe';

const preStyle = {
color: '#666',
Expand Down Expand Up @@ -53,18 +52,13 @@ class ActionLogger extends Component {
}

getActionData() {
const { actions = [] } = this.props.data;
return actions
return this.props.actionLogs
.map((action, i) => {
// assuming that the first object in the array is the latest addition.
return i === 0 ? (
<div style={latestActionLogStyle} ref="actionLogger" key={i}>
{stringify(action, null, 2)}
</div>
<div style={latestActionLogStyle} ref="actionLogger" key={i}>{action}</div>
) : (
<div key={i}>
{stringify(action, null, 2)}
</div>
<div key={i}>{action}</div>
);
});
}
Expand All @@ -85,10 +79,7 @@ class ActionLogger extends Component {

ActionLogger.propTypes = {
onClear: React.PropTypes.func,
data: React.PropTypes.oneOfType([
React.PropTypes.array.isRequired,
React.PropTypes.object.isRequired,
]),
actionLogs: React.PropTypes.array,
};

export default ActionLogger;
6 changes: 5 additions & 1 deletion src/client/ui/admin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom';
import stringify from 'json-stringify-safe';
import StorybookControls from './controls';
import ActionLogger from './action_logger';
import Layout from './layout';
Expand Down Expand Up @@ -65,7 +66,10 @@ export function getIframe(data) {
}

export function getActionLogger(data) {
return (<ActionLogger data={data} onClear={clearLogs} />);
const { actions = [] } = data;
const logs = actions
.map((action) => stringify(action, null, 2));
return (<ActionLogger actionLogs={logs} onClear={clearLogs} />);
}

export function renderMain(data) {
Expand Down

0 comments on commit 27d7f94

Please sign in to comment.