Skip to content

fix(ui) Going to a global saved search from a project based one #12358

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 3 commits into from
Mar 12, 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
21 changes: 8 additions & 13 deletions src/sentry/static/sentry/app/views/organizationStream/overview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ const DEFAULT_QUERY = 'is:unresolved';
const DEFAULT_SORT = 'date';
const DEFAULT_STATS_PERIOD = '24h';
const STATS_PERIODS = new Set(['14d', '24h']);
// TODO: Delete this after testing production counts cc/ @wedamija
const NEW_FILTERS_TEST = 'use_new_filters';

const OrganizationStream = createReactClass({
displayName: 'OrganizationStream',
Expand Down Expand Up @@ -261,12 +259,6 @@ const OrganizationStream = createReactClass({
const currentQuery = this.props.location.query || {};
if ('cursor' in currentQuery) {
requestParams.cursor = currentQuery.cursor;
} else if (NEW_FILTERS_TEST in currentQuery) {
// TODO: Delete this after testing production counts cc/ @wedamija
requestParams[NEW_FILTERS_TEST] = currentQuery[NEW_FILTERS_TEST];
} else if (ConfigStore.get('user').isSuperuser) {
// TODO: Delete this after testing production counts cc/ @wedamija
requestParams[NEW_FILTERS_TEST] = 1;
}

if (this.lastRequest) {
Expand Down Expand Up @@ -462,16 +454,19 @@ const OrganizationStream = createReactClass({
if (savedSearch.projectId) {
query.project = [savedSearch.projectId];
}

// If the saved search is project-less and the user doesn't have
// global-views we retain their current project filter
// so that the backend doesn't reject their request.
const hasMultipleProjectSelection = organization.features.includes('global-views');
if (!savedSearch.projectId && !hasMultipleProjectSelection) {
query.project = this.props.selection.projects;
}
} else {
path = `/organizations/${organization.slug}/issues/`;
}

if (path !== this.props.location.path && !isEqual(query, this.props.location.query)) {
// TODO: Delete/revert this after testing production counts cc/ @wedamija
if (this.props.location.query[NEW_FILTERS_TEST]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be other code that needs to be removed in this file iirc

query[NEW_FILTERS_TEST] = 1;
}

browserHistory.push({
pathname: path,
query,
Expand Down
85 changes: 80 additions & 5 deletions tests/js/spec/views/organizationStream/overview.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const DEFAULT_LINKS_HEADER =
'<http://127.0.0.1:8000/api/0/organizations/org-slug/issues/?cursor=1443575731:0:0>; rel="next"; results="true"; cursor="1443575731:0:0';

describe('OrganizationStream', function() {
let sandbox;
let wrapper;
let props;

Expand All @@ -25,8 +24,6 @@ describe('OrganizationStream', function() {
let fetchMembersRequest;

beforeEach(function() {
sandbox = sinon.sandbox.create();

project = TestStubs.ProjectDetails({
id: '3559',
name: 'Foo Project',
Expand Down Expand Up @@ -81,7 +78,6 @@ describe('OrganizationStream', function() {
body: [TestStubs.Member({projects: [project.slug]})],
});

sandbox.stub(browserHistory, 'push');
TagStore.init();

props = {
Expand All @@ -97,10 +93,89 @@ describe('OrganizationStream', function() {
});

afterEach(function() {
sandbox.restore();
MockApiClient.clearMockResponses();
});

describe('transitionTo', function() {
let instance;
beforeEach(function() {
wrapper = shallow(<OrganizationStream {...props} />);
instance = wrapper.instance();
});

it('transitions to query updates', function() {
instance.transitionTo({query: 'is:ignored'});

expect(browserHistory.push).toHaveBeenCalledWith({
pathname: '/organizations/org-slug/issues/',
query: {
environment: [],
project: [parseInt(project.id, 10)],
query: 'is:ignored',
statsPeriod: '14d',
},
});
});

it('transitions to saved search that has a projectId', function() {
savedSearch = {
id: 123,
projectId: 99,
query: 'foo:bar',
};
instance.setState({savedSearch});
instance.transitionTo();

expect(browserHistory.push).toHaveBeenCalledWith({
pathname: '/organizations/org-slug/issues/searches/123/',
query: {
environment: [],
project: [savedSearch.projectId],
statsPeriod: '14d',
},
});
});

it('goes to all projects when using a basic saved searches and global-views feature', function() {
organization.features = ['global-views'];
savedSearch = {
id: 1,
project: null,
query: 'is:unresolved',
};
instance.setState({savedSearch});
instance.transitionTo();

expect(browserHistory.push).toHaveBeenCalledWith({
pathname: '/organizations/org-slug/issues/searches/1/',
query: {
environment: [],
statsPeriod: '14d',
},
});
});

it('retains project selection when using a basic saved search and no global-views feature', function() {
organization.features = [];
savedSearch = {
id: 1,
projectId: null,
query: 'is:unresolved',
};
instance.setState({savedSearch});
instance.transitionTo();

expect(browserHistory.push).toHaveBeenCalledWith({
pathname: '/organizations/org-slug/issues/searches/1/',
query: {
environment: [],
project: props.selection.projects,
statsPeriod: '14d',
},
});
});
});

describe('getEndpointParams', function() {
beforeEach(function() {
wrapper = shallow(<OrganizationStream {...props} />);
Expand Down