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

Add pages for multi-page app #1947

Merged
merged 66 commits into from
Jun 2, 2022
Merged

Add pages for multi-page app #1947

merged 66 commits into from
Jun 2, 2022

Conversation

AnnMarieW
Copy link
Collaborator

@AnnMarieW AnnMarieW commented Feb 24, 2022

This PR moves the pages plug-in from dash-labs to dash.
Until the tests are written, the app in the usage folder can be used to try the new features.

To Do

  • Find a better way to build dash.register_page. See dash-labs #76. Status: Deferred for now, see comments in dash-labs issue.
  • How to call pages function only when those features are being used.
  • Delete the usage folder
  • Add entry in the CHANGELOG.md

Test coverage

  • test navigation
    • by url
    • by dcc.Link
  • test for path variables.
  • test for query string
  • test for adding arbitrary page information to dash.page_registry
  • test for redirects
  • test for the title
  • test for the extra metadata different by page.
  • test for layout as function.
  • test invalid cases that should be handled.
    • no layout in page.
    • fail to validate the layout page container.
  • test load pages from directory.
  • test not found 404 page.
  • test for specifying page order

Find a live demo of the pages features at https://dashlabs.pythonanywhere.com/

@AnnMarieW
Copy link
Collaborator Author

AnnMarieW commented Feb 25, 2022

@alexcjohnson

changelog
How much information would you like in the CHANGELOG.md? Should it just be a pointer to the forum post?

pages function
What do you think about the following solution for handling when to call the pages function:
I added the following Dash args:

pages: Default False. Set to True to enable the multi-page apps features
pages_folder Default "pages". A path relative to the current working directory for files used with the multi-page app pages feature.

If a pages_folder name is supplied, then pages is set to True so it's not necessary to set both props.
In the unlikely event that people use the multi-page features without a pages/ folder then the warning is not shown if pages=True and pages_folder=None

See commit 4bdf472

dash/dash.py Outdated Show resolved Hide resolved
Copy link
Collaborator Author

@AnnMarieW AnnMarieW left a comment

Choose a reason for hiding this comment

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

This commit is a fix for the bug reported in dash-labs plotly/dash-labs#85

Copy link
Contributor

@T4rk1n T4rk1n left a comment

Choose a reason for hiding this comment

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

This is a very nice feature, I like it.

I think now that it's in dash directly instead of dash-labs, we can have better integration for the index rendering.

I am also wondering if there would be a way to do without a dcc.Location and container to serve the proper page layout directly in _dash-layout instead of an additional callback.

dash/__init__.py Outdated Show resolved Hide resolved
dash/_pages.py Show resolved Hide resolved
dash/dash.py Outdated Show resolved Hide resolved
dash/dash.py Outdated Show resolved Hide resolved
dash/dash.py Outdated Show resolved Hide resolved
dash/dash.py Outdated Show resolved Hide resolved
dash/dash.py Outdated Show resolved Hide resolved
dash/dash.py Show resolved Hide resolved
dash/dash.py Outdated Show resolved Hide resolved
dash/_pages.py Outdated Show resolved Hide resolved
@AnnMarieW
Copy link
Collaborator Author

@T4rk1n Thanks so much for your review!

Can you say more about how we might do this:

I am also wondering if there would be a way to do without a dcc.Location and container to serve the proper page layout directly in _dash-layout instead of an additional callback.

@T4rk1n
Copy link
Contributor

T4rk1n commented Mar 18, 2022

In Dash.serve_layout, you can use flask.request.referrer to find the path of the page that sent the request. Could also wrap the layout in the container there so you still have the dcc.Store(id='_page_title', value=title) to update the title with the clientside callback.

dash/dash.py Show resolved Hide resolved
dash/dash.py Outdated Show resolved Hide resolved
dash/dash.py Outdated Show resolved Hide resolved
dash/__init__.py Outdated Show resolved Hide resolved
dash/dash.py Outdated Show resolved Hide resolved
dash/_configs.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

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

💃 Love it! This has been an epic effort @AnnMarieW, can't wait to get it into everyone's hands!

@alexcjohnson alexcjohnson merged commit fbd3603 into plotly:dev Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants