From 49edf7e0046775b5077c4affd94375f7367b4f1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Wed, 5 May 2021 14:49:08 -0400 Subject: [PATCH 1/3] add `update_title` config option - add `update_title` String field to DashConfig struct - use `"Updating..." as default - inject its value into the frontend, to make it available to the dash renderer --- src/app/config.jl | 1 + src/app/dashapp.jl | 15 ++++++++++++--- src/handler/index_page.jl | 3 ++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/app/config.jl b/src/app/config.jl index ff8d496..be6af42 100644 --- a/src/app/config.jl +++ b/src/app/config.jl @@ -16,4 +16,5 @@ struct DashConfig include_assets_files ::Bool show_undo_redo ::Bool compress ::Bool + update_title ::String end diff --git a/src/app/dashapp.jl b/src/app/dashapp.jl index 976cc37..64d02b3 100644 --- a/src/app/dashapp.jl +++ b/src/app/dashapp.jl @@ -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. @@ -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. """ function dash(; external_stylesheets = ExternalSrcType[], @@ -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..." ) @@ -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 diff --git a/src/handler/index_page.jl b/src/handler/index_page.jl index aedac11..5a0e84c 100644 --- a/src/handler/index_page.jl +++ b/src/handler/index_page.jl @@ -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] = ( From 4b07cab205ded6acd39d8a1c23b9707db58c7069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Thu, 6 May 2021 14:17:44 -0400 Subject: [PATCH 2/3] add `update_title` integration tests --- .../jl_update_title/jltut001_update_title.jl | 6 ++++ .../jl_update_title/jltut002_update_title.jl | 6 ++++ .../jl_update_title/jltut003_update_title.jl | 6 ++++ test/integration/base/test_update_title.py | 34 +++++++++++++++++++ 4 files changed, 52 insertions(+) create mode 100644 test/integration/base/jl_update_title/jltut001_update_title.jl create mode 100644 test/integration/base/jl_update_title/jltut002_update_title.jl create mode 100644 test/integration/base/jl_update_title/jltut003_update_title.jl create mode 100644 test/integration/base/test_update_title.py diff --git a/test/integration/base/jl_update_title/jltut001_update_title.jl b/test/integration/base/jl_update_title/jltut001_update_title.jl new file mode 100644 index 0000000..829ac23 --- /dev/null +++ b/test/integration/base/jl_update_title/jltut001_update_title.jl @@ -0,0 +1,6 @@ +using Dash +using DashHtmlComponents + +app = dash() +app.layout = html_div(children = "Hello world!", id = "hello-div") +run_server(app) diff --git a/test/integration/base/jl_update_title/jltut002_update_title.jl b/test/integration/base/jl_update_title/jltut002_update_title.jl new file mode 100644 index 0000000..e910df6 --- /dev/null +++ b/test/integration/base/jl_update_title/jltut002_update_title.jl @@ -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) diff --git a/test/integration/base/jl_update_title/jltut003_update_title.jl b/test/integration/base/jl_update_title/jltut003_update_title.jl new file mode 100644 index 0000000..798e7a3 --- /dev/null +++ b/test/integration/base/jl_update_title/jltut003_update_title.jl @@ -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) diff --git a/test/integration/base/test_update_title.py b/test/integration/base/test_update_title.py new file mode 100644 index 0000000..b39aad1 --- /dev/null +++ b/test/integration/base/test_update_title.py @@ -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) == "" From c0c0cb82ab3a2e81b31568f341c4708cade4378c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Thu, 6 May 2021 16:57:14 -0400 Subject: [PATCH 3/3] trigger CI tests