import React from 'react' ; import { FileTransfer } from './FileTransfer' ; import { ScpContext } from './scpContextProvider' ; import { Scp } from './scpContext' ; import { Uploader , Downloader } from 'teleport/Console/services/fileTransfer' ; export default { title : 'Teleport/Console/FileTransfer' , } ; const props = { onClose : ( ) => null , } ; export const DownloadError = ( ) => { const context = makeContext ( { ... defaultFile , status : 'error' , error : 'stat /root/test: no such file or directory' , } ) ; return ( < ScpContext . Provider value = { context } > < FileTransfer { ... props } isDownloadOpen = { true } / > < /ScpContext.Provider>); } ; export const DownloadProgress = ( ) => { const context = makeContext ( { ... defaultFile , status : 'processing' , } ) ; return ( < ScpContext . Provider value = { context } > < FileTransfer { ... props } isDownloadOpen = { true } / > < /ScpContext.Provider>); } ; export const DownloadCompleted = ( ) => { const context = makeContext ( { ... defaultFile , status : 'completed' , } ) ; return ( < ScpContext . Provider value = { context } > < FileTransfer { ... props } isDownloadOpen = { true } / > < /ScpContext.Provider>); } ; export const Upload = ( ) => { const context = makeContext ( { ... defaultFile , status : 'completed' , fileName : 'test' , } ) ; return ( < ScpContext . Provider value = { context } > < FileTransfer { ... props } isUploadOpen = { true } / > < /ScpContext.Provider>); } ; function makeContext ( file ) { const context = new Scp ( { } as any ) ; context . updateFile = ( ) => null ; context . store . state . files = [ file ] ; context . createUploader = ( ) => { const uploader = new Uploader ( ) ; uploader . do = ( ) => null ; return uploader ; } ; context . createDownloader = ( ) => { const downloader = new Downloader ( ) ; downloader . do = ( ) => null ; return downloader ; } ; return context ; } const defaultFile = { location : '~test' , id : '1547581437406~/test' , url : '/v1/webapi/sites/one/nodes/' , name : '~/test~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf~/mamaffsdfsdfdssdf' , blob : [ ] , } ;