kgabryje opened a new pull request, #20743: URL: https://github.com/apache/superset/pull/20743
### SUMMARY Currently when user clicks "Edit chart" or chart's title in Dashboard page, we first send a POST request to retrieve form_data_key, then create an Explore URL with that form_data_key and redirect to Explore. We do that in order to pass dashboard context (such as native filters, cross filter, color scheme...) to Explore. There are several problems with this approach: - we redirect to another page, so from semantic HTML point of view this element should be a link - user can't access standard link contextual menu when right clicking - there's a noticeable delay between a click and redirection because of HTTP request being made in the middle - we unnecessarily take up space in redis In order to refactor "Edit chart" to be a link, we need to pass dashboard context in a different way. This PR implements the following changes: - save current dashboard state in local storage, where random id generated on Dashboard mount is a key and stringified state is a value - update the value in local storage on each dashboard state change (such as applying new native filter or cross filter or changing color scheme) - "Edit chart"/chart title is a React Router Link and it contains local storage key as a search param - when mounting Explore, retrieve the dashboard state from local storage using the dashboard id search param and merge it with form data coming from initializing Explore request ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF <!--- Skip this if not applicable --> https://user-images.githubusercontent.com/15073128/179526015-608cef82-85fd-432c-aa5b-57f563cd5e0b.mov ### TESTING INSTRUCTIONS 1. Open dashboard 2. Apply native filters, cross filters, filter box filters 3. Open Explore by clicking on chart title or clicking "Edit chart". Try opening in the same tab and opening in a new tab 4. Verify that filters from dashboard are present in Explore ### ADDITIONAL INFORMATION <!--- Check any relevant boxes with "x" --> <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue --> - [ ] Has associated issue: - [ ] Required feature flags: - [ ] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] Migration is atomic, supports rollback & is backwards-compatible - [ ] Confirm DB migration upgrade and downgrade tested - [ ] Runtime estimates and downtime expectations provided - [ ] Introduces new feature or API - [ ] Removes existing feature or API -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
