import React from 'react' ; import DocumentSsh from './DocumentSsh' ; import { TestLayout } from './../Console.story' ; import ConsoleCtx from './../consoleContext' ; export const Connected = ( ) => { const ctx = new ConsoleCtx ( ) ; const tty = ctx . createTty ( session ) ; tty . connect = ( ) => null ; ctx . fetchSshSession = ( ) => Promise . resolve ( session ) ; ctx . createTty = ( ) => tty ; return ( < TestLayout ctx = { ctx } > < DocumentSsh doc = { doc } visible = { true } / > < /TestLayout>); } ; export const NotFound = ( ) => { const ctx = new ConsoleCtx ( ) ; const tty = ctx . createTty ( session ) ; tty . connect = ( ) => null ; ctx . fetchSshSession = ( ) => Promise . reject ( new Error ( 'server error' ) ) ; ctx . createTty = ( ) => tty ; const disconnectedDoc = { ... doc , status : 'disconnected' as const , } ; return ( < TestLayout ctx = { ctx } > < DocumentSsh doc = { disconnectedDoc } visible = { true } / > < /TestLayout>); } ; export const ServerError = ( ) => { const ctx = new ConsoleCtx ( ) ; const tty = ctx . createTty ( session ) ; tty . connect = ( ) => null ; ctx . createSshSession = ( ) => Promise . reject ( new Error ( 'server error' ) ) ; ctx . createTty = ( ) => tty ; const noSidDoc = { ... doc , sid : '' , } ; return ( < TestLayout ctx = { ctx } > < DocumentSsh doc = { noSidDoc } visible = { true } / > < /TestLayout>); } ; export default { title : 'Teleport/Console/DocumentSsh' , } ; const doc = { kind : 'terminal' , status : 'connected' , sid : 'sid-value' , clusterId : 'clusterId-value' , serverId : 'serverId-value' , login : 'login-value' , id : 3 , url : 'fd' , created : new Date ( ) , } as const ; const session = { login : '123' , sid : '' , namespace : '' , created : new Date ( ) , durationText : '' , serverId : '' , hostname : '' , clusterId : '' , parties : [ ] , addr : '1.1.1.1:1111' , } ;