-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Support for pinned requests #1471
Conversation
I did a once over of the code and it looks great. Nice work! One high-level thing though is that I think people will want to be able to pin any request, not just the top-level ones. I'm not sure pinning folders is useful, although maybe you can point out some use-cases that I haven't considered. Overall great work on this. I'm super excited to get this one merged 💯 |
packages/insomnia-app/app/ui/components/sidebar/sidebar-children.js
Outdated
Show resolved
Hide resolved
Thank you - I appreciate it! 😄
I see pinned items as those being truly global, which would really only be authentication requests. If all requests are pinned, then none of them are pinned so I agree with your sentiment. 😄 Only example I can think of is with larger solutions with multiple APIs and 3rd party integrations where there may be logical groupings for pinned items. Your call - given it is probably a niche use-case I could remove the ability to pin folders and add if a request comes up.
|
Yep that sounds good. Pinned requests for now and folders if people want those later. Just a little background. The original use case for pins that I remember is basically treating them as tabs (like in a text editor). So you might pin just the few requests you're working with at the moment. Sent with GitHawk |
Makes sense. Done deal, PR has been updated! |
@develohpanda Hi, just a suggestion. Would it be better if the pin icon is at the left side? Putting it at the right side will take up the dropdown's arrow, and will be moved aside when the request row is hovered over, which IMHO is a bit awkward 😄. |
Thanks for the suggestion @rickychandra! I have a few reasons why I decided against an icon on the left which I'll outline below, but my ears are open to anything I may have missed. 😄 (apologies in advance for the long message!)
The pin is only supplementary info necessary for certain rows, and is kept out of the way. The drop-down arrow is similar, in that it is supplementary info only for hovered rows, and is kept out of the way (or hidden) when not needed. |
Ah I see. I thought the pin is also clickable, so it would be easier to click if it doesn't move on hovered. I agree with point 1 and 2, putting the pin on the left can make it hard to skim the items, especially when the pinned status is no longer that important (all pinned items are at the top and are separated with a line with the rest of the items). Good job anyway! 😄 |
Thank you! Appreciate the suggestion 🥂 |
After testing out your branch locally, I have a few usability questions/suggestions:
And a bug: When pinning a request that's in a folder, then unpinning, the request is no longer inside the folder. Let me know if your thoughts on these or if you have any questions 😸 |
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.
Really nice work on this. Just a few fairly minor comments 👍
packages/insomnia-app/app/ui/components/dropdowns/request-actions-dropdown.js
Outdated
Show resolved
Hide resolved
packages/insomnia-app/app/ui/components/dropdowns/request-actions-dropdown.js
Outdated
Show resolved
Hide resolved
Do you mean for the pinned request to show in two places - nested section and its original position? 👍 I think I won't be able to get to these until the weekend. Thank you for the feedback! |
@develohpanda yes, show in both places 😄 Don't worry, take your time! |
@gschier two questions:
|
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.
@gschier I have updated the PR with your feedback and added a few comments. Let me know what you think!
pinned: Array<Child>, | ||
all: Array<Child>, | ||
}; | ||
|
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 there a more appropriate place to put this type definition?
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.
I'm okay with it here. It makes sense to have it defined where it's used.
this.props.activeRequest, | ||
!(metas[0] && metas[0].pinned), | ||
); | ||
}, |
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.
Not a big fan of this solution, but the other solution would be to put the pinned
on Request
rather than RequestMeta
, but more changes will need to go into app.js
to support it. 🤔
Are there any other options that I am missing?
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 thinking, whatever solution is decided here could also be used to show a pin icon/reordering for pinned requests in the quick switcher.
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.
We'll need to keep pinned
on RequestMeta
. The "meta" models are meant to store information that isn't related to actually sending the request and also that should not be synced or shared.
Note. One thing that would help here is using the getOrCreateByParentId
method on request-meta.js
.
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.
Also, you'll need to add a check to make sure activeRequest
is not null
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.
Note. One thing that would help here is using the
getOrCreateByParentId
method onrequest-meta.js
.
_handleSetRequestPinned
internally calls App._updateRequestMetaByParentId
, which is the same one used by the other handlers and supports getOrCreate
. If it is a new request (with no meta) then this handler also creates meta.
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.
Ya I saw that. I thought your first comment was about the complexity of finding the request meta in the entities list.
I was suggesting using getOrCreate instead of having to write the manual filter on the entities list
}; | ||
|
||
if (child.pinned) { | ||
pinnedChildren.push(child); |
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.
I did this for efficiency. Extracting all pinned requests (ie. nested requests) in sidebar-children
would require an extra unnecessary traversal of childrenTree
.
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.
I think it actually fits well here within the context of "sidebar children" since the only place it's used is in the sidebar. If/when pinned requests are needed elsewhere, this would make less sense. For now, it's good though.
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 a few comments
pinned: Array<Child>, | ||
all: Array<Child>, | ||
}; | ||
|
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.
I'm okay with it here. It makes sense to have it defined where it's used.
this.props.activeRequest, | ||
!(metas[0] && metas[0].pinned), | ||
); | ||
}, |
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.
We'll need to keep pinned
on RequestMeta
. The "meta" models are meant to store information that isn't related to actually sending the request and also that should not be synced or shared.
Note. One thing that would help here is using the getOrCreateByParentId
method on request-meta.js
.
this.props.activeRequest, | ||
!(metas[0] && metas[0].pinned), | ||
); | ||
}, |
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.
Also, you'll need to add a check to make sure activeRequest
is not null
}; | ||
|
||
if (child.pinned) { | ||
pinnedChildren.push(child); |
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.
I think it actually fits well here within the context of "sidebar children" since the only place it's used is in the sidebar. If/when pinned requests are needed elsewhere, this would make less sense. For now, it's good though.
I'll leave this one up to you. I think both ways make sense. We'll leave it to future feedback to tell us if we made the wrong choice
I think in both places makes sense 👍 |
@@ -288,6 +290,11 @@ const defaultRegistry: HotKeyRegistry = { | |||
keyComb(true, false, false, false, keyboardKeys.d.keyCode), | |||
), | |||
|
|||
[hotKeyRefs.REQUEST_TOGGLE_PIN.id]: keyBinds( | |||
keyComb(false, false, false, true, keyboardKeys.p.keyCode), |
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.
Mac key comb should probably be false, false, true, true
to map to Cmd+Shift+P because Cmd+P already maps to the request switcher. Windows/Linux one is fine though with what you have (Ctrl+Shift+P)
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 one small thing!
if (!this.props.activeRequest) { | ||
return; | ||
} | ||
|
||
const metas = Object.values(this.props.entities.requestMetas).filter( |
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.
Should be using .find()
instead of .filter()
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.
TIL. Will update this evening!
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.
Looks good now! Thanks so much for your hard work on this one 😄 💯
Closes #1344. Closes #1109.
Features
request
andrequest-group
request-group
is possiblefit-content(20%)
fa-thumb-tack
shown on pinned itemspinned
state is stored inrequest-meta
andrequest-group-meta
Screenshots
No pinned items (current behavior):
Pinned folder + request, with unpinned items:
Six pinned items:
Seven pinned items:
Open tag on collapsed, pinned folder to allow dnd of nested items:
Action dropdowns:
No pin action on nested items: