import {useState} from 'react'; import styled from '@emotion/styled'; import {openModal} from 'sentry/actionCreators/modal'; import {Button} from 'sentry/components/button'; import Card from 'sentry/components/card'; import {openConfirmModal} from 'sentry/components/confirm'; import {DateTime} from 'sentry/components/dateTime'; import {DropdownMenu} from 'sentry/components/dropdownMenu'; import ImageVisualization from 'sentry/components/events/eventTagsAndScreenshot/screenshot/imageVisualization'; import ScreenshotModal, { modalCss, } from 'sentry/components/events/eventTagsAndScreenshot/screenshot/modal'; import {LazyRender} from 'sentry/components/lazyRender'; import Link from 'sentry/components/links/link'; import LoadingIndicator from 'sentry/components/loadingIndicator'; import PanelBody from 'sentry/components/panels/panelBody'; import {Tooltip} from 'sentry/components/tooltip'; import {IconEllipsis} from 'sentry/icons/iconEllipsis'; import {t} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import type {IssueAttachment} from 'sentry/types/group'; import type {Project} from 'sentry/types/project'; import {trackAnalytics} from 'sentry/utils/analytics'; import {getShortEventId} from 'sentry/utils/events'; import useOrganization from 'sentry/utils/useOrganization'; type Props = { attachments: IssueAttachment[]; eventAttachment: IssueAttachment; eventId: string; groupId: string; onDelete: (attachment: IssueAttachment) => void; projectSlug: Project['slug']; }; export function ScreenshotCard({ eventAttachment, attachments, groupId, projectSlug, eventId, onDelete, }: Props) { const organization = useOrganization(); const [loadingImage, setLoadingImage] = useState(true); const downloadUrl = `/api/0/projects/${organization.slug}/${projectSlug}/events/${eventId}/attachments/${eventAttachment.id}/?download=1`; function handleDelete() { trackAnalytics('issue_details.attachment_tab.screenshot_modal_deleted', { organization, }); onDelete(eventAttachment); } function openVisualizationModal() { trackAnalytics('issue_details.attachment_tab.screenshot_modal_opened', { organization, }); openModal( modalProps => ( trackAnalytics('issue_details.attachment_tab.screenshot_modal_download', { organization, }) } /> ), {modalCss} ); } return (
{eventAttachment.name}
·{' '} {getShortEventId(eventAttachment.event_id)}
{ window.open(downloadUrl, '_blank'); }, }, { key: 'delete', label: t('Delete'), onAction: () => { openConfirmModal({ onConfirm: () => onDelete(eventAttachment), message:
{t('Are you sure you want to delete this image?')}
, priority: 'danger', confirmText: t('Delete'), }); }, }, ]} position="bottom-end" trigger={triggerProps => (