Skip to content
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

feat: multiple tabs - [INS-4225] #8151

Open
wants to merge 38 commits into
base: develop
Choose a base branch
from
Open

Conversation

CurryYangxx
Copy link
Member

@CurryYangxx CurryYangxx commented Nov 6, 2024

Changes

  • create a TabList and Tab Component, and import it in every type of file page.
  • store tab data in localstorage, use InsomniaTabContext to manage state of the tabs
  • create a useInsomniaTab hook
    • get tab type according to the location pathname
    • check if tab exist
    • pack tab data
    • add new tab
  • sync tab data with db
  • click "+" to add tab
  • right click context menu: Close all & Close others
    • rename the origin IPC show-context-menu to show-nunjucks-context-menu
    • add a new IPC show-context-menu as the common context menu method
  • support drag and drop to re-arrange tabs
  • collection runner improvements: runner improvements (multiple tabs)-[INS-4779] #8244
  • keep long connection for openning tabs: feat(tabs): keep connection for tabs-[INS-4778] #8266
image

related to #6108

@CurryYangxx CurryYangxx marked this pull request as draft November 6, 2024 03:42
@CurryYangxx CurryYangxx changed the title WIP: multiple tabs WIP: multiple tabs - [INS-4225] Nov 6, 2024
@CurryYangxx CurryYangxx force-pushed the feat/multiple-tab branch 4 times, most recently from a8d050d to 68c7cdf Compare November 18, 2024 07:10
@CurryYangxx CurryYangxx marked this pull request as ready for review November 18, 2024 10:35
Copy link
Member

@filfreire filfreire left a comment

Choose a reason for hiding this comment

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

LGTM

Found issue where tabs disappear when pressing OPTION + TAB in the UI after a few times

some suggestions for this PR or other follow-up PRs:

  • allow for pressing CTRL + TAB / CTRL + SHIFT + TAB to alternate between tabs
  • perhaps also allow the same for pressing CTRL + 1 (1 to 9) to go to 1st -> 9th tab, 0 being last tab?
  • allow middle-mouse click to close a tab
  • capture COMMAND+W (and windows/linux equivalent) to close tabs

@filfreire filfreire requested a review from a team November 18, 2024 15:03
@CurryYangxx CurryYangxx changed the title WIP: multiple tabs - [INS-4225] feat: multiple tabs - [INS-4225] Nov 20, 2024
@CurryYangxx CurryYangxx force-pushed the feat/multiple-tab branch 3 times, most recently from 6eab9eb to f802655 Compare November 25, 2024 03:38
gatzjames
gatzjames previously approved these changes Nov 25, 2024
filfreire
filfreire previously approved these changes Nov 25, 2024
@kaynansc
Copy link

it would be nice capture COMMAND+W (and windows/linux equivalent) to close tabs

@CurryYangxx
Copy link
Member Author

Update: (5e90726)
Because we can move a request or a folder to another collection. So, we need to update tab data after the move action.

  • add patches field to database changeBuffer, so that we can know if user change the parentId
  • request move
    • update tab by id (workspaceId, workspaceName, url)
    • revalidate workspace activeRequest
  • folder move
    • batch update (workspaceId, workspaceName, url)
    • revalidate workspace activeRequest (if the activeRequest is in the folder, we need to clear it)
image

@filfreire
Copy link
Member

@CurryYangxx, I took a pass at the branch again and tried after your commit and seems copying and moving seems to be working.

I noticed one other thing - for example if you have 2 tabs open for 2 requests, and maybe you are working on pre-request/after-response scripts, or docs, or headers.... etc. in both, the moment you switch tabs, you are not redirected to the "sub-tab" you were at when browsing the request.

So each time we switch between tabs we don't remember where inside the tab specifically the user was.

@CurryYangxx CurryYangxx force-pushed the feat/multiple-tab branch 2 times, most recently from f431f46 to b93f004 Compare December 3, 2024 06:52
@jackkav
Copy link
Contributor

jackkav commented Jan 8, 2025

improvement ideas for now or later:

analyse state choices against the choices in the rest app
localstorage, refs.
main map+useeffect?

db.onchange to trigger rerender
consider using the router loader instead of a surgical listener to get rerenders after state changes?

look for a way to remove the ref

look for a way to remove the event bus, figure out how to persist runner info on disk or local storage?

look for a way to remove the context provider, flatten useInsomniaTabContext into tablist and pass down function needed for tabs in react props

duplicate useInsomniaTabContext

enum to union

solve sync problems in runner upfront before this pr so this pr doesn't have to treat it as a special thing that needs lots of custom code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants