Skip to content

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
scttcper committed Sep 27, 2024
1 parent 01c206f commit 12da6b5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 30 deletions.
38 changes: 17 additions & 21 deletions static/app/components/events/eventAttachments.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {Fragment, useRef, useState} from 'react';
import {Fragment, useState} from 'react';
import styled from '@emotion/styled';

import {
useDeleteEventAttachmentOptimistic,
useFetchEventAttachments,
} from 'sentry/actionCreators/events';
import {Button} from 'sentry/components/button';
import {LinkButton} from 'sentry/components/button';
import EventAttachmentActions from 'sentry/components/events/eventAttachmentActions';
import FileSize from 'sentry/components/fileSize';
import LoadingError from 'sentry/components/loadingError';
Expand All @@ -14,11 +14,13 @@ import {t} from 'sentry/locale';
import type {Event} from 'sentry/types/event';
import type {Group, IssueAttachment} from 'sentry/types/group';
import type {Project} from 'sentry/types/project';
import {useLocation} from 'sentry/utils/useLocation';
import useOrganization from 'sentry/utils/useOrganization';
import {InlineEventAttachment} from 'sentry/views/issueDetails/groupEventAttachments/inlineEventAttachment';
import {useGroupEventAttachmentsDrawer} from 'sentry/views/issueDetails/groupEventAttachments/useGroupEventAttachmentsDrawer';
import {SectionKey} from 'sentry/views/issueDetails/streamline/context';
import {InterimSection} from 'sentry/views/issueDetails/streamline/interimSection';
import {Tab, TabPaths} from 'sentry/views/issueDetails/types';
import {useGroupDetailsRoute} from 'sentry/views/issueDetails/useGroupDetailsRoute';
import {useHasStreamlinedUI} from 'sentry/views/issueDetails/utils';

import EventAttachmentsCrashReportsNotice from './eventAttachmentsCrashReportsNotice';
Expand All @@ -41,24 +43,20 @@ const attachmentPreviewIsOpen = (
return attachmentPreviews[attachment.id] === true;
};

function ViewAllGroupAttachmentsButton({
group,
project,
}: {
group: Group;
project: Project;
}) {
const openButtonRef = useRef<HTMLButtonElement>(null);
const {openAttachmentDrawer} = useGroupEventAttachmentsDrawer({
project,
group,
openButtonRef,
});
function ViewAllGroupAttachmentsButton() {
const {baseUrl} = useGroupDetailsRoute();
const location = useLocation();

return (
<Button ref={openButtonRef} onClick={openAttachmentDrawer} size="xs">
<LinkButton
size="xs"
to={{
pathname: `${baseUrl}${TabPaths[Tab.ATTACHMENTS]}`,
query: location.query,
}}
>
{t('View All Attachments')}
</Button>
</LinkButton>
);
}

Expand Down Expand Up @@ -113,9 +111,7 @@ function EventAttachmentsContent({event, project, group}: EventAttachmentsProps)
type={SectionKey.ATTACHMENTS}
title={title}
actions={
hasStreamlinedUI && project && group ? (
<ViewAllGroupAttachmentsButton group={group} project={project} />
) : null
hasStreamlinedUI && project && group ? <ViewAllGroupAttachmentsButton /> : null
}
>
{crashFileStripped && (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {EventFixture} from 'sentry-fixture/event';
import {GroupFixture} from 'sentry-fixture/group';
import {OrganizationFixture} from 'sentry-fixture/organization';
import {ProjectFixture} from 'sentry-fixture/project';

Expand All @@ -18,7 +17,6 @@ import * as analytics from 'sentry/utils/analytics';
describe('HighlightsDataSection', function () {
const organization = OrganizationFixture();
const project = ProjectFixture();
const group = GroupFixture();
const event = EventFixture({
contexts: TEST_EVENT_CONTEXTS,
tags: TEST_EVENT_TAGS,
Expand Down Expand Up @@ -57,7 +55,6 @@ describe('HighlightsDataSection', function () {
event={event}
project={project}
viewAllRef={{current: null}}
groupId={group.id}
/>,
{organization}
);
Expand Down Expand Up @@ -92,7 +89,7 @@ describe('HighlightsDataSection', function () {
body: {},
});

render(<HighlightsDataSection event={event} project={project} groupId={group.id} />, {
render(<HighlightsDataSection event={event} project={project} />, {
organization,
});
expect(screen.getByText('Event Highlights')).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {EventAttachmentFixture} from 'sentry-fixture/eventAttachment';
import {GroupFixture} from 'sentry-fixture/group';
import {OrganizationFixture} from 'sentry-fixture/organization';
import {ProjectFixture} from 'sentry-fixture/project';

import {act, render, screen} from 'sentry-test/reactTestingLibrary';

Expand All @@ -10,7 +9,6 @@ import {AttachmentsBadge} from './attachmentsBadge';
describe('AttachmentsBadge', () => {
const organization = OrganizationFixture();
const group = GroupFixture();
const project = ProjectFixture();

beforeEach(() => {
MockApiClient.clearMockResponses();
Expand All @@ -22,7 +20,7 @@ describe('AttachmentsBadge', () => {
body: [],
});

const {container} = render(<AttachmentsBadge group={group} project={project} />);
const {container} = render(<AttachmentsBadge group={group} />);

// Wait for requests to finish
await act(tick);
Expand All @@ -35,7 +33,7 @@ describe('AttachmentsBadge', () => {
body: [EventAttachmentFixture()],
});

render(<AttachmentsBadge group={group} project={project} />);
render(<AttachmentsBadge group={group} />);

expect(await screen.findByRole('button', {name: '1 Attachment'})).toBeInTheDocument();
});
Expand All @@ -50,7 +48,7 @@ describe('AttachmentsBadge', () => {
},
});

render(<AttachmentsBadge group={group} project={project} />);
render(<AttachmentsBadge group={group} />);

expect(
await screen.findByRole('button', {name: '50+ Attachments'})
Expand Down

0 comments on commit 12da6b5

Please sign in to comment.