adminEnvironment.tsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 {IconUpgrade} 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 DeprecatedAsyncView from 'sentry/views/deprecatedAsyncView';
  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 = DeprecatedAsyncView['state'] & {data: Data};
  19. export default class AdminEnvironment extends DeprecatedAsyncView<{}, State> {
  20. getEndpoints(): ReturnType<DeprecatedAsyncView['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. href="https://github.com/getsentry/sentry/releases"
  37. icon={<IconUpgrade size="xs" />}
  38. size="xs"
  39. external
  40. >
  41. {t('Upgrade to Sentry %s', version.latest)}
  42. </Button>
  43. )}
  44. </VersionLabel>
  45. <dd>
  46. <pre className="val">{version.current}</pre>
  47. </dd>
  48. <dt>{t('Python Version')}</dt>
  49. <dd>
  50. <pre className="val">{pythonVersion}</pre>
  51. </dd>
  52. <dt>{t('Configuration File')}</dt>
  53. <dd>
  54. <pre className="val">{environment.config}</pre>
  55. </dd>
  56. <dt>{t('Uptime')}</dt>
  57. <dd>
  58. <pre className="val">
  59. {moment(environment.start_date).toNow(true)} (since{' '}
  60. {environment.start_date})
  61. </pre>
  62. </dd>
  63. </dl>
  64. ) : (
  65. <p>
  66. {t('Environment not found (are you using the builtin Sentry webserver?).')}
  67. </p>
  68. )}
  69. <h3>
  70. {tct('Configuration [configPath]', {
  71. configPath: environment.config && <small>{environment.config}</small>,
  72. })}
  73. </h3>
  74. <dl className="vars">
  75. {config.map(([key, value]) => (
  76. <Fragment key={key}>
  77. <dt>{key}</dt>
  78. <dd>
  79. <pre className="val">{value}</pre>
  80. </dd>
  81. </Fragment>
  82. ))}
  83. </dl>
  84. </div>
  85. );
  86. }
  87. }
  88. const VersionLabel = styled('dt')`
  89. display: inline-grid;
  90. grid-auto-flow: column;
  91. gap: ${space(1)};
  92. align-items: center;
  93. `;