Skip to content

Code Insights: Add proper dashboard redirection after insight was created via the creation UI

Administrator requested to merge vk/add-dashboard-redirection-to-creation-ui into main

Created by: vovakulikov

Closes https://github.com/sourcegraph/sourcegraph/issues/23202

Context

This PR is based on the previous PR about dashboard redirection (you can find this here https://github.com/sourcegraph/sourcegraph/pull/23988). This PR adds some dashboard context info for the creation UI pages to be able to redirect users to the dashboard they came from to these pages. For instance, if I came from my personal dashboard I will see the creation UI with prefilled visibility setting with personal visibility value and then I create this insight I will be redirected to my personal dashboard. Same logic if I came from org-level or global dashboards.

Tech notes

We achieve this dashboard info context by passing dashboard id as a query param in URL to navigate users to the creation page and then creation page takes this query dashboardID and resolves this id in dashboard object and we operate with this info to calculate the right page for the further redirection on saving insight. The main entry point for this logic you can find in this component

What have been done

  • Extract common logic of saving insight to the setting cascade to separate creation page component
  • Change all links to the creation page (adding dashboard id query param)
  • Add logic about proper redirection back to the dashboard page

Merge request reports

Loading