Browse Source

ref(crons): Extract checkStatusToIndicatorStatus to utils/constants (#67024)

David Wang 1 year ago
parent
commit
c74395132b

+ 2 - 2
static/app/components/statusIndicator.tsx

@@ -3,7 +3,7 @@ import styled from '@emotion/styled';
 
 import {Tooltip} from 'sentry/components/tooltip';
 
-type Props = {
+export type StatusIndicatorProps = {
   status: 'muted' | 'info' | 'warning' | 'success' | 'resolved' | 'error';
   tooltipTitle: React.ReactNode;
 };
@@ -13,7 +13,7 @@ type Props = {
  * the color of the status level (Warning, Error, Success, etc)
  *
  */
-function StatusIndicator({status, tooltipTitle}: Props) {
+function StatusIndicator({status, tooltipTitle}: StatusIndicatorProps) {
   let color: keyof Theme['alert'] = 'error';
 
   if (status === 'muted') {

+ 1 - 11
static/app/views/monitors/components/monitorCheckIns.tsx

@@ -27,6 +27,7 @@ import {ContextType} from 'sentry/views/discover/table/quickContext/utils';
 import type {CheckIn, Monitor, MonitorEnvironment} from 'sentry/views/monitors/types';
 import {CheckInStatus} from 'sentry/views/monitors/types';
 import {statusToText} from 'sentry/views/monitors/utils';
+import {checkStatusToIndicatorStatus} from 'sentry/views/monitors/utils/constants';
 
 type Props = {
   monitor: Monitor;
@@ -34,17 +35,6 @@ type Props = {
   orgSlug: string;
 };
 
-const checkStatusToIndicatorStatus: Record<
-  CheckInStatus,
-  'success' | 'error' | 'muted' | 'warning'
-> = {
-  [CheckInStatus.OK]: 'success',
-  [CheckInStatus.ERROR]: 'error',
-  [CheckInStatus.IN_PROGRESS]: 'muted',
-  [CheckInStatus.MISSED]: 'warning',
-  [CheckInStatus.TIMEOUT]: 'error',
-};
-
 function MonitorCheckIns({monitor, monitorEnvs, orgSlug}: Props) {
   const location = useLocation();
   const organization = useOrganization();

+ 12 - 0
static/app/views/monitors/utils/constants.tsx

@@ -1,3 +1,4 @@
+import type {StatusIndicatorProps} from 'sentry/components/statusIndicator';
 import {IconCheckmark, IconFire, IconTimer, IconUnsubscribed} from 'sentry/icons';
 import {t} from 'sentry/locale';
 import type {Aliases} from 'sentry/utils/theme';
@@ -39,3 +40,14 @@ export const statusIconColorMap: Record<
     label: t('Muted'),
   },
 };
+
+export const checkStatusToIndicatorStatus: Record<
+  CheckInStatus,
+  StatusIndicatorProps['status']
+> = {
+  [CheckInStatus.OK]: 'success',
+  [CheckInStatus.ERROR]: 'error',
+  [CheckInStatus.IN_PROGRESS]: 'muted',
+  [CheckInStatus.MISSED]: 'warning',
+  [CheckInStatus.TIMEOUT]: 'error',
+};