From a3ac9fa5f5ebf9257367239231991a2aa595bff5 Mon Sep 17 00:00:00 2001 From: Julien Pivotto Date: Tue, 21 Jul 2020 10:48:29 +0200 Subject: [PATCH] Add custom title to React UI (#7607) * Backport custom title to React UI Backports #4841 into the new UI. Signed-off-by: Julien Pivotto * Fix typo Signed-off-by: Julien Pivotto --- web/ui/react-app/public/index.html | 6 +++++- web/web.go | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/web/ui/react-app/public/index.html b/web/ui/react-app/public/index.html index 5ecd832b4..277da2c11 100755 --- a/web/ui/react-app/public/index.html +++ b/web/ui/react-app/public/index.html @@ -37,7 +37,11 @@ work correctly both with client-side routing and a non-root public URL. Learn how to configure a non-root public URL by running `npm run build`. --> - Prometheus Expression Browser + + TITLE_PLACEHOLDER diff --git a/web/web.go b/web/web.go index 87b597510..fbd404369 100644 --- a/web/web.go +++ b/web/web.go @@ -396,9 +396,10 @@ func New(logger log.Logger, o *Options) *Handler { fmt.Fprintf(w, "Error reading React index.html: %v", err) return } - prefixedIdx := bytes.ReplaceAll(idx, []byte("PATH_PREFIX_PLACEHOLDER"), []byte(o.ExternalURL.Path)) - prefixedIdx = bytes.ReplaceAll(prefixedIdx, []byte("CONSOLES_LINK_PLACEHOLDER"), []byte(h.consolesPath())) - w.Write(prefixedIdx) + replacedIdx := bytes.ReplaceAll(idx, []byte("PATH_PREFIX_PLACEHOLDER"), []byte(o.ExternalURL.Path)) + replacedIdx = bytes.ReplaceAll(replacedIdx, []byte("CONSOLES_LINK_PLACEHOLDER"), []byte(h.consolesPath())) + replacedIdx = bytes.ReplaceAll(replacedIdx, []byte("TITLE_PLACEHOLDER"), []byte(h.options.PageTitle)) + w.Write(replacedIdx) return }