import { AnimateSlideDown, Dropdown, DropdownItem, DropdownSeparator, IconAlertCircle, IconArrowUpRight, IconImage, IconLoading, location, MeatballMenu, SubtleButton, SubtleButtonLink, Tooltip } from "@heydovetail/ui-components"; import React from "react"; import { styled } from "typestyle-react"; import { AttachmentService } from "../../AttachmentService"; import { Attachment } from "../../util/attrs"; import { humanAttachmentTitle } from "../../util/text"; import { AttachmentDownloadUrlSubscribe } from "./AttachmentDownloadUrlSubscribe"; import { AttachmentInfoDropdown } from "./AttachmentInfoDropdown"; export function ToolbarItems(props: { attachment: Attachment; attachmentService: AttachmentService; hasPreview: boolean; onRemove: () => void; onHidePreview?: () => void; onShowPreview?: () => void; }) { const { name, hidePreview, type } = props.attachment; const icon = type !== undefined ? iconForType(type) : null; return ( <>
{icon !== null ? {icon} : null} {humanAttachmentTitle(name)}
{(attachmentDownloadUrl): React.ReactElement<{}> => { switch (attachmentDownloadUrl.type) { case "refreshing": case "pending": return ( {}}> ); case "unavailable": return ( {}}> ); case "available": return ( ); } }} {({ dismiss, push }) => ( {props.hasPreview ? ( hidePreview ? ( ) : ( ) ) : null} push( ) } /> )} ); } const Details = styled("div", { alignItems: "center", display: "flex", flexGrow: 1, // When used in an attachment card, and the user drags when a mouse, this // prevents the dragged preview from being just the name or icon, and instead // causes the drag to happen on the card container, which means the entire // card is rendered in a dragged preview. pointerEvents: "none" }); const Name = styled("div", { fontSize: "14px", fontWeight: 600 }); const Icon = styled("div", { marginRight: "12px" }); function iconForType(type: string): React.ReactElement<{}> | null { if (type.match(/^image\//) !== null) { return ; } return null; }