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

Export folders and requests #1396

Merged
merged 5 commits into from Apr 18, 2019

Conversation

Projects
None yet
2 participants
@rickychandra
Copy link
Contributor

commented Mar 5, 2019

Closes: #1273
I implemented the feature to export only certain folders and/or requests in a single workspace.
There is an alternative to this solution which is adding checkboxes in the sidebar, but IMO this makes the exporting not focusable (it's sidebar), and it's more complex in that other components in the sidebar may be disabled, etc.

UI
I added a new option "Current Workspace's Requests" under "Export Data" dropdown button.
screenshot from 2019-03-05 18-30-11

If the option is chosen, then it will open a new dialog displaying the requests tree of the current workspace.
screenshot from 2019-03-05 18-30-36

The initial state is that all folders are expanded and none of the checkboxes is selected. If no folders or requests are selected, then the "Export" button will be disabled.

When the "Export" button is pressed, the flow will be the same as the existing "Export Workspace".

Since the focus here are requests, empty folders (without requests) will not appear in the tree.

There is also a top folder "All requests" which is a dummy folder to make exporting all top requests and folders easier with a single click, but will not be exported itself.

What are exported
The selected requests and their parent folders, the containing workspace, all environments (private ones are asked first), and cookie jar. This behavior is pretty much the same as the existing "Export Workspace".

Implementation
The tree structure and styling (HTML and CSS) are copied from those of sidebar's with many modifications. I am not sure whether it is better to abstract the tree structure as a separate reusable component or not, because there are many parts (DnD wrappers, dropdown buttons, checkbox, etc.) specific to each use cases.

The requests tree is constructed from the globally cached selectSidebarChildren and then stored as React state in the modal component.

Every time a folder is collapsed or checkbox selected, all of its children will be traversed which in worst case will result in O(N) time complexity. However, I think that this is still quite performant for most users.

@rickychandra rickychandra changed the title Export folders Export folders and requests Mar 5, 2019

@gschier

This comment has been minimized.

Copy link
Collaborator

commented Mar 7, 2019

Woah, awesome work! I haven't looked at your implementation yet but I hope to get to it this week or next

@gschier
Copy link
Collaborator

left a comment

Some general design comments. Overall, I think most of this PR is great, so nice work! I'm really excited for people to be able to use this.

Ricky Chandra
@rickychandra

This comment has been minimized.

Copy link
Contributor Author

commented Mar 12, 2019

Ok, updated the code.

@gschier gschier merged commit 683ac86 into getinsomnia:develop Apr 18, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@rickychandra rickychandra deleted the rickychandra:feature/export-folders branch Apr 19, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.