-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: update alert/report icons and column order #12081
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,53 +22,87 @@ import { Tooltip } from 'src/common/components/Tooltip'; | |
import Icon, { IconName } from 'src/components/Icon'; | ||
import { AlertState } from '../types'; | ||
|
||
const StatusIcon = styled(Icon)<{ status: string }>` | ||
color: ${({ status, theme }) => { | ||
const StatusIcon = styled(Icon)<{ status: string; isReportEnabled: boolean }>` | ||
color: ${({ status, theme, isReportEnabled }) => { | ||
switch (status) { | ||
case AlertState.working: | ||
return theme.colors.alert.base; | ||
return theme.colors.primary.base; | ||
case AlertState.error: | ||
return theme.colors.error.base; | ||
case AlertState.success: | ||
return isReportEnabled | ||
? theme.colors.success.base | ||
: theme.colors.alert.base; | ||
case AlertState.noop: | ||
return theme.colors.success.base; | ||
case AlertState.grace: | ||
return theme.colors.alert.base; | ||
default: | ||
return theme.colors.grayscale.base; | ||
} | ||
}}; | ||
`; | ||
|
||
export default function AlertStatusIcon({ state }: { state: string }) { | ||
export default function AlertStatusIcon({ | ||
state, | ||
isReportEnabled = false, | ||
}: { | ||
state: string; | ||
isReportEnabled: boolean; | ||
}) { | ||
const lastStateConfig = { | ||
name: '', | ||
label: '', | ||
status: '', | ||
}; | ||
switch (state) { | ||
case AlertState.success: | ||
lastStateConfig.name = 'check'; | ||
lastStateConfig.label = t(`${AlertState.success}`); | ||
lastStateConfig.name = isReportEnabled ? 'check' : 'alert-solid-small'; | ||
lastStateConfig.label = isReportEnabled | ||
? t('Report Sent') | ||
: t('Alert Triggered, Notification Sent'); | ||
lastStateConfig.status = AlertState.success; | ||
break; | ||
case AlertState.working: | ||
lastStateConfig.name = 'exclamation'; | ||
lastStateConfig.label = t(`${AlertState.working}`); | ||
lastStateConfig.name = 'running'; | ||
lastStateConfig.label = isReportEnabled | ||
? t('Report Sending') | ||
: t('Alert Running'); | ||
lastStateConfig.status = AlertState.working; | ||
break; | ||
case AlertState.error: | ||
lastStateConfig.name = 'x-small'; | ||
lastStateConfig.label = t(`${AlertState.error}`); | ||
lastStateConfig.label = isReportEnabled | ||
? t('Report Failed') | ||
: t('Alert Failed'); | ||
lastStateConfig.status = AlertState.error; | ||
break; | ||
case AlertState.noop: | ||
lastStateConfig.name = 'check'; | ||
lastStateConfig.label = t('Nothing Triggered'); | ||
lastStateConfig.status = AlertState.noop; | ||
break; | ||
case AlertState.grace: | ||
lastStateConfig.name = 'alert-solid-small'; | ||
lastStateConfig.label = t('Alert Triggered, In Grace Period'); | ||
lastStateConfig.status = AlertState.grace; | ||
break; | ||
default: | ||
lastStateConfig.name = 'exclamation'; | ||
lastStateConfig.label = t(`${AlertState.working}`); | ||
lastStateConfig.status = AlertState.working; | ||
lastStateConfig.name = 'check'; | ||
lastStateConfig.label = t('Nothing Triggered'); | ||
lastStateConfig.status = AlertState.noop; | ||
} | ||
return ( | ||
<Tooltip title={lastStateConfig.label} placement="bottom"> | ||
<Tooltip title={lastStateConfig.label} placement="bottomLeft"> | ||
<StatusIcon | ||
name={lastStateConfig.name as IconName} | ||
status={lastStateConfig.status} | ||
isReportEnabled={isReportEnabled} | ||
viewBox={ | ||
lastStateConfig.name === 'alert-solid-small' | ||
? '-6 -6 24 24' | ||
: '0 0 24 24' | ||
Comment on lines
+100
to
+104
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. might be a better way to assign viewBox There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to do this, anyway? The viewbox on that icon is |
||
} | ||
/> | ||
</Tooltip> | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated but we should update other lists where we use
moment
to properly handle timezones