Frontend: Foundations for multi tenant frontend (#78815)

* Frontend: Foundations for multi tenant frontend

* improve manifest parsing for multi-tenant frontend (#78876)

* add test

* add test

* ??

* Updates

* Added cache

* test cleanup

* lint

* fix test

* fix error templates

* cleanup

* remove copy

* revert changes to list testdata

* comment cleanup

* prepare integration tests

* Remove integrety

---------

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
Torkel Ödegaard
2023-12-05 08:34:22 +01:00
committed by GitHub
co-authored by Ryan McKinley
parent 7b78061235
commit ed128ea964
21 changed files with 1861 additions and 124 deletions
+7 -2
View File
@@ -149,9 +149,14 @@ func TestMiddlewareContext(t *testing.T) {
User: &dtos.CurrentUser{},
Settings: &dtos.FrontendSettingsDTO{},
NavTree: &navtree.NavTreeRoot{},
Assets: &dtos.EntryPointAssets{
JSFiles: []dtos.EntryPointAsset{},
CSSDark: "dark.css",
CSSLight: "light.css",
},
}
t.Log("Calling HTML", "data", data)
c.HTML(http.StatusOK, "index-template", data)
c.HTML(http.StatusOK, "index", data)
t.Log("Returned HTML with code 200")
}
sc.fakeReq("GET", "/").exec()
@@ -199,7 +204,7 @@ func middlewareScenario(t *testing.T, desc string, fn scenarioFunc, cbs ...func(
cfg.LoginCookieName = "grafana_session"
cfg.LoginMaxLifetime = loginMaxLifetime
// Required when rendering errors
cfg.ErrTemplateName = "error-template"
cfg.ErrTemplateName = "error"
for _, cb := range cbs {
cb(cfg)
}
+9 -1
View File
@@ -23,6 +23,8 @@ import (
"os"
"runtime"
"github.com/grafana/grafana/pkg/api/dtos"
"github.com/grafana/grafana/pkg/api/webassets"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/services/contexthandler"
"github.com/grafana/grafana/pkg/setting"
@@ -135,13 +137,19 @@ func Recovery(cfg *setting.Cfg) web.Middleware {
return
}
assets, _ := webassets.GetWebAssets(cfg)
if assets == nil {
assets = &dtos.EntryPointAssets{JSFiles: []dtos.EntryPointAsset{}}
}
data := struct {
Title string
AppTitle string
AppSubUrl string
Theme string
ErrorMsg string
}{"Server Error", "Grafana", cfg.AppSubURL, cfg.DefaultTheme, ""}
Assets *dtos.EntryPointAssets
}{"Server Error", "Grafana", cfg.AppSubURL, cfg.DefaultTheme, "", assets}
if setting.Env == setting.Dev {
if err, ok := r.(error); ok {
+1 -1
View File
@@ -50,7 +50,7 @@ func panicHandler(c *contextmodel.ReqContext) {
func recoveryScenario(t *testing.T, desc string, url string, fn scenarioFunc) {
t.Run(desc, func(t *testing.T) {
cfg := setting.NewCfg()
cfg.ErrTemplateName = "error-template"
cfg.ErrTemplateName = "error"
cfg.UserFacingDefaultError = "test error"
sc := &scenarioContext{
t: t,