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

Introducing a controller that returns automate entry point tree JSON #1949

Merged
merged 1 commit into from
Sep 1, 2017

Conversation

skateman
Copy link
Member

@skateman skateman commented Aug 17, 2017

🔥 🔥 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) with isLazy set to true. If you send a POST request with a lazy node's key as an id 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.

@miq-bot miq-bot added the wip label Aug 17, 2017
json = JSON.parse(tree.instance_variable_get(:@bs_tree))
end

render :json => json
Copy link
Member

@martinpovolny martinpovolny Aug 17, 2017

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

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@skateman
Copy link
Member Author

I was re-reading the REST specification and now it sounds me more REST-y to use just GET with or without the id instead of POST. So dropping the POST route...

@skateman skateman changed the title [WIP] Introducing a controller that returns automate entry point tree JSON Introducing a controller that returns automate entry point tree JSON Aug 17, 2017
@skateman skateman changed the title Introducing a controller that returns automate entry point tree JSON [WIP] Introducing a controller that returns automate entry point tree JSON Aug 17, 2017
@miq-bot miq-bot changed the title [WIP] Introducing a controller that returns automate entry point tree JSON Introducing a controller that returns automate entry point tree JSON Aug 17, 2017
@miq-bot miq-bot removed the wip label Aug 17, 2017
@skateman
Copy link
Member Author

There are still some issues with the override that @Hyperkid123 just found...

@skateman
Copy link
Member Author

Ready to merge!

@martinpovolny
Copy link
Member

Rubocop is right!

@miq-bot
Copy link
Member

miq-bot commented Aug 29, 2017

Checked commit skateman@34ced25 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
3 files checked, 0 offenses detected
Everything looks fine. 🍪

@martinpovolny martinpovolny merged commit 7a7f061 into ManageIQ:master Sep 1, 2017
@martinpovolny martinpovolny self-assigned this Sep 1, 2017
@chessbyte chessbyte added this to the Sprint 68 Ending Sep 4, 2017 milestone Sep 1, 2017
@skateman skateman deleted the automate-tree-api-ui branch September 7, 2018 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants