Files
nebula.js/commands/serve/web/components/Hub/SelectEngine/SelectEngine.jsx
Ahmad Mirzaei 68c16b8264 feat: use cached connections hook (#975)
* feat: `useCachedConnections` hook

* feat: automatic detection of opening guid or not
2022-11-01 10:37:20 +01:00

44 lines
1.3 KiB
JavaScript

import React, { useState, useEffect } from 'react';
import { Help } from '@nebula.js/ui/icons';
import IconButton from '@mui/material/IconButton';
import Grid from '@mui/material/Grid';
import Typography from '@mui/material/Typography';
import ConnectionGuid from './ConnectionGuid';
import ConnectionHistory from './ConnectionHistory';
import ConnectionOptions from './ConnectionOptions';
import { ContentWrapper } from '../styles';
import { useRootContext } from '../../../contexts/RootContext';
const SelectEngine = () => {
const { cachedConnectionsData } = useRootContext();
const [showGuid, setShowGuid] = useState(false);
useEffect(() => {
setShowGuid(!cachedConnectionsData.cachedConnections.length);
}, [cachedConnectionsData.cachedConnections.length]);
return (
<ContentWrapper>
<Grid container>
<Grid item xs>
<Typography variant="h5" gutterBottom>
Connect to an engine
</Typography>
</Grid>
<Grid item>
<IconButton onClick={() => setShowGuid(!showGuid)} size="small">
<Help />
</IconButton>
</Grid>
</Grid>
<ConnectionHistory />
<ConnectionOptions />
<ConnectionGuid showGuid={showGuid} />
</ContentWrapper>
);
};
export default SelectEngine;