Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions static/app/views/alerts/rules/details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import {Location} from 'history';
import moment from 'moment';

import {fetchOrgMembers} from 'app/actionCreators/members';
import {Client} from 'app/api';
import {Client, ResponseMeta} from 'app/api';
import Alert from 'app/components/alert';
import DateTime from 'app/components/dateTime';
import {IconWarning} from 'app/icons';
import {t} from 'app/locale';
import {PageContent} from 'app/styles/organization';
import {DateString, Organization} from 'app/types';
import {trackAnalyticsEvent} from 'app/utils/analytics';
import {getUtcDateString} from 'app/utils/dates';
Expand All @@ -30,13 +33,14 @@ type Props = {
type State = {
isLoading: boolean;
hasError: boolean;
error: ResponseMeta | null;
rule?: IncidentRule;
incidents?: Incident[];
selectedIncident?: Incident | null;
};

class AlertRuleDetails extends Component<Props, State> {
state: State = {isLoading: false, hasError: false};
state: State = {isLoading: false, hasError: false, error: null};

componentDidMount() {
const {api, params} = this.props;
Expand Down Expand Up @@ -158,8 +162,8 @@ class AlertRuleDetails extends Component<Props, State> {
this.setState({incidents});

this.setState({isLoading: false, hasError: false});
} catch (_err) {
this.setState({isLoading: false, hasError: true});
} catch (error) {
this.setState({isLoading: false, hasError: true, error});
}
};

Expand All @@ -183,11 +187,29 @@ class AlertRuleDetails extends Component<Props, State> {
});
};

renderError() {
const {error} = this.state;

return (
<PageContent>
<Alert type="error" icon={<IconWarning />}>
{error?.status === 404
? t('This alert rule could not be found.')
: t('An error occurred while fetching the alert rule.')}
</Alert>
</PageContent>
);
}

render() {
const {rule, incidents, hasError, selectedIncident} = this.state;
const {params} = this.props;
const timePeriod = this.getTimePeriod();

if (hasError) {
return this.renderError();
}

return (
<Fragment>
<DetailsHeader
Expand Down