-
Notifications
You must be signed in to change notification settings - Fork 132
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
Add query folder export #1958
Conversation
Signed-off-by: Mason Fish <mason@brimsecurity.com>
Awesome! I'm not qualified to review this, but love this new feature! |
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.
Awesome feature.
src/js/api/index.ts
Outdated
@@ -96,4 +97,8 @@ export default class BrimApi { | |||
this.dispatch(Queries.addItem(node, "root")) | |||
this.toast.success(`Imported ${node.name}`) | |||
} | |||
|
|||
exportQueries(group: Group) { |
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 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" |
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 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.
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.
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 |
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've been wondering if the isOpen state should just be managed in the ReactArborist component.
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.
Hmm, and drop the isOpen state persistence? Or handle that another way?
Signed-off-by: Mason Fish <mason@brimsecurity.com>
Verified this works as of v0.28.0. Nicely done! |
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
Save dialog with defaults
If multi-selected not allowed (yet)
No option for single query (yet)
Signed-off-by: Mason Fish mason@brimsecurity.com