Browse Source

Add custom title to React UI (#7607)

* Backport custom title to React UI

Backports #4841 into the new UI.

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>

* Fix typo

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
pull/7631/head
Julien Pivotto 4 years ago committed by GitHub
parent
commit
a3ac9fa5f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      web/ui/react-app/public/index.html
  2. 7
      web/web.go

6
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`.
-->
<title>Prometheus Expression Browser</title>
<!--
The TITLE_PLACEHOLDER magic value is replaced during serving by Prometheus.
We need it dynamic because it can be overriden by the command line flag `web.page-title`.
-->
<title>TITLE_PLACEHOLDER</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>

7
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
}

Loading…
Cancel
Save