Skip to content

Commit

Permalink
Load in default view by default
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSun48 committed Sep 27, 2024
1 parent c344143 commit 7856c8e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
21 changes: 18 additions & 3 deletions static/app/utils/withSavedSearches.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {SavedSearch} from 'sentry/types/group';
import type {RouteComponentProps} from 'sentry/types/legacyReactRouter';
import useOrganization from 'sentry/utils/useOrganization';
import {useParams} from 'sentry/utils/useParams';
import {useFetchGroupSearchViews} from 'sentry/views/issueList/queries/useFetchGroupSearchViews';
import {useFetchSavedSearchesForOrg} from 'sentry/views/issueList/queries/useFetchSavedSearchesForOrg';
import {useSelectedSavedSearch} from 'sentry/views/issueList/utils/useSelectedSavedSearch';

Expand All @@ -15,6 +16,9 @@ type InjectedSavedSearchesProps = {
/**
* HOC to provide saved search data to class components.
* When possible, use the hooks directly instead.
*
* Note: this HOC will be completely removed when issue views is GA'd, but until then
* we have to augment it to support both saved searches and issue views.
*/
function withSavedSearches<P extends InjectedSavedSearchesProps>(
WrappedComponent: React.ComponentType<P>
Expand All @@ -29,6 +33,12 @@ function withSavedSearches<P extends InjectedSavedSearchesProps>(
},
{enabled: !organization.features.includes('issue-stream-custom-views')}
);
const {data: groupSearchViews, isPending: areViewsPending} = useFetchGroupSearchViews(
{
orgSlug: organization.slug,
},
{enabled: organization.features.includes('issue-stream-custom-views')}
);

const params = useParams();
const selectedSavedSearch = useSelectedSavedSearch();
Expand All @@ -38,10 +48,15 @@ function withSavedSearches<P extends InjectedSavedSearchesProps>(
{...(props as P)}
savedSearches={props.savedSearches ?? savedSearches}
savedSearchLoading={
!organization.features.includes('issue-stream-custom-views') &&
(props.savedSearchLoading ?? isPending)
organization.features.includes('issue-stream-custom-views')
? areViewsPending
: props.savedSearchLoading ?? isPending
}
savedSearch={
organization.features.includes('issue-stream-custom-views') && groupSearchViews
? groupSearchViews[0]
: props.savedSearch ?? selectedSavedSearch
}
savedSearch={props.savedSearch ?? selectedSavedSearch}
selectedSearchId={params.searchId ?? null}
/>
);
Expand Down
5 changes: 1 addition & 4 deletions static/app/views/issueList/overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,7 @@ class IssueListOverview extends Component<Props, State> {
savedSearch,
location,
}: Pick<Props, 'savedSearch' | 'location'>): string {
if (
!this.props.organization.features.includes('issue-stream-custom-views') &&
savedSearch
) {
if (savedSearch) {
return savedSearch.query;
}

Expand Down

0 comments on commit 7856c8e

Please sign in to comment.