diff --git a/conf/defaults.ini b/conf/defaults.ini index 801dea28d33..66836eb117a 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -304,6 +304,9 @@ password_hint = password # Default UI theme ("dark" or "light") default_theme = dark +# Path to a custom home page. Users are only redirected to this if the default home dashboard is used. It should match a frontend route and contain a leading slash. +home_page = + # External user management external_manage_link_url = external_manage_link_name = diff --git a/conf/sample.ini b/conf/sample.ini index 4ba183facc1..32e8e9de29b 100644 --- a/conf/sample.ini +++ b/conf/sample.ini @@ -304,6 +304,9 @@ # Default UI theme ("dark" or "light") ;default_theme = dark +# Path to a custom home page. Users are only redirected to this if the default home dashboard is used. It should match a frontend route and contain a leading slash. +; home_page = + # External user management, these options affect the organization users view ;external_manage_link_url = ;external_manage_link_name = diff --git a/docs/sources/administration/configuration.md b/docs/sources/administration/configuration.md index 41d70177c5b..8ce96e3978f 100644 --- a/docs/sources/administration/configuration.md +++ b/docs/sources/administration/configuration.md @@ -626,6 +626,10 @@ Text used as placeholder text on login page for password input. Set the default UI theme: `dark` or `light`. Default is `dark`. +### home_page + +Path to a custom home page. Users are only redirected to this if the default home dashboard is used. It should match a frontend route and contain a leading slash. + ### External user management If you manage users externally you can replace the user invite button for organizations with a link to an external site together with a description. diff --git a/pkg/api/dashboard.go b/pkg/api/dashboard.go index d72e4cb3853..226c1942751 100644 --- a/pkg/api/dashboard.go +++ b/pkg/api/dashboard.go @@ -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) diff --git a/pkg/setting/setting.go b/pkg/setting/setting.go index 56661a9b6c7..577e16d993b 100644 --- a/pkg/setting/setting.go +++ b/pkg/setting/setting.go @@ -353,6 +353,7 @@ type Cfg struct { Quota QuotaSettings DefaultTheme string + HomePage string AutoAssignOrg bool AutoAssignOrgId int @@ -1224,6 +1225,7 @@ func readUserSettings(iniFile *ini.File, cfg *Cfg) error { LoginHint = valueAsString(users, "login_hint", "") PasswordHint = valueAsString(users, "password_hint", "") cfg.DefaultTheme = valueAsString(users, "default_theme", "") + cfg.HomePage = valueAsString(users, "home_page", "") ExternalUserMngLinkUrl = valueAsString(users, "external_manage_link_url", "") ExternalUserMngLinkName = valueAsString(users, "external_manage_link_name", "") ExternalUserMngInfo = valueAsString(users, "external_manage_info", "")