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

More flexibility with FAB menu links #13903

Merged
merged 1 commit into from
Feb 17, 2021
Merged

More flexibility with FAB menu links #13903

merged 1 commit into from
Feb 17, 2021

Conversation

jedcunningham
Copy link
Member

@jedcunningham jedcunningham commented Jan 26, 2021

Airflow can be more flexible with the links plugins are allowed to add. Currently, you cannot add a top level link, a link with a label, or even without providing a category_icon (which isn't used anyways).

This PR gives plugin authors the flexibility to add any link FAB supports.

@jedcunningham jedcunningham marked this pull request as draft January 26, 2021 06:20
@jedcunningham jedcunningham marked this pull request as ready for review January 27, 2021 03:24
@jhtimmins
Copy link
Contributor

Hi @jedcunningham! Thanks for adding this with solid looking tests. Just to make this easier to review, would it be possible to add an image of a top-level link and one with a label?

Out of curiosity, is there a specific use case you have that caused you to suggest these changes?

@ryanahamilton

@jedcunningham
Copy link
Member Author

@jhtimmins I recently added an extra link to Docs and found it odd that I needed to provide a category_icon, so I went and looked at FAB add_link upstream and saw that it's unused for existing categories anyways. I also noticed one couldn't create a top-level link if they wanted one, so I figured it was worth a PR.

appbuilder_menu_items = [
    {"name": "Hello", "category": "Docs", "href": "https://google.com",},
    {
        "name": "labelled",
        "label": "Hello (label)",
        "category": "Docs",
        "href": "https://google.com",
    },
    {"name": "Top Hello", "href": "https://google.com",},
]

Leads to:
links

@jhtimmins
Copy link
Contributor

Thanks for explaining @jedcunningham. I think this makes a lot of sense and is a good update.

@kaxil this code is good to go.

@@ -488,7 +488,7 @@ def prepare_dagruns(self):
)

def test_index(self):
with assert_queries_count(42):
with assert_queries_count(43):
Copy link
Member

Choose a reason for hiding this comment

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

Any idea what caused an extra query?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's the new menu link I added (based on me adding a second new link and it going up to 44). I don't know why FAB is doing a query per menu link, but that seems to be the behavior 🤷‍♂️.

Copy link
Member

@kaxil kaxil left a comment

Choose a reason for hiding this comment

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

Just 1 question around an extra query but LGTM otherwise

@github-actions
Copy link

The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest master at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Feb 17, 2021
@kaxil kaxil merged commit ef0c17b into apache:master Feb 17, 2021
@kaxil kaxil added this to the Airflow 2.0.2 milestone Feb 17, 2021
ashb pushed a commit that referenced this pull request Mar 19, 2021
Airflow can be more flexible with the links plugins are allowed to add. Currently, you cannot add a top level link, a link with a label, or even without providing a category_icon (which isn't used anyways).

This PR gives plugin authors the flexibility to add any link FAB supports.

(cherry picked from commit ef0c17b)
@jedcunningham jedcunningham deleted the menu_links branch March 27, 2021 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:plugins area:webserver Webserver related Issues full tests needed We need to run full set of tests for this PR to merge kind:documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants