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:
parent
31a6d12d34
commit
bd74953f0d
@ -304,6 +304,9 @@ password_hint = password
|
|||||||
# Default UI theme ("dark" or "light")
|
# Default UI theme ("dark" or "light")
|
||||||
default_theme = dark
|
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 user management
|
||||||
external_manage_link_url =
|
external_manage_link_url =
|
||||||
external_manage_link_name =
|
external_manage_link_name =
|
||||||
|
@ -304,6 +304,9 @@
|
|||||||
# Default UI theme ("dark" or "light")
|
# Default UI theme ("dark" or "light")
|
||||||
;default_theme = dark
|
;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 user management, these options affect the organization users view
|
||||||
;external_manage_link_url =
|
;external_manage_link_url =
|
||||||
;external_manage_link_name =
|
;external_manage_link_name =
|
||||||
|
@ -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`.
|
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
|
### 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.
|
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.
|
||||||
|
@ -371,10 +371,17 @@ func (hs *HTTPServer) dashboardSaveErrorToApiResponse(err error) response.Respon
|
|||||||
// GetHomeDashboard returns the home dashboard.
|
// GetHomeDashboard returns the home dashboard.
|
||||||
func (hs *HTTPServer) GetHomeDashboard(c *models.ReqContext) response.Response {
|
func (hs *HTTPServer) GetHomeDashboard(c *models.ReqContext) response.Response {
|
||||||
prefsQuery := models.GetPreferencesWithDefaultsQuery{User: c.SignedInUser}
|
prefsQuery := models.GetPreferencesWithDefaultsQuery{User: c.SignedInUser}
|
||||||
|
homePage := hs.Cfg.HomePage
|
||||||
|
|
||||||
if err := hs.Bus.Dispatch(&prefsQuery); err != nil {
|
if err := hs.Bus.Dispatch(&prefsQuery); err != nil {
|
||||||
return response.Error(500, "Failed to get preferences", err)
|
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 {
|
if prefsQuery.Result.HomeDashboardId != 0 {
|
||||||
slugQuery := models.GetDashboardRefByIdQuery{Id: prefsQuery.Result.HomeDashboardId}
|
slugQuery := models.GetDashboardRefByIdQuery{Id: prefsQuery.Result.HomeDashboardId}
|
||||||
err := hs.Bus.Dispatch(&slugQuery)
|
err := hs.Bus.Dispatch(&slugQuery)
|
||||||
|
@ -366,6 +366,7 @@ type Cfg struct {
|
|||||||
Quota QuotaSettings
|
Quota QuotaSettings
|
||||||
|
|
||||||
DefaultTheme string
|
DefaultTheme string
|
||||||
|
HomePage string
|
||||||
|
|
||||||
AutoAssignOrg bool
|
AutoAssignOrg bool
|
||||||
AutoAssignOrgId int
|
AutoAssignOrgId int
|
||||||
@ -1252,6 +1253,7 @@ func readUserSettings(iniFile *ini.File, cfg *Cfg) error {
|
|||||||
LoginHint = valueAsString(users, "login_hint", "")
|
LoginHint = valueAsString(users, "login_hint", "")
|
||||||
PasswordHint = valueAsString(users, "password_hint", "")
|
PasswordHint = valueAsString(users, "password_hint", "")
|
||||||
cfg.DefaultTheme = valueAsString(users, "default_theme", "")
|
cfg.DefaultTheme = valueAsString(users, "default_theme", "")
|
||||||
|
cfg.HomePage = valueAsString(users, "home_page", "")
|
||||||
ExternalUserMngLinkUrl = valueAsString(users, "external_manage_link_url", "")
|
ExternalUserMngLinkUrl = valueAsString(users, "external_manage_link_url", "")
|
||||||
ExternalUserMngLinkName = valueAsString(users, "external_manage_link_name", "")
|
ExternalUserMngLinkName = valueAsString(users, "external_manage_link_name", "")
|
||||||
ExternalUserMngInfo = valueAsString(users, "external_manage_info", "")
|
ExternalUserMngInfo = valueAsString(users, "external_manage_info", "")
|
||||||
|
Loading…
Reference in New Issue
Block a user