Skip to content

Conversation

@nytai
Copy link
Contributor

@nytai nytai commented Sep 12, 2019

exposes a method on the menu class to output the menu as list of dictionaries that can be converted to json.

@codecov
Copy link

codecov bot commented Sep 12, 2019

Codecov Report

Merging #1116 into master will increase coverage by 0.12%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1116      +/-   ##
==========================================
+ Coverage   68.71%   68.83%   +0.12%     
==========================================
  Files          45       45              
  Lines        6223     6248      +25     
==========================================
+ Hits         4276     4301      +25     
  Misses       1947     1947
Impacted Files Coverage Δ
flask_appbuilder/menu.py 92.63% <100%> (+2.63%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update be6d98a...606c2c9. Read the comment docs.

@nytai nytai force-pushed the tai/expose-menu branch 2 times, most recently from 8566d2e to a97e6ca Compare September 19, 2019 01:57
sess = PSSession()

class PSView(ModelView):
datamodel = GenericInterface(PSModel, sess)
Copy link
Owner

Choose a reason for hiding this comment

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

This can be removed

rv = client.get(uri)
eq_(rv.status_code, 200)
data = rv.data.decode('utf-8')
eq_(data, '{"data":[]}\n')
Copy link
Owner

Choose a reason for hiding this comment

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

let's use assertEqual I'm changing everything on another PR

@nytai nytai marked this pull request as ready for review September 19, 2019 23:35
class MenuApi(BaseApi):
resource_name = "menu"

@expose('/data', methods=["GET"])
Copy link
Owner

Choose a reason for hiding this comment

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

I personally prefer just GET /api/v1/menu

- label
- icon
"""
return self.response(200, data=current_app.appbuilder.menu.get_data())
Copy link
Owner

Choose a reason for hiding this comment

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

Currently FAB uses result key instead of data

$ref: \
'#/paths/menu/data/get/reponses/200/content/application/json/schema/properties/result'
required:
- name
Copy link
Owner

Choose a reason for hiding this comment

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

name and url are required. label, icon are optional

class MenuApi(BaseApi):
resource_name = "menu"

@expose('/', methods=["GET"])
Copy link
Owner

Choose a reason for hiding this comment

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

public endpoint, is this intentional? it really does not return any data when no user is authenticated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct, it returns an empty array, currently. However if a user decides to expose a menu for the public role we'd still want to serve that [limited] menu, right?

Copy link
Owner

Choose a reason for hiding this comment

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

Right, yet we do have a public role for this. It's actually a decision between exposing an unauthenticated EP that anonymously return an empty list, or exposing an authenticated EP that returns 401


class MenuApiManager(BaseManager):
def register_views(self):
self.appbuilder.add_api(MenuApi)
Copy link
Owner

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean expose a config to enable/disable this endpoint? something like FAB_EXPOSE_MENU_API?

Copy link
Owner

Choose a reason for hiding this comment

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

yep

@dpgaspar dpgaspar self-requested a review September 24, 2019 10:37
Copy link
Owner

@dpgaspar dpgaspar left a comment

Choose a reason for hiding this comment

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

LGTM, sorry Tai just merged a big change on tests that created some conflicts here, I've created a branch named preset-io-tai/expose-menu on FAB that resolves them, take a look a that

@dpgaspar dpgaspar self-requested a review September 24, 2019 10:38
@dpgaspar dpgaspar merged commit 0b3e6bc into dpgaspar:master Sep 25, 2019
@nytai nytai deleted the tai/expose-menu branch September 25, 2019 16:13
@dpgaspar dpgaspar mentioned this pull request Sep 27, 2019
@dpgaspar dpgaspar mentioned this pull request Oct 16, 2019
@nytai nytai mentioned this pull request Nov 6, 2019
12 tasks
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.

2 participants