Skip to content
Snippets Groups Projects
Unverified Commit 5c2279d4 authored by Kamil Mielnik's avatar Kamil Mielnik Committed by GitHub
Browse files

Add custom warning message when leaving creating/editing a query action in...

Add custom warning message when leaving creating/editing a query action in model details page (#34192)

* Replace useBeforeUnload with LeaveConfirmationModal in ActionCreator

* Take action name and action settings changes into account when computing isDirty

* Improve action name change detection

* Rename handleFormSettingsChange to patchFormSettings

* Rename handleActionChange to patchAction

* Introduce a way to sync initial action state after creation/update

* Sync initial action state after creation/update

* Add a hack for re-rendering

* Revert "fixing" isDirty flag

* Replace delay hack with an effect

* Improve ActionCreatorModal setup
- use actual component, not the mock
- move waiting for spinner outside of setup, as it is initialRoute-dependent
- ensure history object is always present
- add missing setupDatabaseEndpoints call

* Add a test for showing custom unsaved changes warning modal

* Update default mock query action's visualization_settings

* Add a test for not showing custom unsaved changes warning modal

* Fix isDirty flag evaluation

* Group similar tests

* Add tests for creating new action

* Remove redundant spread

* Use local action

* Fix typo

* Add a test for updating an action

* Add a test for creating an action

* Fix a flake

* Add missing router in tests setup

* Enable LeaveConfirmationModal only in ActionCreatorModal with a dedicated route
- see action-related edge cases in https://github.com/metabase/metabase/issues/34114

* Fix flaking test by waiting for modal to close

* Make assertion consistent

* Fix flaky unit tests

* Refactor isDirty computation

* Add a way to skip unsaved changes warning when submitting the modal

* Remove setAction

* Bring back old logic

* Undo rename

* Update comment

* Update comment

* Add areActionsEqual to deal with redundant "value" attribute of action parameter

* Omit "hasVariableTemplateTagTarget", compute visualization settings diff based on form state

* Revert unnecessary change

* Revert unnecessary change

* Rename getActionCrudParameters to getCleanParameters

* Revert unnecessary change

* Revert unnecessary change

* Simplify isDirty computation with Question.prototype.isDirtyComparedTo

* Revert leftover code

* Remove duplicated assertion

* Update test to detect correctness of isDirty flag when user reverts changes
parent 85dbd9ac
Branches
Tags
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment