Closed Bug 1284855 Opened 8 years ago Closed 8 years ago

Reps: match spacing and brace placement in nested objects/arrays

Categories

(DevTools :: Shared Components, enhancement, P1)

enhancement

Tracking

(firefox50 affected)

RESOLVED FIXED
Iteration:
51.3 - Sep 19
Tracking Status
firefox50 --- affected

People

(Reporter: linclark, Assigned: steveck)

References

Details

(Whiteboard: [reserve-html])

Attachments

(2 files)

For example, the console currently outputs this:

> Object { foo: Object }

Reps would output this:

> Object{foo: Object{}}
Blocks: 1283847
Whiteboard: [devtools-html] [triage]
Flags: qe-verify-
Priority: -- → P2
Whiteboard: [devtools-html] [triage] → [devtools-html]
Sorry I didn't get this part:
(In reply to Lin Clark [:linclark] from comment #0)
> For example, the console currently outputs this:
> 
> > Object { foo: Object }
> 
> Reps would output this:
> 
> > Object{foo: Object{}}

So it means that all the nested object reps should be displayed like Object{foo: Object{}} instead of Object { foo: Object }, and the test[1] should be revised to:

> const defaultOutput = `Object{objProp: Object{}, strProp: "test string"}`;
 
And we should start from object.js. Hope that I didn't misunderstand the requirement.

[1] https://dxr.mozilla.org/mozilla-central/source/devtools/client/shared/components/test/mochitest/test_reps_grip.html#150
Flags: needinfo?(lclark)
Sorry, my wording was not clear.

We want the reps to output as the current console does. If you did a console.log({foo: "bar"}) in the current console, it would show up as:

> Object { foo: "bar" }

That's what we want.

There is a separate issue for making sure that the space between "Object" and "{" is there. This issue is just about the spacing inside the nested object/array/etc.
Flags: needinfo?(lclark)
Ok, does it only happen in object/array reps, not in grip reps with object/array type? I'm still confused about where to find the nested object/array case in the panel, because it seems that the general case of nested object display would be "Object { foo: Object }".
Flags: needinfo?(lclark)
It also happens in grips and grip-arrays.

Sorry, my wording was confusing. I meant the properties nested inside the object. So the spacing around the properties.
Flags: needinfo?(lclark)
Thanks for the explanation, it looks like the current display between brace/bracket and properties uses css margin for the spacing. Could I assume that we should replace all the margin styling for objectBrace/objectBracket with real space in js?
Flags: needinfo?(lclark)
We should get Honza's opinion on this, but I would say that yes, we should replace margin styling for real spaces.
Flags: needinfo?(lclark) → needinfo?(odvarko)
(In reply to Lin Clark [:linclark] from comment #6)
> We should get Honza's opinion on this, but I would say that yes, we should
> replace margin styling for real spaces.
Agree, using real spaces is better when coping rendered text into the clipboard.

Honza
Flags: needinfo?(odvarko)
Thanks, hope it's the last question about the spacing: For the grip in tiny mode, it would also have a object with class "objectLeftBrace" and empty text content at the end[1]. I'm not sure if this object is necessary for objectBox. Should we simply remove it, or rename the class instead?

[1] https://dxr.mozilla.org/mozilla-central/source/devtools/client/shared/components/reps/grip.js#162-168
Flags: needinfo?(odvarko)
(In reply to Steve Chung [:steveck] from comment #8)
> Thanks, hope it's the last question about the spacing: For the grip in tiny
> mode, it would also have a object with class "objectLeftBrace" and empty
> text content at the end[1]. I'm not sure if this object is necessary for
> objectBox. Should we simply remove it, or rename the class instead?

Are talking about a space between `Object` and `,` ?

E.g. Object { foo: Object , bar: Object }

As far as I can tell this space is again CSS margin and as soon as we remove it from reps.css it'll disappear. Does this answer the question?

Honza
Flags: needinfo?(odvarko)
Priority: P2 → P3
Whiteboard: [devtools-html] → [reserve-html]
Hi Honza,

It's patch for the replacing the styling with real space. Not sure if it totally fit the requirement. I'll also reply the question in the review.
Attachment #8772350 - Flags: feedback?(odvarko)
Assignee: nobody → schung
Status: NEW → ASSIGNED
Comment on attachment 8772350 [details] [diff] [review]
bug-1284855.patch

Review of attachment 8772350 [details] [diff] [review]:
-----------------------------------------------------------------

::: devtools/client/shared/components/test/mochitest/test_reps_array.html
@@ +47,5 @@
>      const renderedRep = shallowRenderComponent(Rep, { object: stub });
>      is(renderedRep.type, ArrayRep.rep, `Rep correctly selects ${ArrayRep.rep.displayName}`);
>  
>      // Test rendering
> +    const defaultOutput = `[  ]`;

It will cause the empty array displayed with 2 spaces inside the brackets, maybe we should remove all the spaces(or only left one space)?
Comment on attachment 8772350 [details] [diff] [review]
bug-1284855.patch

Review of attachment 8772350 [details] [diff] [review]:
-----------------------------------------------------------------

(In reply to Steve Chung [:steveck] from comment #11)
> Comment on attachment 8772350 [details] [diff] [review]
> bug-1284855.patch
> 
> Review of attachment 8772350 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: devtools/client/shared/components/test/mochitest/test_reps_array.html
> @@ +47,5 @@
> >      const renderedRep = shallowRenderComponent(Rep, { object: stub });
> >      is(renderedRep.type, ArrayRep.rep, `Rep correctly selects ${ArrayRep.rep.displayName}`);
> >  
> >      // Test rendering
> > +    const defaultOutput = `[  ]`;
> 
> It will cause the empty array displayed with 2 spaces inside the brackets,
> maybe we should remove all the spaces(or only left one space)?

Yes, this is the part I don't like in the patch.

Can we do it as follows?

1) No space if the array is empty, example:  `[]`
2) No space if the array is displayed in tiny mode with number of items inside, example:  `[8]`
3) Spaces in short and long modes: [ 1, 2, 3 ]
4) the same for objects: `{}`, `{ p1: "value", p2: value }`

Honza
Attachment #8772350 - Flags: feedback?(odvarko)
Comment on attachment 8773626 [details]
Bug 1284855 - Reps: match spacing and brace placement in nested objects/arrays.

https://reviewboard.mozilla.org/r/66008/#review63128

R+, but please resolve the one small thing I commented.

Honza

::: devtools/client/shared/components/reps/object.js:162
(Diff revision 1)
>            this.getTitle(object),
>            objectLink({
>              className: "objectLeftBrace",
>              role: "presentation",
>              object: object
> -          }, "{"),
> +          }, "{ "),

Why there is no space before `{`?
It should be consistent with Grip rep.

Honza
Attachment #8773626 - Flags: review?(odvarko) → review+
This will also need try push

Honza
Comment on attachment 8773626 [details]
Bug 1284855 - Reps: match spacing and brace placement in nested objects/arrays.

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/66008/diff/1-2/
Thanks for the review! I applied the suggestion and try build has 2 unrelated  failed.
Keywords: checkin-needed
Needs rebasing.
Keywords: checkin-needed
Comment on attachment 8773626 [details]
Bug 1284855 - Reps: match spacing and brace placement in nested objects/arrays.

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/66008/diff/2-3/
Patch rebased and try build passed.
Keywords: checkin-needed
has problems to apply:

1 out of 1 hunks FAILED -- saving rejects to file devtools/client/shared/components/reps/grip-array.js.rej
patching file devtools/client/shared/components/test/mochitest/test_reps_grip-array.html
Hunk #1 FAILED at 70
Hunk #2 FAILED at 98
Hunk #3 FAILED at 158
3 out of 3 hunks FAILED -- saving rejects to file devtools/client/shared/components/test/mochitest/test_reps_grip-array.html.rej
patch failed to apply
abort: fix up the working directory and run hg transplant --continue
Flags: needinfo?(schung)
Comment on attachment 8773626 [details]
Bug 1284855 - Reps: match spacing and brace placement in nested objects/arrays.

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/66008/diff/3-4/
Rebased to central again.
Flags: needinfo?(schung)
Request checkin-needed again. It is not possible to bust OSX build with this patch... :/
Keywords: checkin-needed
Needs rebasing :(

applying db587c44ba37
patching file devtools/client/shared/components/test/mochitest/test_reps_array.html
Hunk #2 FAILED at 101
Hunk #4 FAILED at 188
Hunk #5 FAILED at 218
3 out of 5 hunks FAILED -- saving rejects to file devtools/client/shared/components/test/mochitest/test_reps_array.html.rej
patching file devtools/client/shared/components/test/mochitest/test_reps_grip-array.html
Hunk #2 FAILED at 100
1 out of 4 hunks FAILED -- saving rejects to file devtools/client/shared/components/test/mochitest/test_reps_grip-array.html.rej
patching file devtools/client/shared/components/test/mochitest/test_reps_grip.html
Hunk #2 FAILED at 97
Hunk #3 FAILED at 134
2 out of 4 hunks FAILED -- saving rejects to file devtools/client/shared/components/test/mochitest/test_reps_grip.html.rej
patching file devtools/client/shared/components/test/mochitest/test_reps_object.html
Hunk #2 FAILED at 95
Hunk #3 FAILED at 121
2 out of 4 hunks FAILED -- saving rejects to file devtools/client/shared/components/test/mochitest/test_reps_object.html.rej
patch failed to apply
Keywords: checkin-needed
Comment on attachment 8773626 [details]
Bug 1284855 - Reps: match spacing and brace placement in nested objects/arrays.

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/66008/diff/4-5/
Keywords: checkin-needed
Still doesn't apply.

patching file devtools/client/shared/components/reps/array.js
Hunk #1 FAILED at 117
1 out of 1 hunks FAILED -- saving rejects to file devtools/client/shared/components/reps/array.js.rej
patching file devtools/client/shared/components/reps/grip-array.js
Hunk #1 FAILED at 100
1 out of 1 hunks FAILED -- saving rejects to file devtools/client/shared/components/reps/grip-array.js.rej
patching file devtools/client/shared/components/reps/grip.js
Hunk #1 FAILED at 183
1 out of 1 hunks FAILED -- saving rejects to file devtools/client/shared/components/reps/grip.js.rej
patching file devtools/client/shared/components/reps/object.js
Hunk #1 FAILED at 145
1 out of 1 hunks FAILED -- saving rejects to file devtools/client/shared/components/reps/object.js.rej
patch failed to apply
Keywords: checkin-needed
Pushed by bbouvier@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/3e7e914abf3d
Baseline fixes for handling custom NaN payloads; r=lth
(In reply to Pulsebot from comment #28)
> Pushed by bbouvier@mozilla.com:
> https://hg.mozilla.org/integration/mozilla-inbound/rev/3e7e914abf3d
> Baseline fixes for handling custom NaN payloads; r=lth

Oops sorry, landed with the wrong bug number; backed out:

o  changeset:   307856:2dda5f625bc0
|  summary:     Backed out changeset 3e7e914abf3d for landing with the wrong bug number;
Keywords: leave-open
Rebase the patch again and triggered a try build...(keep my fingers crossed that no more conflicts)
Keywords: checkin-needed
Pushed by kwierso@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/a63498564d7d
Reps: match spacing and brace placement in nested objects/arrays. r=Honza
Keywords: checkin-needed
Could we close this bug since it's already in central(and the reason why it left as open seems not the patch's problem)?
Flags: needinfo?(bbouvier)
(In reply to Steve Chung [:steveck] from comment #34)
> Could we close this bug since it's already in central(and the reason why it
> left as open seems not the patch's problem)?

Yes, sorry for the trouble.
Flags: needinfo?(bbouvier)
Keywords: leave-open
Hi Wes, could we close this bug, since this patch is already merged in central?
Flags: needinfo?(wkocher)
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Flags: needinfo?(wkocher)
Resolution: --- → FIXED
Iteration: --- → 51.3 - Sep 12
Priority: P3 → P1
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: