Skip to content
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 @@ -84,7 +84,6 @@ describe('GroupEventAttachments', () => {
query: {
screenshot: '1',
environment: [],
statsPeriod: '14d',
},
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ export function GroupEventAttachments({project, group}: GroupEventAttachmentsPro

const {mutate: deleteAttachment} = useDeleteGroupEventAttachment();

const hasSetStatsPeriod =
location.query.statsPeriod || location.query.start || location.query.end;

const handleDelete = (attachment: IssueAttachment) => {
deleteAttachment({
attachment,
Expand All @@ -83,10 +86,12 @@ export function GroupEventAttachments({project, group}: GroupEventAttachmentsPro
orgSlug: organization.slug,
cursor: location.query.cursor as string | undefined,
environment: eventView.environment as string[],
start: eventView.start,
end: eventView.end,
statsPeriod: eventView.statsPeriod,
eventQuery,
...(hasSetStatsPeriod && {
start: eventView.start,
end: eventView.end,
statsPeriod: eventView.statsPeriod,
}),
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ interface UseGroupEventAttachmentsOptions {
group: Group;
options?: {
/**
* If true, the query will fetch all available attachments for the group, ignoring the
* current filters (for environment, date, query, etc).
* If true, fetches all attachments for the group without applying any
* filters (environment, date range, query). Used by the header badge to
* determine whether the issue has any attachments at all.
*/
fetchAllAvailable?: boolean;
placeholderData?: typeof keepPreviousData;
Expand Down Expand Up @@ -116,21 +117,26 @@ export function useGroupEventAttachments({

const hasSetStatsPeriod =
location.query.statsPeriod || location.query.start || location.query.end;
const fetchAllAvailable = options?.fetchAllAvailable;

const filterParams = options?.fetchAllAvailable
? {}
: {
environment: eventView.environment as string[],
eventQuery,
...(hasSetStatsPeriod && {
start: eventView.start,
end: eventView.end,
statsPeriod: eventView.statsPeriod,
}),
};

const {data, isPending, isError, refetch} = useQuery({
...fetchGroupEventAttachmentsApiOptions({
activeAttachmentsTab,
group,
orgSlug: organization.slug,
cursor: location.query.cursor as string | undefined,
// We only want to filter by date/query/environment if we're using the Streamlined UI
environment: fetchAllAvailable ? undefined : (eventView.environment as string[]),
start: fetchAllAvailable && !hasSetStatsPeriod ? undefined : eventView.start,
end: fetchAllAvailable && !hasSetStatsPeriod ? undefined : eventView.end,
statsPeriod:
fetchAllAvailable && !hasSetStatsPeriod ? undefined : eventView.statsPeriod,
eventQuery: fetchAllAvailable ? undefined : eventQuery,
...filterParams,
}),
placeholderData: options?.placeholderData,
select: selectJsonWithHeaders,
Expand Down
Loading