diff --git a/vizro-core/changelog.d/20231124_130803_antony.milne_session_storage.md b/vizro-core/changelog.d/20231124_130803_antony.milne_session_storage.md new file mode 100644 index 000000000..9231939f6 --- /dev/null +++ b/vizro-core/changelog.d/20231124_130803_antony.milne_session_storage.md @@ -0,0 +1,47 @@ + + + + + + +### Changed + +- Change the persistence of client-side data to `session` rather than `local` ([#182](https://github.com/mckinsey/vizro/pull/182)) + + + + diff --git a/vizro-core/docs/pages/user_guides/custom_charts.md b/vizro-core/docs/pages/user_guides/custom_charts.md index 3dda3f720..7325b16d2 100644 --- a/vizro-core/docs/pages/user_guides/custom_charts.md +++ b/vizro-core/docs/pages/user_guides/custom_charts.md @@ -151,10 +151,3 @@ The below examples shows a more involved use-case. We create and style a waterfa [![Graph3]][Graph3] [Graph3]: ../../assets/user_guides/custom_charts/custom_chart_waterfall.png - - -???+ warning - - Please note that users of this package are responsible for the content of any custom-created component, - function or integration they write - especially with regard to leaking any sensitive information or exposing to - any security threat during implementation. diff --git a/vizro-core/docs/pages/user_guides/custom_components.md b/vizro-core/docs/pages/user_guides/custom_components.md index f3872edfd..6caaef8bd 100644 --- a/vizro-core/docs/pages/user_guides/custom_components.md +++ b/vizro-core/docs/pages/user_guides/custom_components.md @@ -137,6 +137,7 @@ vm.Parameter.add_type("selector", TooltipNonCrossRangeSlider) className="range_slider_control" if self.step else "range_slider_control_no_space", value=value, persistence=True, + persistence_type="session", allowCross=False, # (3)! tooltip={"placement": "bottom", "always_visible": True}, # (4)! ), @@ -154,6 +155,7 @@ vm.Parameter.add_type("selector", TooltipNonCrossRangeSlider) value=value[0], size="24px", persistence=True, + persistence_type="session", ), dcc.Input( id=f"{self.id}_end_value", @@ -166,8 +168,9 @@ vm.Parameter.add_type("selector", TooltipNonCrossRangeSlider) else "slider_input_field_no_space_right", value=value[1], persistence=True, + persistence_type="session", ), - dcc.Store(id=f"temp-store-range_slider-{self.id}", storage_type="local"), + dcc.Store(id=f"temp-store-range_slider-{self.id}", storage_type="session"), ], className="slider_input_container", ), @@ -355,3 +358,5 @@ vm.Page.add_type("components", Jumbotron) Please note that users of this package are responsible for the content of any custom-created component, function or integration they write - especially with regard to leaking any sensitive information or exposing to any security threat during implementation. + + By default, all Dash components in Vizro that persist client-side data set [`persistence_type="session"` to use `window.SessionStorage`](https://dash.plotly.com/persistence), which is cleared upon closing the browser. Be careful when using any custom components that persist data beyond this scope: it is your responsibility to ensure compliance with any legal requirements affecting jurisdictions in which your app operates. diff --git a/vizro-core/docs/pages/user_guides/integration.md b/vizro-core/docs/pages/user_guides/integration.md index c4c6e1253..faa0f4961 100644 --- a/vizro-core/docs/pages/user_guides/integration.md +++ b/vizro-core/docs/pages/user_guides/integration.md @@ -70,10 +70,3 @@ The full code for these different cases is given below. for dataset_name, dataset in kedro_integration.datasets_from_catalog(catalog).items(): data_manager[dataset_name] = dataset ``` - - -???+ warning - - Please note that users of this package are responsible for the content of any custom-created component, - function or integration they write - especially with regard to leaking any sensitive information or exposing to - any security threat during implementation. diff --git a/vizro-core/src/vizro/models/_components/form/_user_input.py b/vizro-core/src/vizro/models/_components/form/_user_input.py index cfe29a275..53821ed98 100644 --- a/vizro-core/src/vizro/models/_components/form/_user_input.py +++ b/vizro-core/src/vizro/models/_components/form/_user_input.py @@ -42,6 +42,7 @@ def build(self): placeholder=self.placeholder, type=self.input_type, persistence=True, + persistence_type="session", debounce=True, className="user_input", ), diff --git a/vizro-core/src/vizro/models/_components/form/checklist.py b/vizro-core/src/vizro/models/_components/form/checklist.py index b8f0daea6..83d07aa06 100644 --- a/vizro-core/src/vizro/models/_components/form/checklist.py +++ b/vizro-core/src/vizro/models/_components/form/checklist.py @@ -47,6 +47,7 @@ def build(self): options=full_options, value=self.value if self.value is not None else [default_value], persistence=True, + persistence_type="session", className="selector_body_checklist", ), ], diff --git a/vizro-core/src/vizro/models/_components/form/dropdown.py b/vizro-core/src/vizro/models/_components/form/dropdown.py index 9d01c79a5..cf5626954 100755 --- a/vizro-core/src/vizro/models/_components/form/dropdown.py +++ b/vizro-core/src/vizro/models/_components/form/dropdown.py @@ -60,6 +60,7 @@ def build(self): value=self.value if self.value is not None else default_value, multi=self.multi, persistence=True, + persistence_type="session", className="selector_body_dropdown", ), ], diff --git a/vizro-core/src/vizro/models/_components/form/radio_items.py b/vizro-core/src/vizro/models/_components/form/radio_items.py index 782f15d21..2d69efa6c 100644 --- a/vizro-core/src/vizro/models/_components/form/radio_items.py +++ b/vizro-core/src/vizro/models/_components/form/radio_items.py @@ -48,6 +48,7 @@ def build(self): options=full_options, value=self.value if self.value is not None else default_value, persistence=True, + persistence_type="session", className="selector_body_radio_items", ), ], diff --git a/vizro-core/src/vizro/models/_components/form/range_slider.py b/vizro-core/src/vizro/models/_components/form/range_slider.py index 4ee181c8d..9bd94e52b 100644 --- a/vizro-core/src/vizro/models/_components/form/range_slider.py +++ b/vizro-core/src/vizro/models/_components/form/range_slider.py @@ -98,6 +98,7 @@ def build(self): marks=self.marks, value=value, persistence=True, + persistence_type="session", className="range_slider_control" if self.step else "range_slider_control_no_space", ), html.Div( @@ -112,6 +113,7 @@ def build(self): value=value[0], size="24px", persistence=True, + persistence_type="session", className="slider_input_field_left" if self.step else "slider_input_field_no_space_left", @@ -125,11 +127,12 @@ def build(self): step=self.step, value=value[1], persistence=True, + persistence_type="session", className="slider_input_field_right" if self.step else "slider_input_field_no_space_right", ), - dcc.Store(id=f"temp-store-range_slider-{self.id}", storage_type="local"), + dcc.Store(id=f"temp-store-range_slider-{self.id}", storage_type="session"), ], className="slider_input_container", ), diff --git a/vizro-core/src/vizro/models/_components/form/slider.py b/vizro-core/src/vizro/models/_components/form/slider.py index 4a44e898f..28be60714 100644 --- a/vizro-core/src/vizro/models/_components/form/slider.py +++ b/vizro-core/src/vizro/models/_components/form/slider.py @@ -93,6 +93,7 @@ def build(self): value=self.value or self.min, included=False, persistence=True, + persistence_type="session", className="slider_control" if self.step else "slider_control_no_space", ), dcc.Input( @@ -104,9 +105,10 @@ def build(self): step=self.step, value=self.value or self.min, persistence=True, + persistence_type="session", className="slider_input_field_right" if self.step else "slider_input_field_no_space_right", ), - dcc.Store(id=f"{self.id}_temp_store", storage_type="local"), + dcc.Store(id=f"{self.id}_temp_store", storage_type="session"), ], className="slider_inner_container", ), diff --git a/vizro-core/src/vizro/models/_dashboard.py b/vizro-core/src/vizro/models/_dashboard.py index f28b08f22..a1631288a 100644 --- a/vizro-core/src/vizro/models/_dashboard.py +++ b/vizro-core/src/vizro/models/_dashboard.py @@ -96,7 +96,9 @@ def _make_page_layout(self, page: Page): if self.title else html.Div(hidden=True, id="dashboard_title_outer") ) - theme_switch = daq.BooleanSwitch(id="theme_selector", on=self.theme == "vizro_dark", persistence=True) + theme_switch = daq.BooleanSwitch( + id="theme_selector", on=self.theme == "vizro_dark", persistence=True, persistence_type="session" + ) # Shared across pages but slightly differ in content page_title = html.H2(children=page.title, id="page_title") diff --git a/vizro-core/tests/unit/vizro/models/_components/form/test_checklist.py b/vizro-core/tests/unit/vizro/models/_components/form/test_checklist.py index c73dd0c06..be1275a13 100755 --- a/vizro-core/tests/unit/vizro/models/_components/form/test_checklist.py +++ b/vizro-core/tests/unit/vizro/models/_components/form/test_checklist.py @@ -21,6 +21,7 @@ def expected_checklist(): value=["ALL"], className="selector_body_checklist", persistence=True, + persistence_type="session", ), ], className="selector_container", diff --git a/vizro-core/tests/unit/vizro/models/_components/form/test_dropdown.py b/vizro-core/tests/unit/vizro/models/_components/form/test_dropdown.py index 64b94f0e2..76b496162 100755 --- a/vizro-core/tests/unit/vizro/models/_components/form/test_dropdown.py +++ b/vizro-core/tests/unit/vizro/models/_components/form/test_dropdown.py @@ -21,6 +21,7 @@ def expected_dropdown_with_all(): value="ALL", multi=True, persistence=True, + persistence_type="session", className="selector_body_dropdown", ), ], @@ -40,6 +41,7 @@ def expected_dropdown_without_all(): value="A", multi=False, persistence=True, + persistence_type="session", className="selector_body_dropdown", ), ], diff --git a/vizro-core/tests/unit/vizro/models/_components/form/test_radioitems.py b/vizro-core/tests/unit/vizro/models/_components/form/test_radioitems.py index 83c2053bd..05f935895 100755 --- a/vizro-core/tests/unit/vizro/models/_components/form/test_radioitems.py +++ b/vizro-core/tests/unit/vizro/models/_components/form/test_radioitems.py @@ -21,6 +21,7 @@ def expected_radio_items(): value="A", className="selector_body_radio_items", persistence=True, + persistence_type="session", ), ], className="selector_container", diff --git a/vizro-core/tests/unit/vizro/models/_components/form/test_range_slider.py b/vizro-core/tests/unit/vizro/models/_components/form/test_range_slider.py index dba28f7b6..5e74b86df 100644 --- a/vizro-core/tests/unit/vizro/models/_components/form/test_range_slider.py +++ b/vizro-core/tests/unit/vizro/models/_components/form/test_range_slider.py @@ -28,6 +28,7 @@ def expected_range_slider_default(): id="range_slider", className="range_slider_control_no_space", persistence=True, + persistence_type="session", min=None, max=None, marks=None, @@ -44,6 +45,7 @@ def expected_range_slider_default(): size="24px", step=None, persistence=True, + persistence_type="session", min=None, max=None, value=None, @@ -54,12 +56,13 @@ def expected_range_slider_default(): placeholder="end", className="slider_input_field_no_space_right", persistence=True, + persistence_type="session", step=None, min=None, max=None, value=None, ), - dcc.Store(id="temp-store-range_slider-range_slider", storage_type="local"), + dcc.Store(id="temp-store-range_slider-range_slider", storage_type="session"), ], className="slider_input_container", ), @@ -96,6 +99,7 @@ def expected_range_slider_with_optional(): className="range_slider_control", value=[0, 10], persistence=True, + persistence_type="session", ), html.Div( [ @@ -110,6 +114,7 @@ def expected_range_slider_with_optional(): value=0, size="24px", persistence=True, + persistence_type="session", ), dcc.Input( id="range_slider_with_all_end_value", @@ -121,8 +126,9 @@ def expected_range_slider_with_optional(): className="slider_input_field_right", value=10, persistence=True, + persistence_type="session", ), - dcc.Store(id="temp-store-range_slider-range_slider_with_all", storage_type="local"), + dcc.Store(id="temp-store-range_slider-range_slider_with_all", storage_type="session"), ], className="slider_input_container", ), diff --git a/vizro-core/tests/unit/vizro/models/_components/form/test_slider.py b/vizro-core/tests/unit/vizro/models/_components/form/test_slider.py index a8cd4a6ab..6a2747010 100755 --- a/vizro-core/tests/unit/vizro/models/_components/form/test_slider.py +++ b/vizro-core/tests/unit/vizro/models/_components/form/test_slider.py @@ -33,6 +33,7 @@ def expected_slider(): value=5, included=False, persistence=True, + persistence_type="session", className="slider_control", ), dcc.Input( @@ -44,9 +45,10 @@ def expected_slider(): max=10, value=5, persistence=True, + persistence_type="session", className="slider_input_field_right", ), - dcc.Store(id="slider_id_temp_store", storage_type="local"), + dcc.Store(id="slider_id_temp_store", storage_type="session"), ], className="slider_inner_container", ),