mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-21 03:16:00 -08:00
React UI: Use null value for determining consoles link display (#6790)
Signed-off-by: Julius Volz <julius.volz@gmail.com>
This commit is contained in:
parent
687a962bd1
commit
0a8acb654e
|
@ -15,8 +15,8 @@
|
||||||
to Prometheus, both for asset loading as well as API accesses.
|
to Prometheus, both for asset loading as well as API accesses.
|
||||||
|
|
||||||
The GLOBAL_CONSOLES_LINK placeholder magic value is replaced during serving by Prometheus
|
The GLOBAL_CONSOLES_LINK placeholder magic value is replaced during serving by Prometheus
|
||||||
and set to the consoles link if it exists. It will render a "Consoles" link in the navbar when
|
and set to the consoles link if it exists. It will render a "Consoles" link in the navbar when
|
||||||
it is non-empty.
|
it is non-empty.
|
||||||
-->
|
-->
|
||||||
<script>
|
<script>
|
||||||
const GLOBAL_PATH_PREFIX='PATH_PREFIX_PLACEHOLDER';
|
const GLOBAL_PATH_PREFIX='PATH_PREFIX_PLACEHOLDER';
|
||||||
|
|
|
@ -18,7 +18,7 @@ describe('Navbar should contain console Link', () => {
|
||||||
|
|
||||||
describe('Navbar should not contain consoles link', () => {
|
describe('Navbar should not contain consoles link', () => {
|
||||||
it('with empty string in consolesLink', () => {
|
it('with empty string in consolesLink', () => {
|
||||||
const app = shallow(<Navigation pathPrefix="/path/prefix" consolesLink="" />);
|
const app = shallow(<Navigation pathPrefix="/path/prefix" consolesLink={null} />);
|
||||||
expect(
|
expect(
|
||||||
app.contains(
|
app.contains(
|
||||||
<NavItem>
|
<NavItem>
|
||||||
|
|
|
@ -29,9 +29,9 @@ const Navigation: FC<PathPrefixProps & NavbarProps> = ({ pathPrefix, consolesLin
|
||||||
</Link>
|
</Link>
|
||||||
<Collapse isOpen={isOpen} navbar style={{ justifyContent: 'space-between' }}>
|
<Collapse isOpen={isOpen} navbar style={{ justifyContent: 'space-between' }}>
|
||||||
<Nav className="ml-0" navbar>
|
<Nav className="ml-0" navbar>
|
||||||
{consolesLink !== '' && (
|
{consolesLink !== null && (
|
||||||
<NavItem>
|
<NavItem>
|
||||||
<NavLink href={`${consolesLink}`}>Consoles</NavLink>
|
<NavLink href={consolesLink}>Consoles</NavLink>
|
||||||
</NavItem>
|
</NavItem>
|
||||||
)}
|
)}
|
||||||
<NavItem>
|
<NavItem>
|
||||||
|
|
|
@ -10,7 +10,8 @@ declare const GLOBAL_PATH_PREFIX: string;
|
||||||
declare const GLOBAL_CONSOLES_LINK: string;
|
declare const GLOBAL_CONSOLES_LINK: string;
|
||||||
|
|
||||||
let prefix = GLOBAL_PATH_PREFIX;
|
let prefix = GLOBAL_PATH_PREFIX;
|
||||||
let consolesLink = GLOBAL_CONSOLES_LINK;
|
let consolesLink: string | null = GLOBAL_CONSOLES_LINK;
|
||||||
|
|
||||||
if (GLOBAL_PATH_PREFIX === 'PATH_PREFIX_PLACEHOLDER' || GLOBAL_PATH_PREFIX === '/' || !isPresent(GLOBAL_PATH_PREFIX)) {
|
if (GLOBAL_PATH_PREFIX === 'PATH_PREFIX_PLACEHOLDER' || GLOBAL_PATH_PREFIX === '/' || !isPresent(GLOBAL_PATH_PREFIX)) {
|
||||||
// Either we are running the app outside of Prometheus, so the placeholder value in
|
// Either we are running the app outside of Prometheus, so the placeholder value in
|
||||||
// the index.html didn't get replaced, or we have a '/' prefix, which we also need to
|
// the index.html didn't get replaced, or we have a '/' prefix, which we also need to
|
||||||
|
@ -24,7 +25,7 @@ if (
|
||||||
GLOBAL_CONSOLES_LINK === '' ||
|
GLOBAL_CONSOLES_LINK === '' ||
|
||||||
!isPresent(GLOBAL_CONSOLES_LINK)
|
!isPresent(GLOBAL_CONSOLES_LINK)
|
||||||
) {
|
) {
|
||||||
consolesLink = '';
|
consolesLink = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReactDOM.render(<App pathPrefix={prefix} consolesLink={consolesLink} />, document.getElementById('root'));
|
ReactDOM.render(<App pathPrefix={prefix} consolesLink={consolesLink} />, document.getElementById('root'));
|
||||||
|
|
Loading…
Reference in a new issue