github.com/thanos-io/thanos@v0.32.5/pkg/ui/react-app/src/index.tsx (about)

     1  import './globals';
     2  import React from 'react';
     3  import ReactDOM from 'react-dom';
     4  import App from './App';
     5  import './themes/app.scss';
     6  import './themes/light.scss';
     7  import './themes/dark.scss';
     8  import './fonts/codicon.ttf';
     9  import { isPresent } from './utils';
    10  
    11  // Declared/defined in public/index.html, value replaced by Prometheus when serving bundle.
    12  declare const GLOBAL_PATH_PREFIX: string;
    13  declare const THANOS_COMPONENT: string;
    14  
    15  let prefix = GLOBAL_PATH_PREFIX;
    16  if (GLOBAL_PATH_PREFIX === '{{ pathPrefix }}' || GLOBAL_PATH_PREFIX === '/' || !isPresent(GLOBAL_PATH_PREFIX)) {
    17    // Either we are running the app outside of Prometheus, so the placeholder value in
    18    // the index.html didn't get replaced, or we have a '/' prefix, which we also need to
    19    // normalize to '' to make concatenations work (prefixes like '/foo/bar/' already get
    20    // their trailing slash stripped by Prometheus).
    21    prefix = '';
    22  }
    23  let thanosComponent = THANOS_COMPONENT;
    24  if (THANOS_COMPONENT === '' || THANOS_COMPONENT === '{{ .Component }}') {
    25    thanosComponent = 'query';
    26  }
    27  
    28  ReactDOM.render(<App pathPrefix={prefix} thanosComponent={thanosComponent} />, document.getElementById('root'));