adminWarnings.tsx 1.3 KB

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