import React from 'react' ; import { createMemoryHistory } from 'history' ; import { Router } from 'react-router' ; import { Flex } from 'design' ; import { ContextProvider , Context } from 'teleport' ; import getFeatures from 'teleport/features' ; import { Main } from './Main' ; import { clusters } from 'teleport/Clusters/fixtures' ; import { nodes } from 'teleport/Nodes/fixtures' ; import { events } from 'teleport/Audit/fixtures' ; import { sessions } from 'teleport/Sessions/fixtures' ; import { apps } from 'teleport/Apps/fixtures' ; import { databases } from 'teleport/Databases/fixtures' ; import { userContext } from './fixtures' ; import { kubes } from 'teleport/Kubes/fixtures' ; import { desktops } from 'teleport/Desktops/fixtures' ; export function OSS ( ) { const state = useMainStory ( ) ; return ( < Flex my = { - 3 } mx = { - 4 } > < ContextProvider ctx = { state . ctx } > < Router history = { state . history } > < Main { ... state } / > < /Router> < /ContextProvider> < /Flex>); } OSS . storyName = 'Main' ; export default { title : 'Teleport/Main' , } ; function useMainStory ( ) { const [ history ] = React . useState ( ( ) => { return createMemoryHistory ( { initialEntries : [ '/web/cluster/one/nodes' ] , } ) ; } ) ; const [ ctx ] = React . useState ( ( ) => { const ctx = new Context ( ) ; ctx . isEnterprise = false ; ctx . auditService . fetchEvents = ( ) => Promise . resolve ( { events , startKey : '' } ) ; ctx . clusterService . fetchClusters = ( ) => Promise . resolve ( clusters ) ; ctx . nodeService . fetchNodes = ( ) => Promise . resolve ( nodes ) ; ctx . sshService . fetchSessions = ( ) => Promise . resolve ( sessions ) ; ctx . appService . fetchApps = ( ) => Promise . resolve ( apps ) ; ctx . kubeService . fetchKubernetes = ( ) => Promise . resolve ( kubes ) ; ctx . databaseService . fetchDatabases = ( ) => Promise . resolve ( databases ) ; ctx . desktopService . fetchDesktops = ( ) => Promise . resolve ( desktops ) ; ctx . storeUser . setState ( userContext ) ; getFeatures ( ) . forEach ( f => f . register ( ctx ) ) ; return ctx ; } ) ; const status = 'success' as const ; const statusText = '' ; return { history , ctx , status , statusText , } ; }