-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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: Add Activated Alert Rules to alert rule index #69124
Conversation
Bundle ReportChanges will increase total bundle size by 10.23kB ⬆️
|
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.
Left comments mostly focusing on the net new components.. i really recommend adding tests for the net new components as well. Maybe these could be built in a way that we could utilize the code with upcoming refactors as well?
); | ||
} | ||
|
||
function renderAlertRuleStatus(): React.ReactNode { |
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.
I'd recommend decomposing this quite a bit.. you could really simplify this by pulling the alert status out as a different component.. then applying SOLID programming principles split this into it's most basic pieces.. each alert threshold state. Then have the AlertRuleStatus simply look at the state and decide which component to render. That would simplify the UI components, decouple your logic from presentation, and simplify testing.
{!projectsLoaded && ( | ||
<LoadingIndicator | ||
mini | ||
style={{height: '24px', margin: 0, marginRight: 11}} |
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.
nit: make this a styled component, looks like the LoadingIndicator
will take a class name and apply it correctly.
<AlertName> | ||
<div>{rule.name}</div> | ||
</AlertName> |
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.
The inner div isn't needed here
<AlertName> | |
<div>{rule.name}</div> | |
</AlertName> | |
<AlertName>{rule.name}</AlertName> |
const MenuItemWrapper = styled('div')` | ||
display: flex; | ||
align-items: center; | ||
font-size: 13px; |
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.
Rather than hard coding it, we should use something from the theme.. there's fontSizeSmall
which is 12px and feels like it maps to the intent of this a little more. If you have to keep it 13px, there's codeFontSize
which also maps, but doesn't make as much sense from the naming perspective.
font-size: 13px; | |
font-size: ${p.theme.codeFontSize}; |
`; | ||
|
||
const Label = styled(TextOverflow)` | ||
margin-left: 6px; |
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.
margin-left: 6px; | |
margin-left: $(space(0.75)}; |
width: 24px; | ||
height: 24px; |
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.
width: 24px; | |
height: 24px; | |
width: ${p.theme.iconSizes.lg}; | |
height: ${p.theme.iconSizes.lg}; |
const FlexCenter = styled('div')` | ||
display: flex; | ||
align-items: center; | ||
`; | ||
|
||
const IssueAlertStatusWrapper = styled('div')` | ||
display: flex; | ||
align-items: center; | ||
gap: ${space(1)}; | ||
line-height: 2; | ||
`; | ||
|
||
const AlertNameWrapper = styled('div')<{isIssueAlert?: boolean}>` | ||
${p => p.theme.overflowEllipsis} | ||
display: flex; | ||
align-items: center; | ||
gap: ${space(2)}; | ||
${p => p.isIssueAlert && `padding: ${space(3)} ${space(2)}; line-height: 2.4;`} | ||
`; |
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.
Might be nice to use static/app/components/profiling/flex.tsx
and FlexContainer
where you can here. I think you can cover most of the flex cases you have defined with that component. By reusing the component, it would likely cut down pretty substantially on the css payload of this component.
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.
🤔
hmmm since most of this is just copy/pasta from the sister rules.tsx, i'm less inclined to rewrite the entire component
I can leave a note to come back to this though
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.
sounds good - this pattern also already exists in the code so nbd.
[rule] | ||
); | ||
|
||
function renderLatestActivation(): React.ReactNode { |
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.
Nit: recommend decomposing each of the render calls. If you're accessing things like the rule
it'd be extra cool to use react-query
to avoid prop drilling too.
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.
hmmm how does react-query addres prop drilling?
Or did you mean context?
for now i think i'll keep these patterns to match rules.tsx
😅
I'll create a follow up ticket to clean both of these up though
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.
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.
react-query uses context to store api data for you. (it also handles automatic updates and syncing data across all uses of the "store").
for example, if you wanted to fetch a specific rule
you could do useRule(ruleId)
-- then that hook uses the api react-query hook to fetch the data (which updates the value in the store for rule etc).
If you haven't used it before.. it's kinda a mind meld and we should def wait until later to update. i'm planning on using it for the API requests with project settings pages, so we could also take a look at it when that comes up.
ea16b2a
to
a2458bb
Compare
type: CombinedAlertType.METRIC; | ||
latestIncident?: Incident | null; |
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.
why remove latestIncident? This property is returned when passing the latestIncident expand parameter https://github.com/getsentry/sentry/blob/master/static/app/views/alerts/list/rules/alertRulesList.tsx#L49 I assume the only reason this passes is because IssueAlert has latestIncident too which is probably not correct
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.
oh i see its available on MetricRule
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.
hmm that's probably wrong too lol
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.
Ah - no it's because the MetricRule that this is extending already includes the latestIncident
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.
If you can, i'd try to add some tests for activatedRuleRow.tsx
since that's a net new component. if possible, i think decomposing that class would be good follow up work.
[rule] | ||
); | ||
|
||
function renderLatestActivation(): React.ReactNode { |
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.
react-query uses context to store api data for you. (it also handles automatic updates and syncing data across all uses of the "store").
for example, if you wanted to fetch a specific rule
you could do useRule(ruleId)
-- then that hook uses the api react-query hook to fetch the data (which updates the value in the store for rule etc).
If you haven't used it before.. it's kinda a mind meld and we should def wait until later to update. i'm planning on using it for the API requests with project settings pages, so we could also take a look at it when that comes up.
const FlexCenter = styled('div')` | ||
display: flex; | ||
align-items: center; | ||
`; | ||
|
||
const IssueAlertStatusWrapper = styled('div')` | ||
display: flex; | ||
align-items: center; | ||
gap: ${space(1)}; | ||
line-height: 2; | ||
`; | ||
|
||
const AlertNameWrapper = styled('div')<{isIssueAlert?: boolean}>` | ||
${p => p.theme.overflowEllipsis} | ||
display: flex; | ||
align-items: center; | ||
gap: ${space(2)}; | ||
${p => p.isIssueAlert && `padding: ${space(3)} ${space(2)}; line-height: 2.4;`} | ||
`; |
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.
sounds good - this pattern also already exists in the code so nbd.
4287e0d
to
09c8c78
Compare
Duplicates the AlertRuleRow component to enable Activated Alert Rule rows.
Moves Alert Badge next to the rule status
Introduces a new "active state" to determine whether we are "ready to monitor" or "actively monitoring" states
cleans up the status logic