sourceMapsArchiveRow.tsx 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import Access from 'sentry/components/acl/access';
  4. import Button from 'sentry/components/button';
  5. import ButtonBar from 'sentry/components/buttonBar';
  6. import Confirm from 'sentry/components/confirm';
  7. import Count from 'sentry/components/count';
  8. import DateTime from 'sentry/components/dateTime';
  9. import Link from 'sentry/components/links/link';
  10. import TextOverflow from 'sentry/components/textOverflow';
  11. import Tooltip from 'sentry/components/tooltip';
  12. import Version from 'sentry/components/version';
  13. import {IconDelete} from 'sentry/icons';
  14. import {t} from 'sentry/locale';
  15. import space from 'sentry/styles/space';
  16. import {SourceMapsArchive} from 'sentry/types';
  17. type Props = {
  18. archive: SourceMapsArchive;
  19. onDelete: (name: string) => void;
  20. orgId: string;
  21. projectId: string;
  22. };
  23. const SourceMapsArchiveRow = ({archive, orgId, projectId, onDelete}: Props) => {
  24. const {name, date, fileCount} = archive;
  25. const archiveLink = `/settings/${orgId}/projects/${projectId}/source-maps/${encodeURIComponent(
  26. name
  27. )}`;
  28. return (
  29. <Fragment>
  30. <Column>
  31. <TextOverflow>
  32. <Link to={archiveLink}>
  33. <Version version={name} anchor={false} tooltipRawVersion truncate />
  34. </Link>
  35. </TextOverflow>
  36. </Column>
  37. <ArtifactsColumn>
  38. <Count value={fileCount} />
  39. </ArtifactsColumn>
  40. <Column>{t('release')}</Column>
  41. <Column>
  42. <DateTime date={date} />
  43. </Column>
  44. <ActionsColumn>
  45. <ButtonBar gap={0.5}>
  46. <Access access={['project:releases']}>
  47. {({hasAccess}) => (
  48. <Tooltip
  49. disabled={hasAccess}
  50. title={t('You do not have permission to delete artifacts.')}
  51. >
  52. <Confirm
  53. onConfirm={() => onDelete(name)}
  54. message={t(
  55. 'Are you sure you want to remove all artifacts in this archive?'
  56. )}
  57. disabled={!hasAccess}
  58. >
  59. <Button
  60. size="sm"
  61. icon={<IconDelete size="sm" />}
  62. title={t('Remove All Artifacts')}
  63. aria-label={t('Remove All Artifacts')}
  64. disabled={!hasAccess}
  65. />
  66. </Confirm>
  67. </Tooltip>
  68. )}
  69. </Access>
  70. </ButtonBar>
  71. </ActionsColumn>
  72. </Fragment>
  73. );
  74. };
  75. const Column = styled('div')`
  76. display: flex;
  77. align-items: center;
  78. overflow: hidden;
  79. `;
  80. const ArtifactsColumn = styled(Column)`
  81. padding-right: ${space(4)};
  82. text-align: right;
  83. justify-content: flex-end;
  84. `;
  85. const ActionsColumn = styled(Column)`
  86. justify-content: flex-end;
  87. `;
  88. export default SourceMapsArchiveRow;