import {useState} from 'react'; import {Link} from 'react-router'; import styled from '@emotion/styled'; import {LocationDescriptor} from 'history'; import {t} from 'sentry/locale'; import space from 'sentry/styles/space'; type Item = { target: LocationDescriptor; value: string; }; interface ArrayLinksProps { items: Item[]; } function ArrayLinks({items}: ArrayLinksProps) { const [expanded, setExpanded] = useState(false); const firstItem = items[0]; return ( {firstItem && } {items.length > 1 && expanded && items .slice(1, items.length) .map(item => )} {items.length > 1 ? ( ) : null} ); } function LinkedItem({item}: {item: Item}) { return ( {item.value} ); } const ArrayContainer = styled('div')<{expanded: boolean}>` display: flex; flex-direction: ${p => (p.expanded ? 'column' : 'row')}; `; const ArrayItem = styled('span')` flex-shrink: 1; display: block; ${p => p.theme.overflowEllipsis}; width: unset; `; const ButtonContainer = styled('div')` white-space: nowrap; & button { background: none; border: 0; outline: none; padding: 0; cursor: pointer; color: ${p => p.theme.blue300}; margin-left: ${space(0.5)}; } `; export {ArrayLinks};