adminWarnings.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import {Fragment} from 'react';
  2. import {t} from 'sentry/locale';
  3. import DeprecatedAsyncView from 'sentry/views/deprecatedAsyncView';
  4. type Data = {
  5. groups: [groupName: string, grouppedWarnings: string[]][];
  6. warnings: string[];
  7. };
  8. type State = DeprecatedAsyncView['state'] & {data: Data | null};
  9. class AdminWarnings extends DeprecatedAsyncView<{}, State> {
  10. getEndpoints(): ReturnType<DeprecatedAsyncView['getEndpoints']> {
  11. return [['data', '/internal/warnings/']];
  12. }
  13. renderBody() {
  14. const {data} = this.state;
  15. if (data === null) {
  16. return null;
  17. }
  18. const {groups, warnings} = data;
  19. return (
  20. <div>
  21. <h3>{t('System Warnings')}</h3>
  22. {!warnings && !groups && t('There are no warnings at this time')}
  23. {groups.map(([groupName, groupedWarnings]) => (
  24. <Fragment key={groupName}>
  25. <h4>{groupName}</h4>
  26. <ul>
  27. {groupedWarnings.map((warning, i) => (
  28. <li key={i}>{warning}</li>
  29. ))}
  30. </ul>
  31. </Fragment>
  32. ))}
  33. {warnings.length > 0 && (
  34. <Fragment>
  35. <h4>Miscellaneous</h4>
  36. <ul>
  37. {warnings.map((warning, i) => (
  38. <li key={i}>{warning}</li>
  39. ))}
  40. </ul>
  41. </Fragment>
  42. )}
  43. </div>
  44. );
  45. }
  46. }
  47. export default AdminWarnings;