-
Notifications
You must be signed in to change notification settings - Fork 357
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
Introducing a controller that returns automate entry point tree JSON #1949
Conversation
app/controllers/tree_controller.rb
Outdated
json = JSON.parse(tree.instance_variable_get(:@bs_tree)) | ||
end | ||
|
||
render :json => json |
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.
you can set the response headers (content-type etc) and send the json as :text instead of reparsing
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.
fixed
820c816
to
f132a31
Compare
I was re-reading the REST specification and now it sounds me more REST-y to use just GET with or without the |
f132a31
to
5d6e24d
Compare
There are still some issues with the |
5d6e24d
to
3f60784
Compare
Ready to merge! |
Rubocop is right! |
3f60784
to
34ced25
Compare
Checked commit skateman@34ced25 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
🔥 🔥 Dialog editor calls for aid! And TreeBuilderAutomateEntrypoint will answer! 🎺 🎺
The dialog editor component needs a way to fetch the automate tree in JSON form. The data format is given and it won't change, but the way how I implemented this is not final and this piece of code should not be used as an example in any case.
If you send a GET request to
/tree/automate_entrypoint
, it sends back the collapsed root node(s) withisLazy
set totrue
. If you send a POST request with a lazy node's key as anid
attribute, it will return the node expanded with its children. The routes aren't final, I'd like to ask @martinpovolny's help for GET vs POST vs CSRF security.EDIT: Using GET for both lazy and root node requests, so no CSRF issues
We can't move this to the API as we're using TreeBuilders that are living in the UI repo. However, in the future I'd like to see these things fully API-driven.