Skip to content

ref(issue-views): Add visibility and pagination params to issue views hook #88041

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
Mar 27, 2025
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
9 changes: 8 additions & 1 deletion static/app/components/nav/issueViews/issueViewNavItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import type {IssueView} from 'sentry/views/issueList/issueViews/issueViews';
import {generateTempViewId} from 'sentry/views/issueList/issueViews/issueViews';
import {useUpdateGroupSearchViews} from 'sentry/views/issueList/mutations/useUpdateGroupSearchViews';
import {makeFetchGroupSearchViewsKey} from 'sentry/views/issueList/queries/useFetchGroupSearchViews';
import type {GroupSearchView} from 'sentry/views/issueList/types';
import {
type GroupSearchView,
GroupSearchViewVisibility,
} from 'sentry/views/issueList/types';

interface IssueViewNavItemsProps {
baseUrl: string;
Expand Down Expand Up @@ -201,6 +204,8 @@ export function IssueViewNavItems({
...v,
isAllProjects: isEqual(v.projects, [-1]),
name: v.label,
lastVisited: null,
visibility: GroupSearchViewVisibility.OWNER,
}))
);
},
Expand Down Expand Up @@ -242,6 +247,8 @@ export function IssueViewNavItems({
...v,
isAllProjects: isEqual(v.projects, [-1]),
name: v.label,
lastVisited: null,
visibility: GroupSearchViewVisibility.OWNER,
}))
);
}
Expand Down
11 changes: 10 additions & 1 deletion static/app/views/issueList/issueViewsHeader.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';

import OrganizationStore from 'sentry/stores/organizationStore';
import IssueViewsIssueListHeader from 'sentry/views/issueList/issueViewsHeader';
import type {GroupSearchView} from 'sentry/views/issueList/types';
import {
type GroupSearchView,
GroupSearchViewVisibility,
} from 'sentry/views/issueList/types';
import {IssueSortOptions} from 'sentry/views/issueList/utils';

describe('IssueViewsHeader', () => {
Expand Down Expand Up @@ -34,6 +37,8 @@ describe('IssueViewsHeader', () => {
start: '2024-01-02',
utc: false,
},
visibility: GroupSearchViewVisibility.OWNER,
lastVisited: null,
},
{
id: '2',
Expand All @@ -48,6 +53,8 @@ describe('IssueViewsHeader', () => {
period: '1d',
utc: null,
},
visibility: GroupSearchViewVisibility.ORGANIZATION,
lastVisited: null,
},
{
id: '3',
Expand All @@ -62,6 +69,8 @@ describe('IssueViewsHeader', () => {
start: '2024-01-02',
utc: true,
},
visibility: GroupSearchViewVisibility.ORGANIZATION,
lastVisited: null,
},
];

Expand Down
30 changes: 24 additions & 6 deletions static/app/views/issueList/queries/useFetchGroupSearchViews.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,39 @@
import type {UseApiQueryOptions} from 'sentry/utils/queryClient';
import type {ApiQueryKey, UseApiQueryOptions} from 'sentry/utils/queryClient';
import {useApiQuery} from 'sentry/utils/queryClient';
import type {GroupSearchView} from 'sentry/views/issueList/types';
import type {
GroupSearchView,
GroupSearchViewVisibility,
} from 'sentry/views/issueList/types';

type FetchGroupSearchViewsParameters = {
orgSlug: string;
cursor?: string;
limit?: number;
visibility?: GroupSearchViewVisibility;
};

export const makeFetchGroupSearchViewsKey = ({
orgSlug,
}: FetchGroupSearchViewsParameters) =>
[`/organizations/${orgSlug}/group-search-views/`] as const;
visibility,
limit,
cursor,
}: FetchGroupSearchViewsParameters): ApiQueryKey =>
[
`/organizations/${orgSlug}/group-search-views/`,
{
query: {
per_page: limit,
visibility,
cursor,
},
},
] as const;

Copy link
Member

Choose a reason for hiding this comment

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

you shouldn't need as const once you have the ApiQueryKey

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
] as const;
];

export const useFetchGroupSearchViews = (
{orgSlug}: FetchGroupSearchViewsParameters,
parameters: FetchGroupSearchViewsParameters,
options: Partial<UseApiQueryOptions<GroupSearchView[]>> = {}
) => {
return useApiQuery<GroupSearchView[]>(makeFetchGroupSearchViewsKey({orgSlug}), {
return useApiQuery<GroupSearchView[]>(makeFetchGroupSearchViewsKey(parameters), {
staleTime: Infinity,
...options,
});
Expand Down
10 changes: 9 additions & 1 deletion static/app/views/issueList/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,25 @@ export type IssueUpdateData =
| MarkReviewed
| GroupStatusResolution;

export enum GroupSearchViewVisibility {
OWNER = 'owner',
ORGANIZATION = 'organization',
}

export type GroupSearchView = {
environments: string[];
id: string;
lastVisited: string | null;
name: string;
projects: number[];
query: string;
querySort: IssueSortOptions;
timeFilters: PageFilters['datetime'];
visibility: GroupSearchViewVisibility;
};

export interface UpdateGroupSearchViewPayload extends Omit<GroupSearchView, 'id'> {
export interface UpdateGroupSearchViewPayload
extends Omit<GroupSearchView, 'id' | 'lastVisited' | 'visibility'> {
environments: string[];
projects: number[];
timeFilters: PageFilters['datetime'];
Expand Down
Loading