Skip to content

Fix #983 verify the whole array to check Parse.Objects into generic objects #984

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from
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