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

Conversation

dannywolfmx
Copy link

Recursive function to deal with nested objects and check if some children is a Parse.Object type

@dplewis
Copy link
Member

dplewis commented Feb 13, 2019

Can you post a screenshot?

@dannywolfmx
Copy link
Author

dannywolfmx commented Feb 14, 2019

Hi sure.

"Producto is a parse object"

Before

bug 1

bug

And this is my solution

after1
after 2

The problem with the actual dashboard is when you try to edit the cell, and the dashboard overwrite the parse server object keeping only the id and losing the reference

@dplewis dplewis requested a review from natanrolnik February 22, 2019 19:56
@dplewis
Copy link
Member

dplewis commented Mar 12, 2019

@dannywolfmx Thanks for starting this PR. There are two parts to this issue, displaying and editing.

This PR handles displaying properly.

There is an error with editing an array of array of objects.

testObject.set('arrayField', [[object]])

It stores correctly in the database as [[ '__type': 'Pointer' ...]] but if you edit it will save the full object.

https://github.com/parse-community/parse-dashboard/blob/master/src/dashboard/Data/Browser/BrowserTable.react.js#L204

@dannywolfmx
Copy link
Author

Interesting, let's me check the PR to solve the issues.

@dplewis
Copy link
Member

dplewis commented Mar 12, 2019

I added some nits make sure you pull it down

@dplewis
Copy link
Member

dplewis commented Apr 2, 2019

@dannywolfmx Can we get this one in? For the editing you can use similar recursion.

@dplewis
Copy link
Member

dplewis commented Apr 2, 2019

@dannywolfmx @masonlee Can you guys test this out? I added a fix for editing

@dplewis dplewis mentioned this pull request Apr 2, 2019
3 tasks
Copy link
Contributor

@acinader acinader left a comment

Choose a reason for hiding this comment

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

@dplewis with the returns and the recursive call in the middle of the larger big if, its hard to follow.

if you agree, pull detect out of the if into its own func?

@@ -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?


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?

@dannywolfmx
Copy link
Author

Hi guys, sorry for being late.

Unfortunately I had to work on other projects so I could not devote much time to review this code.

I hope this weekend to be able to finish fixing the bug commented by @dplewis.

It is correct @acinader, it is better to move that block of code out of the if / else so that it can be reused.

I Have a question, Wouldn't it be better to allow the developers to place comments so that other users understand better than the code does?, I find it complex understanding that makes each module to be able to locate the bug.

@dplewis
Copy link
Member

dplewis commented Apr 2, 2019

@dannywolfmx I went ahead and fixed the bug I mentioned. Just need another set of eyes for testing.

Wouldn't it be better to allow the developers to place comments so that other users understand better than the code does?

Can you elaborate?

@acinader
Copy link
Contributor

acinader commented Apr 2, 2019

@dannywolfmx there are no comments in that file, but there are in others.

definitely feel free to comment the code!

@dannywolfmx
Copy link
Author

@dplewis Ok, I'll review it this weekend

Copy link
Contributor

@acinader acinader left a comment

Choose a reason for hiding this comment

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

Ugh, sorry for serial picking instead of concurrent picking, but can you rename the function please.

we've already detected that it is an array. flattenArray?

And what if the values are date? boolean? etc. is that ok? or do we need another level of factoring here 1. process array 2. process values 3. populate the cell.

here we have 2 levels instead of 3....

@dannywolfmx
Copy link
Author

dannywolfmx commented Apr 2, 2019

mmm, @acinader you are right. If the user makes an array date types, it will be processed by the "JSON.stringify" and not by the dateStringUTC.

@dannywolfmx
Copy link
Author

We Could separate that great block of if/else in another function (setContent or setValue), this way would be easier to do the same thing that does "detectArray " but including all types

@dplewis
Copy link
Member

dplewis commented Apr 2, 2019

This is how dates are currently handled (with the fixes)

Before Edit (From Database)

"arrayTest": [
        [
            {
                "__type": "Pointer",
                "className": "TestObject",
                "objectId": "agBGsAr7uf"
            }
        ],
        {
            "$date": "2019-04-02T20:07:33.057Z"
        },
        [
            {
                "__type": "Date",
                "iso": "2019-04-02T20:07:33.057Z"
            }
        ]
    ],

Screen Shot 2019-04-02 at 4 06 35 PM

After Edit

"arrayTest": [
        [
            {
                "__type": "Pointer",
                "className": "TestObject",
                "objectId": "agBGsAr7uf"
            }
        ],
        {
            "$date": "2019-04-02T20:07:33.057Z"
        },
        [
            {
                "__type": "Date",
                "iso": "2019-04-02T20:07:33.057Z"
            }
        ]
    ],

Screen Shot 2019-04-02 at 4 10 28 PM

If you refresh it goes back to how it looked in before edit (note the data in the database is the same even though they look different for view / edit.

@ghost
Copy link

ghost commented May 9, 2019

Danger run resulted in 1 fail; to find out more, see the checks page.

Generated by 🚫 dangerJS

@stale
Copy link

stale bot commented Jul 4, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the state:wont-fix Won’t be fixed with a clearly stated reason label Jul 4, 2019
@stale stale bot closed this Jul 11, 2019
@dplewis dplewis reopened this Jul 11, 2019
@stale stale bot removed the state:wont-fix Won’t be fixed with a clearly stated reason label Jul 11, 2019
@dplewis dplewis added type:bug Impaired feature or lacking behavior that is likely assumed help wanted labels Jul 11, 2019
@dplewis
Copy link
Member

dplewis commented Aug 15, 2019

Closing via #1223

@dannywolfmx Thanks for getting started on this!

@dplewis dplewis closed this Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants