import { action } from 'storybook/actions'; import React from 'react'; import { AttachmentProvider, AttachmentTable, } from '../src/lib/organisms/attachments/AttachmentTable'; import { Box } from '../src/lib/next'; import { useTheme } from 'styled-components'; import { MemoryRouter } from 'react-router'; import { Icon } from '../src/lib'; import { AttachmentConfirmationModal } from '../src/lib/organisms/attachments/AttachmentConfirmationModal'; import { AttachmentAction, AttachmentOperation, } from '../src/lib/organisms/attachments/AttachmentTypes'; export default { title: 'Components/AttachmentTable', component: AttachmentTable, }; export const Playground = { render: () => { const theme = useTheme(); return ( { console.log('changed'); }} /> ); }, }; export const FailToLoad = { render: () => { const theme = useTheme(); return ( { console.log('changed'); }} /> ); }, }; const ConfirmationEntityIcon = ({ type }: { type: string }) => ( {type} ); export const ConfirmationModal = { render: () => { const theme = useTheme(); // Enough rows to exceed the modal body height: the table must scroll // internally, the modal itself must not gain a scrollbar. const attachmentOperations: AttachmentOperation[] = Array.from( { length: 24 }, (_, index) => ({ action: index % 4 === 0 ? AttachmentAction.REMOVE : AttachmentAction.ADD, entity: { name: `bucket-${String(index + 1).padStart(2, '0')}`, id: `id-${index + 1}`, type: 'Bucket', }, }), ); return (

Click “Save” to open the attachment confirmation modal.

({ mutationFn: () => new Promise((resolve) => setTimeout(resolve, 800)), })} resourceType="storage-account" resourceName="my-storage-account" redirectUrl="/" EntityIcon={ConfirmationEntityIcon} />
); }, };