@@ -11,24 +11,21 @@ import { observer } from 'mobx-react-lite'
1111
1212import { Button } from '@postgres.ai/shared/components/Button2'
1313import { StubSpinner } from '@postgres.ai/shared/components/StubSpinner'
14- import { Spinner } from '@postgres.ai/shared/components/Spinner' ;
1514import { SectionTitle } from '@postgres.ai/shared/components/SectionTitle'
1615import { ErrorStub } from '@postgres.ai/shared/components/ErrorStub'
1716
1817import { Tabs } from './Tabs'
18+ import { Logs } from '../Logs'
1919import { Clones } from './Clones'
2020import { Info } from './Info'
21- import { establishConnection } from './wsLogs'
2221import { Configuration } from '../Configuration'
2322import { ClonesModal } from './ClonesModal'
2423import { SnapshotsModal } from './SnapshotsModal'
2524import { Host , HostProvider , StoresProvider } from './context'
2625
27- import PropTypes from "prop-types" ;
28- import Typography from "@material-ui/core/Typography" ;
29- import Box from "@material-ui/core/Box" ;
30- import Alert from '@material-ui/lab/Alert' ;
31- import AlertTitle from '@material-ui/lab/AlertTitle' ;
26+ import PropTypes from 'prop-types'
27+ import Typography from '@material-ui/core/Typography'
28+ import Box from '@material-ui/core/Box'
3229
3330import { useCreatedStores } from './useCreatedStores'
3431
@@ -57,12 +54,6 @@ const useStyles = makeStyles((theme) => ({
5754 flexDirection : 'column' ,
5855 } ,
5956 } ,
60- spinnerContainer : {
61- display : "flex" ,
62- width : "100%" ,
63- alignItems : "center" ,
64- justifyContent : "center"
65- }
6657} ) )
6758
6859export const Instance = observer ( ( props : Props ) => {
@@ -97,16 +88,10 @@ export const Instance = observer((props: Props) => {
9788
9889 const [ activeTab , setActiveTab ] = React . useState ( 0 ) ;
9990
100- const [ isLogConnectionEnabled , enableLogConnection ] = React . useState ( false ) ;
101-
102- const switchTab = ( _ : React . ChangeEvent < { } > , tabID : number ) => {
103- if ( tabID == 1 && api . initWS != undefined && ! isLogConnectionEnabled ) {
104- establishConnection ( api ) . then ( ( ) => {
105- enableLogConnection ( true )
106- } ) ;
107- }
108-
91+ const switchTab = ( _ : React . ChangeEvent < { } | null > , tabID : number ) => {
92+ const contentElement = document . getElementById ( 'content-container' )
10993 setActiveTab ( tabID ) ;
94+ contentElement . scroll ( 0 , 0 )
11095 } ;
11196
11297 return (
@@ -160,25 +145,15 @@ export const Instance = observer((props: Props) => {
160145 </ TabPanel >
161146
162147 < TabPanel value = { activeTab } index = { 1 } >
163- < Alert severity = "info" >
164- < AlertTitle > Sensitive data are masked.</ AlertTitle >
165- You can see the raw log data connecting to the machine and running the < strong > 'docker logs'</ strong > command.
166- </ Alert >
167- < div id = "logs-container" >
168- { ! isLogConnectionEnabled && (
169- < div className = { classes . spinnerContainer } >
170- < Spinner />
171- </ div >
172- ) }
173- </ div >
148+ { activeTab === 1 && < Logs api = { api } /> }
174149 </ TabPanel >
175150 </ >
176151
177152 < TabPanel value = { activeTab } index = { 2 } >
178153 < Configuration
179154 isConfigurationActive = { isConfigurationActive }
180155 allowModifyingConfig = { instance ?. state . engine . allowModifyingConfig }
181- switchActiveTab = { ( id : number ) => setActiveTab ( id ) }
156+ switchActiveTab = { switchTab }
182157 activeTab = { activeTab }
183158 reload = { ( ) => stores . main . load ( props . instanceId ) }
184159 />
0 commit comments