adminEnvironment.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import moment from 'moment';
  4. import Button from 'sentry/components/button';
  5. import {IconQuestion} from 'sentry/icons';
  6. import {t, tct} from 'sentry/locale';
  7. import ConfigStore from 'sentry/stores/configStore';
  8. import space from 'sentry/styles/space';
  9. import AsyncView from 'sentry/views/asyncView';
  10. type Data = {
  11. config: [key: string, value: string][];
  12. environment: {
  13. config: string;
  14. start_date: string;
  15. };
  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.getState();
  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. aria-label={t(
  41. "You're running an old version of Sentry, did you know %s is available?",
  42. version.latest
  43. )}
  44. priority="link"
  45. href="https://github.com/getsentry/sentry/releases"
  46. icon={<IconQuestion size="sm" />}
  47. size="sm"
  48. external
  49. />
  50. )}
  51. </VersionLabel>
  52. <dd>
  53. <pre className="val">{version.current}</pre>
  54. </dd>
  55. <dt>{t('Python Version')}</dt>
  56. <dd>
  57. <pre className="val">{pythonVersion}</pre>
  58. </dd>
  59. <dt>{t('Configuration File')}</dt>
  60. <dd>
  61. <pre className="val">{environment.config}</pre>
  62. </dd>
  63. <dt>{t('Uptime')}</dt>
  64. <dd>
  65. <pre className="val">
  66. {moment(environment.start_date).toNow(true)} (since{' '}
  67. {environment.start_date})
  68. </pre>
  69. </dd>
  70. </dl>
  71. ) : (
  72. <p>
  73. {t('Environment not found (are you using the builtin Sentry webserver?).')}
  74. </p>
  75. )}
  76. <h3>
  77. {tct('Configuration [configPath]', {
  78. configPath: environment.config && <small>{environment.config}</small>,
  79. })}
  80. </h3>
  81. <dl className="vars">
  82. {config.map(([key, value]) => (
  83. <Fragment key={key}>
  84. <dt>{key}</dt>
  85. <dd>
  86. <pre className="val">{value}</pre>
  87. </dd>
  88. </Fragment>
  89. ))}
  90. </dl>
  91. </div>
  92. );
  93. }
  94. }
  95. const VersionLabel = styled('dt')`
  96. display: inline-grid;
  97. grid-auto-flow: column;
  98. gap: ${space(1)};
  99. align-items: center;
  100. `;