({ dataSource, onEdit }: DataSourceRowProps)
| 12 | } |
| 13 | |
| 14 | export const DataSourceRow = ({ dataSource, onEdit }: DataSourceRowProps) => { |
| 15 | const features = useGetDatasourceFeatures(dataSource.type); |
| 16 | const [progress, setProgress] = useState<number>(0); |
| 17 | const sync = useSyncDataSource(dataSource.type, dataSource.account, dataSource.container); |
| 18 | const edit = useGetDataSource(dataSource.type, dataSource.account, dataSource.container); |
| 19 | const upload = useUploadDataSource(dataSource.type, dataSource.account, dataSource.container, setProgress); |
| 20 | |
| 21 | return ( |
| 22 | <div className="card p-2 pb-4 w-80 bg-base-100 shadow-xl border-secondary border-2"> |
| 23 | <figure className="p-2"> |
| 24 | <img src={dataSource.imageURL} alt={dataSource.description} /> |
| 25 | </figure> |
| 26 | <div className="card-body"> |
| 27 | <h2 className="card-title"> |
| 28 | {dataSource.name} |
| 29 | <div className="badge badge-accent">{dataSource.type}</div> |
| 30 | </h2> |
| 31 | <p>{dataSource.description}</p> |
| 32 | </div> |
| 33 | {features.sync && ( |
| 34 | <div className="card-actions justify-center"> |
| 35 | <button |
| 36 | aria-label={'edit ' + dataSource.name} |
| 37 | className="btn btn-primary" |
| 38 | onClick={async (e) => { |
| 39 | e.preventDefault(); |
| 40 | onEdit(await edit()); |
| 41 | }} |
| 42 | > |
| 43 | Edit |
| 44 | </button> |
| 45 | <button |
| 46 | aria-label={'upload ' + dataSource.name} |
| 47 | className="btn btn-primary" |
| 48 | onClick={async (e) => { |
| 49 | e.preventDefault(); |
| 50 | upload(); |
| 51 | }} |
| 52 | > |
| 53 | {progress === 0 ? ( |
| 54 | "Upload" |
| 55 | ) : ( |
| 56 | <div className="w-fill h-6 text-center outline outline-1 outline-primary rounded-lg"> |
| 57 | <div className="bg-secondary h-6 rounded-lg" style={{ width: `${String(progress.toFixed(1))}%` }}> |
| 58 | <span className="text-white font-bold">{`${String(progress.toFixed(1))}%`}</span> |
| 59 | </div> |
| 60 | </div> |
| 61 | )} |
| 62 | </button> |
| 63 | <button |
| 64 | aria-label={'sync ' + dataSource.name} |
| 65 | className="btn btn-primary" |
| 66 | onClick={(e) => { |
| 67 | e.preventDefault(); |
| 68 | toast('Syncing the datasource with the storage account', { |
| 69 | icon: '🔄', |
| 70 | className: 'font-bold', |
| 71 | }); |
nothing calls this directly
no test coverage detected