groupEventAttachmentsTableRow.tsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import styled from '@emotion/styled';
  2. import DateTime from 'sentry/components/dateTime';
  3. import AttachmentUrl from 'sentry/components/events/attachmentUrl';
  4. import EventAttachmentActions from 'sentry/components/events/eventAttachmentActions';
  5. import FileSize from 'sentry/components/fileSize';
  6. import Link from 'sentry/components/links/link';
  7. import {t} from 'sentry/locale';
  8. import {IssueAttachment} from 'sentry/types';
  9. import {types} from 'sentry/views/issueDetails/groupEventAttachments/types';
  10. type Props = {
  11. attachment: IssueAttachment;
  12. groupId: string;
  13. isDeleted: boolean;
  14. onDelete: (attachmentId: string) => void;
  15. orgId: string;
  16. projectSlug: string;
  17. };
  18. function GroupEventAttachmentsTableRow({
  19. attachment,
  20. projectSlug,
  21. onDelete,
  22. isDeleted,
  23. orgId,
  24. groupId,
  25. }: Props) {
  26. return (
  27. <TableRow isDeleted={isDeleted}>
  28. <td>
  29. <h5>
  30. {attachment.name}
  31. <br />
  32. <small>
  33. <DateTime date={attachment.dateCreated} /> &middot;{' '}
  34. <Link
  35. to={`/organizations/${orgId}/issues/${groupId}/events/${attachment.event_id}/`}
  36. >
  37. {attachment.event_id}
  38. </Link>
  39. </small>
  40. </h5>
  41. </td>
  42. <td>{types[attachment.type] || t('Other')}</td>
  43. <td>
  44. <FileSize bytes={attachment.size} />
  45. </td>
  46. <td>
  47. <ActionsWrapper>
  48. <AttachmentUrl
  49. projectSlug={projectSlug}
  50. eventId={attachment.event_id}
  51. attachment={attachment}
  52. >
  53. {url =>
  54. !isDeleted ? (
  55. <EventAttachmentActions
  56. url={url}
  57. onDelete={onDelete}
  58. attachmentId={attachment.id}
  59. />
  60. ) : null
  61. }
  62. </AttachmentUrl>
  63. </ActionsWrapper>
  64. </td>
  65. </TableRow>
  66. );
  67. }
  68. const TableRow = styled('tr')<{isDeleted: boolean}>`
  69. opacity: ${p => (p.isDeleted ? 0.3 : 1)};
  70. td {
  71. text-decoration: ${p => (p.isDeleted ? 'line-through' : 'normal')};
  72. }
  73. `;
  74. const ActionsWrapper = styled('div')`
  75. display: inline-block;
  76. `;
  77. export default GroupEventAttachmentsTableRow;