Skip to content

feat(ui): Fix Incidents list status filters [SEN-687] #13433

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

Merged
merged 1 commit into from
May 29, 2019
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import space from 'app/styles/space';

import Status from '../status';

const DEFAULT_QUERY_STATUS = 'open';
const DEFAULT_QUERY_STATUS = '';

class OrganizationIncidentsBody extends AsyncComponent {
class OrganizationIncidentsList extends AsyncComponent {
getEndpoints() {
const {params, location} = this.props;
return [
Expand Down Expand Up @@ -99,12 +99,13 @@ class OrganizationIncidentsBody extends AsyncComponent {
}
}

class OrganizationIncidents extends React.Component {
class OrganizationIncidentsListContainer extends React.Component {
render() {
const {pathname, query} = this.props.location;

const openIncidentsQuery = omit(query, 'status');
const allIncidentsQuery = {...query, status: ''};
const openIncidentsQuery = {...query, status: 'open'};
const closedIncidentsQuery = {...query, status: 'closed'};
const allIncidentsQuery = omit(query, 'status');

const status = query.status === undefined ? DEFAULT_QUERY_STATUS : query.status;

Expand All @@ -117,6 +118,13 @@ class OrganizationIncidents extends React.Component {
</PageHeading>

<div className="btn-group">
<Button
to={{pathname, query: allIncidentsQuery}}
size="small"
className={'btn' + (status === '' ? ' active' : '')}
>
{t('All Incidents')}
</Button>
<Button
to={{pathname, query: openIncidentsQuery}}
size="small"
Expand All @@ -125,15 +133,15 @@ class OrganizationIncidents extends React.Component {
{t('Open')}
</Button>
<Button
to={{pathname, query: allIncidentsQuery}}
to={{pathname, query: closedIncidentsQuery}}
size="small"
className={'btn' + (status === '' ? ' active' : '')}
className={'btn' + (status === 'closed' ? ' active' : '')}
>
{t('All Incidents')}
{t('Closed')}
</Button>
</div>
</PageHeader>
<OrganizationIncidentsBody {...this.props} />
<OrganizationIncidentsList {...this.props} />
</PageContent>
</DocumentTitle>
);
Expand All @@ -147,4 +155,4 @@ const TableLayout = styled('div')`
width: 100%;
`;

export default OrganizationIncidents;
export default OrganizationIncidentsListContainer;
6 changes: 3 additions & 3 deletions tests/js/spec/views/organizationIncidents/list/index.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('OrganizationIncidentsList', function() {
expect(wrapper.text()).toContain("You don't have any incidents yet");
});

it('toggles all/unresolved', function() {
it('toggles all/open', function() {
const wrapper = mount(
<OrganizationIncidentsList
params={{orgId: 'org-slug'}}
Expand All @@ -73,7 +73,7 @@ describe('OrganizationIncidentsList', function() {
expect.objectContaining({query: {}})
);

wrapper.setProps({location: {query: {status: ''}, search: '?status='}});
wrapper.setProps({location: {query: {status: 'open'}, search: '?status=open'}});

expect(
wrapper
Expand All @@ -87,7 +87,7 @@ describe('OrganizationIncidentsList', function() {

expect(mock).toHaveBeenCalledWith(
'/organizations/org-slug/incidents/',
expect.objectContaining({query: expect.objectContaining({status: ''})})
expect.objectContaining({query: expect.objectContaining({status: 'open'})})
);
});
});