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 very basic update notifications #3121

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft

Conversation

marthacryan
Copy link

Warning: Very much in-progress

This PR adds the ability to notify dash developers of new versions of dash through the developer tools. It mostly updates the errors section of the dash developer tools frontend. The only change to python is adding an additional config passed from the python side to send the dash python version to the frontend.

The notification prompts the developer to upgrade their version of dash and has 3 options for actions:

  • Don't show again -> sets a boolean flag in local storage if the user clicks.
  • Remind me later -> sets a field in local storage to the time that this button is clicked. The frontend then uses that to determine whether to show the notification again.
  • Skip this version -> sets a field in local storage to the version that was received from the server. The frontend then uses that to determine whether to show the notification again.

Todos:

  • Add style to UI (There is currently no style applied to the buttons / very little applied to the notification)
  • Update dev tools menu options - create separate button for toggling notifications?
  • Code cleanup - clean up handling of button clicks, clean up names of directories and files that assume notifications are errors, etc.
  • Swap in actual server information for notifications
A couple of sample files to help test Server:
from flask import Flask, request
from flask_cors import CORS

app = Flask(__name__)
CORS(app)
@app.route('/sample', methods=['POST'])
def index():
    # Get contents of post request
    data = request.json
    if data['dash_version'] == current_version:
        return []
    else: 
        return [{
            'message': 'A new version of dash is available! Run `pip install dash --upgrade` to upgrade.',
            'buttons': ['dont_show_again', 'remind_me_later', 'skip_this_version'],
            'version': current_version
        }]
   

if __name__ == '__main__':
    # on port 8080
    app.run(debug=True, port=8080)

Dash app that adds errors to show how errors fit with these notifications:

## generic dash app
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output

app = dash.Dash(__name__)

app.layout = html.Div([
    dcc.Input(id='input', value='initial value', type='text'),
    html.Div(id='output')
])

@app.callback(
    Output(component_id='output', component_property='children'),
    [Input(component_id='input', component_property='value')]
)
def update_value(input_data):
    # Throw a sample error
    raise ValueError('This is a sample error')
    return 'Input: "{}"'.format(input_data)

if __name__ == '__main__':
    app.run_server(debug=True)

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.

1 participant