123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- import {Fragment, useMemo, useState} from 'react';
- import styled from '@emotion/styled';
- import {Button} from 'sentry/components/button';
- import {DateTime} from 'sentry/components/dateTime';
- import KeyValueList from 'sentry/components/events/interfaces/keyValueList';
- import Link from 'sentry/components/links/link';
- import {t} from 'sentry/locale';
- import type {KeyValueListData} from 'sentry/types/group';
- import type {DebugIdBundle, DebugIdBundleArtifact} from 'sentry/types/sourceMaps';
- import useOrganization from 'sentry/utils/useOrganization';
- const formatDist = (dist: string | string[] | null) => {
- if (Array.isArray(dist)) {
- return dist.join(', ');
- }
- if (dist === null) {
- return 'none';
- }
- return dist;
- };
- export function DebugIdBundleDetails({
- debugIdBundle,
- }: {
- debugIdBundle: DebugIdBundle | DebugIdBundleArtifact;
- }) {
- const [showAll, setShowAll] = useState(false);
- const organization = useOrganization();
- const detailsData = useMemo<KeyValueListData>(() => {
- const associations = debugIdBundle.associations;
- const visibleAssociations = showAll ? associations : associations.slice(0, 3);
- return [
- {
- key: 'count',
- subject: t('Artifacts'),
- value: debugIdBundle.fileCount,
- },
- {
- key: 'releases',
- subject: t('Associated Releases'),
- actionButton: associations.length > 3 && (
- <Button size="xs" onClick={() => setShowAll(value => !value)}>
- {showAll ? t('Show Less') : t('Show All')}
- </Button>
- ),
- value:
- associations.length > 0 ? (
- <ReleasesWrapper className="val-string-multiline">
- {visibleAssociations.map(association => (
- <Fragment key={association.release}>
- <Link
- to={`/organizations/${organization.slug}/releases/${association.release}/`}
- >
- {association.release}
- </Link>
- {` (Dist: ${formatDist(association.dist)})`}
- <br />
- </Fragment>
- ))}
- </ReleasesWrapper>
- ) : (
- t('No releases associated with this bundle')
- ),
- },
- {
- key: 'date',
- subject: t('Date Uploaded'),
- value: (
- <pre>
- <DateTime timeZone year date={debugIdBundle.date} />
- </pre>
- ),
- },
- ];
- }, [debugIdBundle, organization.slug, showAll]);
- return <StyledKeyValueList data={detailsData} shouldSort={false} />;
- }
- const ReleasesWrapper = styled('pre')`
- max-height: 200px;
- overflow-y: auto !important;
- `;
- const StyledKeyValueList = styled(KeyValueList)`
- && {
- margin-bottom: 0;
- }
- `;
|