Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional Rendering of Jupyter-React Components #266

Open
Prahmodh-Raj1 opened this issue Jul 12, 2024 · 1 comment
Open

Conditional Rendering of Jupyter-React Components #266

Prahmodh-Raj1 opened this issue Jul 12, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Prahmodh-Raj1
Copy link

Prahmodh-Raj1 commented Jul 12, 2024

Description

I'm trying to Load the Terminal based on Conditional Rendering of the Terminal Component as provided in the code below, but I'm running into an error. On the Toggle of the Switch Component, the Terminal Needs to be rendered.
cc @echarles

Here's the error:
http://127.0.0.1:8888/api/contents/jl310/share/jupyter/lab/staging/node_modules/%40jupyterlab/vega5-extension?1720775773557 net::ERR_INSUFFICIENT_RESOURCES

Please let me know if there is a solution to this issue.

Code:

import IconButton from '@mui/material/IconButton';
import SaveIcon from '@mui/icons-material/Save';
import PlayArrow from '@mui/icons-material/PlayArrow';
import PauseIcon from '@mui/icons-material/Pause';
import AddIcon from '@mui/icons-material/Add';
import AppsIcon from '@mui/icons-material/Apps';
import { Box, Switch } from '@mui/material';

interface CustomToolbarProps {
  switchState: boolean;
  handleSwitchChange: () => void;
}

export default function CustomToolbar({ switchState, handleSwitchChange }: CustomToolbarProps) {
  return (
    <Box
      sx={{
        display: 'flex',
        justifyContent: 'space-around',
        alignItems: 'center',
        backgroundColor: '#f5f5f5',
        padding: '8px',
        borderRadius: '4px',
      }}
    >
      <IconButton onClick={handlePlayClick}>
        <PlayArrow />
      </IconButton>
      <IconButton onClick={handleAddClick}>
        <AddIcon />
      </IconButton>
      <IconButton onClick={handlePauseClick}>
        <PauseIcon />
      </IconButton>
      <Switch checked={switchState} onChange={handleSwitchChange} />
      <IconButton onClick={handleSaveClick}>
        <SaveIcon />
      </IconButton>
      <IconButton onClick={handleAppsClick}>
        <AppsIcon />
      </IconButton>
    </Box>
  );
}

`

const App = () => {
  const [isTerminalOpen, setIsTerminalOpen] = useState(false);

  const handleSwitchChange = () => {
    setIsTerminalOpen((prev) => !prev);
  };

  return (
    <Box>
      <Jupyter startDefaultKernel={true} terminals={true}>
        <CustomToolbar switchState={isTerminalOpen} handleSwitchChange={handleSwitchChange} />
        <FileBrowser />
        <Notebook path='/testnb.ipynb' />
        {console.log(isTerminalOpen)}
        {isTerminalOpen && <Terminal colorMode='light' height='800px' />}
      </Jupyter>
    </Box>
  );
};

@Prahmodh-Raj1 Prahmodh-Raj1 added the bug Something isn't working label Jul 12, 2024
@echarles
Copy link
Member

We have seen exhausted kernels on our cloud infra. Could it be a temporary issue related to that? Would be great if you could retry and confirm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants