debugIdBundleList.tsx 2.5 KB

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