debugIdBundleList.tsx 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import styled from '@emotion/styled';
  2. import EmptyMessage from 'sentry/components/emptyMessage';
  3. import Link from 'sentry/components/links/link';
  4. import LoadingIndicator from 'sentry/components/loadingIndicator';
  5. import Panel from 'sentry/components/panels/panel';
  6. import {IconList} from 'sentry/icons';
  7. import {space} from 'sentry/styles/space';
  8. import type {Project} from 'sentry/types/project';
  9. import type {DebugIdBundle} from 'sentry/types/sourceMaps';
  10. import useOrganization from 'sentry/utils/useOrganization';
  11. import {DebugIdBundleDeleteButton} from 'sentry/views/settings/projectSourceMaps/debugIdBundleDeleteButton';
  12. import {DebugIdBundleDetails} from 'sentry/views/settings/projectSourceMaps/debugIdBundleDetails';
  13. interface DebugIdBundleListProps {
  14. emptyMessage: React.ReactNode;
  15. isLoading: boolean;
  16. onDelete: (bundleId: string) => void;
  17. project: Project;
  18. debugIdBundles?: DebugIdBundle[];
  19. }
  20. export function DebugIdBundleList({
  21. isLoading,
  22. debugIdBundles,
  23. emptyMessage,
  24. onDelete,
  25. project,
  26. }: DebugIdBundleListProps) {
  27. const organization = useOrganization();
  28. if (isLoading) {
  29. return <LoadingIndicator />;
  30. }
  31. if (!debugIdBundles || debugIdBundles.length === 0) {
  32. return <EmptyMessage>{emptyMessage}</EmptyMessage>;
  33. }
  34. return (
  35. <List>
  36. {debugIdBundles.map(debugIdBundle => (
  37. <Item key={debugIdBundle.bundleId}>
  38. <ItemHeader>
  39. <ItemTitle
  40. to={`/settings/${organization.slug}/projects/${
  41. project.slug
  42. }/source-maps/artifact-bundles/${encodeURIComponent(
  43. debugIdBundle.bundleId
  44. )}`}
  45. >
  46. <IconList /> {debugIdBundle.bundleId}
  47. </ItemTitle>
  48. <DebugIdBundleDeleteButton
  49. onDelete={() => onDelete(debugIdBundle.bundleId)}
  50. />
  51. </ItemHeader>
  52. <ItemContent>
  53. <DebugIdBundleDetails debugIdBundle={debugIdBundle} />
  54. </ItemContent>
  55. </Item>
  56. ))}
  57. </List>
  58. );
  59. }
  60. const List = styled('div')`
  61. display: grid;
  62. grid-template-columns: 1fr;
  63. gap: ${space(2)};
  64. `;
  65. const Item = styled(Panel)`
  66. margin: 0;
  67. `;
  68. const ItemHeader = styled('div')`
  69. display: flex;
  70. align-items: center;
  71. justify-content: space-between;
  72. font-size: ${p => p.theme.fontSizeMedium};
  73. border-bottom: 1px solid ${p => p.theme.border};
  74. line-height: 1;
  75. padding: ${space(1)} ${space(2)};
  76. `;
  77. const ItemTitle = styled(Link)`
  78. display: flex;
  79. align-items: center;
  80. gap: ${space(1)};
  81. `;
  82. const ItemContent = styled('div')`
  83. padding: ${space(1)} ${space(2)};
  84. `;