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 update_title config option #102

Merged
merged 4 commits into from
May 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/app/config.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ struct DashConfig
include_assets_files ::Bool
show_undo_redo ::Bool
compress ::Bool
update_title ::String
end
15 changes: 12 additions & 3 deletions src/app/dashapp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ get_assets_path(app::DashApp) = joinpath(app.root_path, get_setting(app, :assets
assets_external_path,
include_assets_files,
show_undo_redo,
compress
compress,
update_title
)

Dash is a framework for building analytical web applications. No JavaScript required.
Expand Down Expand Up @@ -280,6 +281,12 @@ If a parameter can be set by an environment variable, that is listed as:
- `compress::Bool`: Default ``true``, controls whether gzip is used to compress
files and data served by HTTP.jl when supported by the client. Set to
``false`` to disable compression completely.

- `update_title::String`: Default ``Updating...``. Configures the document.title
(the text that appears in a browser tab) text when a callback is being run.
Set to '' if you don't want the document.title to change or if you
want to control the document.title through a separate component or
clientside callback.
Comment on lines +285 to +289
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Only supporting '' is fine by me.

"""
function dash(;
external_stylesheets = ExternalSrcType[],
Expand All @@ -299,7 +306,8 @@ function dash(;
assets_external_path = dash_env("assets_external_path"),
include_assets_files = dash_env(Bool, "include_assets_files", true),
show_undo_redo = false,
compress = true
compress = true,
update_title = "Updating..."

)

Expand All @@ -323,7 +331,8 @@ function dash(;
assets_external_path,
include_assets_files,
show_undo_redo,
compress
compress,
update_title
)
result = DashApp(app_root_path(), isinteractive(), config, index_string)
return result
Expand Down
3 changes: 2 additions & 1 deletion src/handler/index_page.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ function config_html(app::DashApp)
:ui => get_devsetting(app, :ui),
:props_check => get_devsetting(app, :props_check),
:show_undo_redo => get_setting(app, :show_undo_redo),
:suppress_callback_exceptions => get_setting(app, :suppress_callback_exceptions)
:suppress_callback_exceptions => get_setting(app, :suppress_callback_exceptions),
:update_title => get_setting(app, :update_title)
)
if get_devsetting(app, :hot_reload)
config[:hot_reload] = (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using Dash
using DashHtmlComponents

app = dash()
app.layout = html_div(children = "Hello world!", id = "hello-div")
run_server(app)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using Dash
using DashHtmlComponents

app = dash(;update_title = "... computing !")
app.layout = html_div(children = "Hello world!", id = "hello-div")
run_server(app)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using Dash
using DashHtmlComponents

app = dash(;update_title = "")
app.layout = html_div(children = "Hello world!", id = "hello-div")
run_server(app)
34 changes: 34 additions & 0 deletions test/integration/base/test_update_title.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import os
import pathlib

curr_path = pathlib.Path(__file__).parent.absolute()


def boot(dashjl, filename):
fp = os.path.join(curr_path, "jl_update_title", filename)
dashjl.start_server(fp)
dashjl.wait_for_text_to_equal(
"#hello-div",
"Hello world!"
)


def get_update_title_state(dashjl):
return dashjl.driver.execute_script(
"return store.getState().config.update_title"
)


def test_jltut001_update_title(dashjl):
boot(dashjl, "jltut001_update_title.jl")
assert get_update_title_state(dashjl) == "Updating..."


def test_jltut002_update_title(dashjl):
boot(dashjl, "jltut002_update_title.jl")
assert get_update_title_state(dashjl) == "... computing !"


def test_jltut003_update_title(dashjl):
boot(dashjl, "jltut003_update_title.jl")
assert get_update_title_state(dashjl) == ""