-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add resizing for Design Preview and Testing Results panes #2712
Conversation
There are three ways I'm thinking of for cleaning this up -
so that we get correct
For question / option #2 - here's what renderPageBody() {
...
return (
<div className="unit-tests layout-body--sidebar">
<section ref={handleSetRequestPaneRef} className="unit-tests__tests">...</section>
<div className="drag drag--pane-test">...</div>
<section className="unit-tests__results results-pane" ref={handleSetResponsePaneRef}>
{this.renderResults()}
</section>
</div>
);
} |
All in all, a nice approach you've followed 👏 Code looks good! Note: if none of the following options are viable in the short term, the current changes (and those anticipated for To answer your questions
I'm not too concerned about the warnings for library maintainers with this particular case as we are the only consumers of the components. How do you envision Alternatively the new class components can also be simple(r) function components. New components might be unnecessary altogether too, if you get refs on dom elements working.
I'm not sure why this wouldn't be working... could it be that you need to use If you can't get it working for this PR, it can be scoped to a standalone PR given it might need some additional work, but it would be good to remove
While this would be pretty awesome, my gut feel is that it might be a lot of work. CSS Grid is quite central to the layout and it's variations. Flexbox would definitely be a step forwards but might be too much to tackle in this PR? Some additional observations I was looking at how the drag pane was set up for the sidebar, because it seems to be working across all views (design, debug, test) in the current state. It looks like I wonder if it's worth investigating whether This doesn't really change the approach, just prevents the common dragging logic from being scattered and duplicated throughout. It might be slightly more work than just duplicating but feels a little more maintainable. What do you think? |
It's only a guess, but after thinking about it some more, maybe if the ref is a dom element since the element itself isn't changing on drag no update is triggered, whereas when the ref is on a class component (that then finds a dom element) when the pane gets resized something is updated and the changes propagate down to the component, which then updates? Looking it up, seems the best way to forward multiple refs is to make the ref an object with refs. That being said, if we had It'd make the most sense if the dragging logic were all in one place like |
My understanding of
This sounds good 👍 I can't think of any (great) reasons not to split
I agree, it seems non-trivial, but also non-critical so it can be tackled as a standalone PR. Another thing to be tackled separately is persisting the unique sidebar/pane widths per workspace and per tab. Previously we only had one tab (Debug) so it wasn't necessary. |
Ohhh I see - so if Right now I'm working on hiding return {renderPaneTwo && <div> ... renderPaneTwo()</div>} and in renderPreview = () => { return !previewHidden && <div /> } Since we're passing it a function, const preview = renderPreview()
<PageLayout renderPaneTwo={preview} /> This would prevent dynamically generating the content of If there are no issues, would it be a good idea to change just Second thought is, in const preview = renderPaneTwo()
return {preview && <div />} and I think then the content would still be dynamically generated upon component render. Would this be okay or is there a better way to go about hiding the second pane? Update: Even after implementing the last suggestion, I'm still running into an issue where PaneOne's grid space is calculated by the parent |
There are a few different options I can think of, and no one is better than the other at first sight. The options you've given are both good too. I'll pull this code later today and see what's up, AFK for the next few hours! 😊 |
I very much appreciate your responsiveness, but it says your status is "on vacation" so please enjoy it! This is certainly not something that can't wait a few days! |
I picked a good week to take off, middle of the busiest open-source month 😅 just making sure the wheels keep turning, but I'll dip away for the last few days; thanks for noting it! I noticed
Because the render functions don't actually have any arguments, I don't think there's a specific case for them to be functions over just FYI the insomnia/packages/insomnia-components/components/header.js Lines 5 to 10 in 4fc8b21
Lastly, as far as I know, this is alright. It's a fairly common pattern. React components are, after-all, standard JS objects, and they can be passed around as props just fine. One gotchaconst preview = renderPreview()
<PageLayout renderPaneTwo={preview} /> Assuming the above snippet runs in each render of It does but also doesn't matter (here) because there are other props using inline functions If you get rid of the render functions, does the drag resizing work as expected? |
Pushed a couple more changes and updated the PR body! Still have a couple todos, but please let me know if the logic looks okay, and if I'm missing something not in the todos! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consolidated CSS styling, mostly removing styles previously unused or now unused after these changes
One note about styles, in favor of keeping the scope of this PR small. If styles were previously unused, move to a separate PR. If styles are now unused after these changes, keep in this PR. 😄
Looks to be on the right path! I cloned locally and ran it again, and am quite impressed with what you have achieved. 👏
I'm not so familiar with the CSS classes and where they are used upfront, but as long as the end result is correct, I'm not too concerned about the changes made there.
Also, it is possible to create custom themes via Insomnia plugins. It would be worth comparing the live application with your PR, and researching any of the removed classes, to ensure theme support hasn't changed.
For example, the Core Default theme in Insomnia is fairly broken for Designer, but it would be good to understand why there are differences between this PR and 2020.4.1. It will be something to do with CSS classes and hierarchy.
Aww shucks, I even tried out a bunch of different themes but I guess not the first one! It was missing two properties - it should be good now! I'll keep the CSS changes as is in this PR and open another new PR with just the previously unused styles, if that one can be merged in first? And thanks for the compliment, it means a lot! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QA:
- horizontal resizing panes work on all tabs
- vertical resizing panes work on all tabs
- automatic/forced vertical layout works 🤯
- designer homepage correctly wraps and scrolls with multiple documents
- view -> toggle sidebar (to hide sidebar) works on all tabs
- after navigating around, I don't see any additional errors or warnings in the console window
- can send requests (E2E tests)
- double check the on-boarding flow (E2E tests do cover this)
Nicely done! I think there ended up being some overlap with #2713, because this PR handles vertical layout automatically, but this PR would be my preferred direction. I did find another bug (#2787) that might already be fixed by #2713, though.
LGTM, thank you for working through the various iterations, and putting your time into it! I'm looking forward to merge it in. 💯
Apologies for the merge conflicts! There was some refactoring in #2799, and looking at that PR might help. The changes in the conflicting files were mostly copy-paste so it should not be too tricky. 🤞 Let me know if you need any help resolving them. |
Merged and updated :) |
Merge looks good! Any future conflicts should only be prop changes to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's still some dead code in the render()
function of WrapperDesign, but as long as that gets removed this looks good to go: #2712 (comment)
Thanks for implementing this @simplywondrous!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just keeping an eye on merge conflict resolution and noticed some props need to be sent through 👀 should be a quick one
gRPC work is 90% complete so there will not be any more conflicts 🤞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this PR waiting for another review? Otherwise could someone merge it in? |
We've held off on merging OS PRs for the last week or so, pushing for a big release. Now that 2020.5 is on the horizon, we'll start merging OS PRs again. No more reviews needed, this PR is good to go. 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@
Context
This PR closes #2583
Changes
renderPaneOne
andrenderPaneTwo
inPageLayout
renderPageBody
is still available (such as forWrapperHome
)GIF