* 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>
(cherry picked from commit bd74953f0d)
Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
This commit is contained in:
co-authored by
Jack Westbrook
parent
4f542d69db
commit
7354150b79
@@ -368,10 +368,17 @@ func dashboardSaveErrorToApiResponse(err error) response.Response {
|
||||
// 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