groupEventAttachmentsTableRow.tsx 2.0 KB

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