adminEnvironment.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import moment from 'moment';
  4. import Button from 'app/components/button';
  5. import {IconQuestion} from 'app/icons';
  6. import {t, tct} from 'app/locale';
  7. import ConfigStore from 'app/stores/configStore';
  8. import space from 'app/styles/space';
  9. import AsyncView from 'app/views/asyncView';
  10. type Data = {
  11. environment: {
  12. config: string;
  13. start_date: string;
  14. };
  15. config: [key: string, value: string][];
  16. pythonVersion: string;
  17. };
  18. type State = AsyncView['state'] & {data: Data};
  19. export default class AdminEnvironment extends AsyncView<{}, State> {
  20. getEndpoints(): ReturnType<AsyncView['getEndpoints']> {
  21. return [['data', '/internal/environment/']];
  22. }
  23. renderBody() {
  24. const {data} = this.state;
  25. const {environment, config, pythonVersion} = data;
  26. const {version} = ConfigStore.getConfig();
  27. return (
  28. <div>
  29. <h3>{t('Environment')}</h3>
  30. {environment ? (
  31. <dl className="vars">
  32. <VersionLabel>
  33. {t('Server Version')}
  34. {version.upgradeAvailable && (
  35. <Button
  36. title={t(
  37. "You're running an old version of Sentry, did you know %s is available?",
  38. version.latest
  39. )}
  40. priority="link"
  41. href="https://github.com/getsentry/sentry/releases"
  42. icon={<IconQuestion size="sm" />}
  43. size="small"
  44. external
  45. />
  46. )}
  47. </VersionLabel>
  48. <dd>
  49. <pre className="val">{version.current}</pre>
  50. </dd>
  51. <dt>{t('Python Version')}</dt>
  52. <dd>
  53. <pre className="val">{pythonVersion}</pre>
  54. </dd>
  55. <dt>{t('Configuration File')}</dt>
  56. <dd>
  57. <pre className="val">{environment.config}</pre>
  58. </dd>
  59. <dt>{t('Uptime')}</dt>
  60. <dd>
  61. <pre className="val">
  62. {moment(environment.start_date).toNow(true)} (since{' '}
  63. {environment.start_date})
  64. </pre>
  65. </dd>
  66. </dl>
  67. ) : (
  68. <p>
  69. {t('Environment not found (are you using the builtin Sentry webserver?).')}
  70. </p>
  71. )}
  72. <h3>
  73. {tct('Configuration [configPath]', {
  74. configPath: environment.config && <small>{environment.config}</small>,
  75. })}
  76. </h3>
  77. <dl className="vars">
  78. {config.map(([key, value]) => (
  79. <Fragment key={key}>
  80. <dt>{key}</dt>
  81. <dd>
  82. <pre className="val">{value}</pre>
  83. </dd>
  84. </Fragment>
  85. ))}
  86. </dl>
  87. </div>
  88. );
  89. }
  90. }
  91. const VersionLabel = styled('dt')`
  92. display: inline-grid;
  93. grid-auto-flow: column;
  94. grid-gap: ${space(1)};
  95. align-items: center;
  96. `;