mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Plugins: Allow a non-dashboard page to be the default home page (#32926)
* feat: introduce home page redirect if default dashboard * style: clean up * Apply suggestions from code review Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com> * chore(dashboard): remove obsolete setting import * docs(config): add home_page description Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
This commit is contained in:
@@ -371,10 +371,17 @@ func (hs *HTTPServer) dashboardSaveErrorToApiResponse(err error) response.Respon
|
||||
// GetHomeDashboard returns the home dashboard.
|
||||
func (hs *HTTPServer) GetHomeDashboard(c *models.ReqContext) response.Response {
|
||||
prefsQuery := models.GetPreferencesWithDefaultsQuery{User: c.SignedInUser}
|
||||
homePage := hs.Cfg.HomePage
|
||||
|
||||
if err := hs.Bus.Dispatch(&prefsQuery); err != nil {
|
||||
return response.Error(500, "Failed to get preferences", err)
|
||||
}
|
||||
|
||||
if prefsQuery.Result.HomeDashboardId == 0 && len(homePage) > 0 {
|
||||
homePageRedirect := dtos.DashboardRedirect{RedirectUri: homePage}
|
||||
return response.JSON(200, &homePageRedirect)
|
||||
}
|
||||
|
||||
if prefsQuery.Result.HomeDashboardId != 0 {
|
||||
slugQuery := models.GetDashboardRefByIdQuery{Id: prefsQuery.Result.HomeDashboardId}
|
||||
err := hs.Bus.Dispatch(&slugQuery)
|
||||
|
||||
Reference in New Issue
Block a user