Skip to content

Commit b1402bc

Browse files
authored
Fix build (#322)
* chore: serverless example * fix: build
1 parent 550b3ad commit b1402bc

File tree

5 files changed

+52
-5
lines changed

5 files changed

+52
-5
lines changed

packages/react/src/components/notebook/NotebookAdapter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { getMarked } from './marked/marked';
3131
import { INotebookProps } from './Notebook';
3232
import { NotebookCommands } from './NotebookCommands';
3333

34-
const FALLBACK_NOTEBOOK_PATH = 'ping.ipynb';
34+
const FALLBACK_NOTEBOOK_PATH = '.datalayer/ping.ipynb';
3535

3636
export class NotebookAdapter {
3737

@@ -302,10 +302,10 @@ export class NotebookAdapter {
302302
this._notebookPanel?.update();
303303
});
304304

305-
const isNbFormat = this._path !== undefined && this._path !== '' ? false : true;
305+
const isNbFormat = (this._path !== undefined && this._path !== '') ? false : true;
306306

307307
if (isNbFormat) {
308-
// Fixes if nbformat is provided and we don't want to interact with the content manager.
308+
// If nbformat is provided and we don't want to interact with the content manager.
309309
(this._context as any).initialize = async (isNew: boolean): Promise<void> => {
310310
(this._context as Context<INotebookModel>).model.dirty = false;
311311
const now = new Date().toISOString();
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2021-2023 Datalayer, Inc.
3+
*
4+
* MIT License
5+
*/
6+
7+
import { useState } from 'react';
8+
import { createRoot } from 'react-dom/client';
9+
import { Box } from '@primer/react';
10+
import { INotebookContent } from '@jupyterlab/nbformat';
11+
import { JupyterReactTheme } from '../theme';
12+
import { ServiceManagerLess } from '../jupyter';
13+
import { Notebook } from '../components/notebook/Notebook';
14+
import { NotebookToolbar } from './../components/notebook/toolbar/NotebookToolbar';
15+
import { CellSidebar } from '../components/notebook/cell/sidebar/CellSidebar';
16+
17+
import nbformat from './notebooks/NotebookExample1.ipynb.json';
18+
19+
const NotebookLess = () => {
20+
const [serviceManager, _] = useState(new ServiceManagerLess());
21+
return (
22+
<JupyterReactTheme>
23+
<Box as="h1">A Jupyter Notebook with a Less Service Manager</Box>
24+
<Notebook
25+
serverless={true}
26+
nbformat={nbformat as INotebookContent}
27+
id="notebook-less-id"
28+
height="calc(100vh - 2.6rem)" // (Height - Toolbar Height).
29+
cellSidebarMargin={120}
30+
readonly={true}
31+
serviceManager={serviceManager}
32+
CellSidebar={CellSidebar}
33+
Toolbar={NotebookToolbar}
34+
/>
35+
</JupyterReactTheme>
36+
)
37+
};
38+
39+
const div = document.createElement('div');
40+
document.body.appendChild(div);
41+
const root = createRoot(div);
42+
43+
root.render(<NotebookLess />);

packages/react/src/examples/NotebookServiceManager.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const NotebookServiceManager = () => {
2828
setReadonly(false);
2929
const serverSettings = createServerSettings(getJupyterServerUrl(), getJupyterServerToken());
3030
const serviceManager = new ServiceManager({ serverSettings });
31-
setServiceManager(serviceManager);
31+
setServiceManager(serviceManager as any);
3232
} else {
3333
setServerless(true);
3434
setReadonly(true);

packages/react/src/jupyter/services/ServiceManagerLess.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,9 @@ export class ServiceManagerLess implements ServiceManager.IManager {
405405
this.nbconvert = new NbConvertManagerLess(this.serverSettings) as unknown as NbConvert.IManager;
406406
}
407407
dispose(): void {}
408+
get_name = () => {
409+
return this.__NAME__;
410+
}
408411
}
409412

410413
export default ServiceManagerLess;

packages/react/webpack.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ const ENTRY =
4747
// './src/examples/NotebookKernelChange';
4848
// './src/examples/NotebookLite';
4949
// './src/examples/NotebookLiteContext';
50-
'./src/examples/NotebookMutations';
50+
'./src/examples/NotebookLess';
51+
// './src/examples/NotebookMutations';
5152
// './src/examples/NotebookNbformat';
5253
// './src/examples/NotebookNbformatChange';
5354
// './src/examples/NotebookNoContext';

0 commit comments

Comments
 (0)