Skip to content
16 changes: 15 additions & 1 deletion src/components/BrowserCell/BrowserCell.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,21 @@ let BrowserCell = ({ type, value, hidden, width, current, onSelect, onEditChange
} else if (type === 'Boolean') {
content = value ? 'True' : 'False';
} else if (type === 'Array') {
content = JSON.stringify(value.map(val => val instanceof Parse.Object ? val.toPointer() : val))
const detectObject = (value) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you pull this function out so its not in the middle of this huge if/else?

if (Array.isArray(value)) {
return value.map(detectObject);
} else if (value instanceof Parse.Object) {
return value.toPointer();
} else if (typeof value === 'object') {
Object.keys(value).forEach(key => {
value[key] = detectObject(value[key]);
});
return value;
} else {
return value;
}
};
content = JSON.stringify(detectObject(value));
} else if (type === 'Object' || type === 'Bytes') {
content = JSON.stringify(value);
} else if (type === 'File') {
Expand Down
21 changes: 12 additions & 9 deletions src/dashboard/Data/Browser/BrowserTable.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,18 @@ export default class BrowserTable extends React.Component {
value = '';
} else if (type === 'Array') {
if (value) {
value = value.map(val => {
if (val instanceof Parse.Object) {
return val.toPointer();
} else if (val && typeof val.getMonth === 'function') {
return { __type: "Date", iso: val.toISOString() };
}

return val;
});
const detectObject = (value) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same?

if (Array.isArray(value)) {
return value.map(detectObject);
} else if (value instanceof Parse.Object) {
return value.toPointer();
} else if (value && typeof value.getMonth === 'function') {
return { __type: "Date", iso: value.toISOString() };
} else {
return value;
}
};
value = detectObject(value);
}
}
let wrapTop = Math.max(0, this.props.current.row * ROW_HEIGHT);
Expand Down