|
@@ -14,7 +14,6 @@ import ExternalLink from 'sentry/components/links/externalLink';
|
|
|
import PageFiltersContainer from 'sentry/components/organizations/pageFilters/container';
|
|
|
import Pagination from 'sentry/components/pagination';
|
|
|
import {PanelTable} from 'sentry/components/panels';
|
|
|
-import SearchBar from 'sentry/components/searchBar';
|
|
|
import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
|
|
|
import {IconInfo} from 'sentry/icons';
|
|
|
import {t, tct} from 'sentry/locale';
|
|
@@ -24,8 +23,9 @@ import {trackAnalyticsEvent} from 'sentry/utils/analytics';
|
|
|
import Projects from 'sentry/utils/projects';
|
|
|
import withOrganization from 'sentry/utils/withOrganization';
|
|
|
|
|
|
-import TeamFilter, {getTeamParams} from '../rules/teamFilter';
|
|
|
+import FilterBar from '../filterBar';
|
|
|
import {Incident} from '../types';
|
|
|
+import {getQueryStatus, getTeamParams} from '../utils';
|
|
|
|
|
|
import AlertHeader from './header';
|
|
|
import Onboarding from './onboarding';
|
|
@@ -57,7 +57,7 @@ class IncidentsList extends AsyncComponent<Props, State & AsyncComponent['state'
|
|
|
const {params, location} = this.props;
|
|
|
const {query} = location;
|
|
|
|
|
|
- const status = this.getQueryStatus(query.status);
|
|
|
+ const status = getQueryStatus(query.status);
|
|
|
// Filtering by one status, both does nothing
|
|
|
if (status.length === 1) {
|
|
|
query.status = status;
|
|
@@ -69,18 +69,6 @@ class IncidentsList extends AsyncComponent<Props, State & AsyncComponent['state'
|
|
|
return [['incidentList', `/organizations/${params?.orgId}/incidents/`, {query}]];
|
|
|
}
|
|
|
|
|
|
- getQueryStatus(status: string | string[]): string[] {
|
|
|
- if (Array.isArray(status)) {
|
|
|
- return status;
|
|
|
- }
|
|
|
-
|
|
|
- if (status === '') {
|
|
|
- return [];
|
|
|
- }
|
|
|
-
|
|
|
- return ['open', 'closed'].includes(status) ? [status] : [];
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* If our incidentList is empty, determine if we've configured alert rules or
|
|
|
* if the user has seen the welcome prompt.
|
|
@@ -173,28 +161,6 @@ class IncidentsList extends AsyncComponent<Props, State & AsyncComponent['state'
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- renderFilterBar() {
|
|
|
- const {location} = this.props;
|
|
|
- const selectedTeams = new Set(getTeamParams(location.query.team));
|
|
|
- const selectedStatus = new Set(this.getQueryStatus(location.query.status));
|
|
|
-
|
|
|
- return (
|
|
|
- <FilterWrapper>
|
|
|
- <TeamFilter
|
|
|
- showStatus
|
|
|
- selectedStatus={selectedStatus}
|
|
|
- selectedTeams={selectedTeams}
|
|
|
- handleChangeFilter={this.handleChangeFilter}
|
|
|
- />
|
|
|
- <StyledSearchBar
|
|
|
- placeholder={t('Search by name')}
|
|
|
- query={location.query?.name}
|
|
|
- onSearch={this.handleChangeSearch}
|
|
|
- />
|
|
|
- </FilterWrapper>
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
tryRenderOnboarding() {
|
|
|
const {firstVisitShown} = this.state;
|
|
|
const {organization} = this.props;
|
|
@@ -288,7 +254,7 @@ class IncidentsList extends AsyncComponent<Props, State & AsyncComponent['state'
|
|
|
}
|
|
|
|
|
|
renderBody() {
|
|
|
- const {params, organization, router} = this.props;
|
|
|
+ const {params, organization, router, location} = this.props;
|
|
|
const {orgId} = params;
|
|
|
|
|
|
return (
|
|
@@ -302,7 +268,12 @@ class IncidentsList extends AsyncComponent<Props, State & AsyncComponent['state'
|
|
|
<StyledAlert icon={<IconInfo />}>
|
|
|
{t('This page only shows metric alerts.')}
|
|
|
</StyledAlert>
|
|
|
- {this.renderFilterBar()}
|
|
|
+ <FilterBar
|
|
|
+ location={location}
|
|
|
+ onChangeFilter={this.handleChangeFilter}
|
|
|
+ onChangeSearch={this.handleChangeSearch}
|
|
|
+ hasStatusFilters
|
|
|
+ />
|
|
|
</Fragment>
|
|
|
)}
|
|
|
{this.renderList()}
|
|
@@ -365,16 +336,6 @@ const StyledAlert = styled(Alert)`
|
|
|
margin-bottom: ${space(1.5)};
|
|
|
`;
|
|
|
|
|
|
-const FilterWrapper = styled('div')`
|
|
|
- display: flex;
|
|
|
- margin-bottom: ${space(1.5)};
|
|
|
-`;
|
|
|
-
|
|
|
-const StyledSearchBar = styled(SearchBar)`
|
|
|
- flex-grow: 1;
|
|
|
- margin-left: ${space(1.5)};
|
|
|
-`;
|
|
|
-
|
|
|
const StyledLayoutBody = styled(Layout.Body)`
|
|
|
margin-bottom: -20px;
|
|
|
`;
|