From 9bc832d4dcb78e7aec98e11059af7f3053c3f91c Mon Sep 17 00:00:00 2001 From: Antonio Davi Macedo Coelho de Castro Date: Mon, 16 Sep 2019 00:39:07 -0700 Subject: [PATCH 1/2] Force pointer array items to always be pointers --- src/components/BrowserRow/BrowserRow.react.js | 3 ++- src/dashboard/Data/Browser/BrowserTable.react.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/BrowserRow/BrowserRow.react.js b/src/components/BrowserRow/BrowserRow.react.js index 5b7cf8d4d0..11aff817ed 100644 --- a/src/components/BrowserRow/BrowserRow.react.js +++ b/src/components/BrowserRow/BrowserRow.react.js @@ -1,4 +1,5 @@ import Parse from 'parse'; +import encode from 'parse/lib/browser/encode'; import React, { Component } from 'react'; import BrowserCell from 'components/BrowserCell/BrowserCell.react'; @@ -46,7 +47,7 @@ export default class BrowserRow extends Component { // "Parse._encoding" is responsible to convert Parse data into raw data. // Since array and object are generic types, we want to render them the way // they were stored in the database. - attr = Parse._encode(obj.get(name)); + attr = encode(obj.get(name), undefined, true); } } let hidden = false; diff --git a/src/dashboard/Data/Browser/BrowserTable.react.js b/src/dashboard/Data/Browser/BrowserTable.react.js index 414c2659d8..4b5b95255f 100644 --- a/src/dashboard/Data/Browser/BrowserTable.react.js +++ b/src/dashboard/Data/Browser/BrowserTable.react.js @@ -12,6 +12,7 @@ import Editor from 'dashboard/Data/Browser/Editor.react'; import EmptyState from 'components/EmptyState/EmptyState.react'; import Icon from 'components/Icon/Icon.react'; import Parse from 'parse'; +import encode from 'parse/lib/browser/encode'; import React from 'react'; import styles from 'dashboard/Data/Browser/Browser.scss'; import Button from 'components/Button/Button.react'; @@ -198,7 +199,7 @@ export default class BrowserTable extends React.Component { // "Parse._encoding" is responsible to convert Parse data into raw data. // Since array and object are generic types, we want to edit them the way // they were stored in the database. - value = Parse._encode(obj.get(name)); + value = encode(obj.get(name), undefined, true); } else { value = obj.get(name); } From ef3c89e717247bbf4c9ebad12b356c6e75803c43 Mon Sep 17 00:00:00 2001 From: Antonio Davi Macedo Coelho de Castro Date: Mon, 16 Sep 2019 15:56:47 -0700 Subject: [PATCH 2/2] Do not show invalid pointers after commiting a change in an array or object field --- src/dashboard/Data/Browser/Editor.react.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dashboard/Data/Browser/Editor.react.js b/src/dashboard/Data/Browser/Editor.react.js index d2a61a19bd..5425d333bc 100644 --- a/src/dashboard/Data/Browser/Editor.react.js +++ b/src/dashboard/Data/Browser/Editor.react.js @@ -12,6 +12,7 @@ import FileEditor from 'components/FileEditor/FileEditor.react'; import GeoPointEditor from 'components/GeoPointEditor/GeoPointEditor.react'; import NumberEditor from 'components/NumberEditor/NumberEditor.react'; import Parse from 'parse'; +import decode from 'parse/lib/browser/decode'; import React from 'react'; import StringEditor from 'components/StringEditor/StringEditor.react'; @@ -30,7 +31,7 @@ let Editor = ({ top, left, type, targetClass, value, readonly, width, onCommit } } else if (type === 'Array' || type === 'Object') { let encodeCommit = (json) => { try { - let obj = JSON.parse(json); + let obj = decode(JSON.parse(json)); onCommit(obj); } catch (e) { onCommit(value);