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

Add query folder export #1958

Merged
merged 2 commits into from
Nov 16, 2021
Merged

Add query folder export #1958

merged 2 commits into from
Nov 16, 2021

Conversation

mason-fish
Copy link
Contributor

Adds an export context menu item to export a single selected folder of queries as json. Later, we can extend this so users can pick and choose individual queries and folders to be exported as a single lib.

Menu option
image

Save dialog with defaults
image

If multi-selected not allowed (yet)
image

No option for single query (yet)
image

Signed-off-by: Mason Fish mason@brimsecurity.com

Signed-off-by: Mason Fish <mason@brimsecurity.com>
@mason-fish mason-fish requested a review from a team November 13, 2021 18:58
@mccanne
Copy link
Contributor

mccanne commented Nov 13, 2021

Awesome! I'm not qualified to review this, but love this new feature!

Copy link
Member

@jameskerr jameskerr left a comment

Choose a reason for hiding this comment

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

Awesome feature.

@@ -96,4 +97,8 @@ export default class BrimApi {
this.dispatch(Queries.addItem(node, "root"))
this.toast.success(`Imported ${node.name}`)
}

exportQueries(group: Group) {
Copy link
Member

Choose a reason for hiding this comment

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

I think if this is a public api, I think the argument should just be the query id or name of the folder.

@@ -0,0 +1,19 @@
import fs from "fs"
Copy link
Member

Choose a reason for hiding this comment

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

I want to steer away from creating any new files in src/js. I think the body of this function should just be in the brim api file for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, placing a thunk directly in the api definition seems out of place to me since thunks are so coupled with redux. It seems like placing it here right next to our other thunks would at least make it easier to remember and refactor later on, no?

const jsonGroup = cloneDeep(group)
flattenItemTree(jsonGroup).forEach((item) => {
delete item.id
delete item.isOpen
Copy link
Member

Choose a reason for hiding this comment

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

I've been wondering if the isOpen state should just be managed in the ReactArborist component.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, and drop the isOpen state persistence? Or handle that another way?

Signed-off-by: Mason Fish <mason@brimsecurity.com>
@mason-fish mason-fish merged commit 8782586 into main Nov 16, 2021
@mason-fish mason-fish deleted the add-queries-export branch November 16, 2021 17:16
@mattnibs
Copy link
Contributor

Verified this works as of v0.28.0. Nicely done!

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.

4 participants