Skip to content

Commit

Permalink
fix(alerts): Add back interval select field (#83007)
Browse files Browse the repository at this point in the history
I unintentionally removed the interval select field on metric alerts
when removing the monitor type in
#81218 this PR puts it back

<img width="1077" alt="Screenshot 2025-01-07 at 9 45 10 AM"
src="https://github.com/user-attachments/assets/d249600f-665a-43f3-bcfa-d6f2c567cfdd"
/>

---------

Co-authored-by: Nate Moore <[email protected]>
  • Loading branch information
2 people authored and andrewshie-sentry committed Jan 22, 2025
1 parent e754290 commit 63e33f5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
20 changes: 19 additions & 1 deletion static/app/views/alerts/rules/metric/ruleConditionsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,15 @@ class RuleConditionsForm extends PureComponent<Props, State> {
}

renderInterval() {
const {organization, disabled, alertType, project, isForLlmMetric} = this.props;
const {
organization,
timeWindow,
disabled,
alertType,
project,
isForLlmMetric,
onTimeWindowChange,
} = this.props;

return (
<Fragment>
Expand Down Expand Up @@ -518,6 +526,16 @@ class RuleConditionsForm extends PureComponent<Props, State> {
required
/>
)}
<SelectControl
name="timeWindow"
styles={this.selectControlStyles}
options={this.timeWindowOptions}
isDisabled={disabled}
value={timeWindow}
onChange={({value}) => onTimeWindowChange(value)}
inline={false}
flexibleControlStateSize
/>
</FormRow>
</Fragment>
);
Expand Down
6 changes: 6 additions & 0 deletions static/app/views/alerts/rules/metric/ruleForm.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ describe('Incident Rules Form', () => {
expect(screen.queryByText(permissionAlertText)).not.toBeInTheDocument();
});

it('renders time window', async () => {
createWrapper({rule});

expect(await screen.findByText('1 hour interval')).toBeInTheDocument();
});

it('is enabled with project-level alerts:write', async () => {
organization.access = [];
project.access = ['alerts:write'];
Expand Down

0 comments on commit 63e33f5

Please sign in to comment.