-
Notifications
You must be signed in to change notification settings - Fork 49
/
voila.tsx
37 lines (31 loc) · 847 Bytes
/
voila.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { ReactWidget, ToolbarButtonComponent } from '@jupyterlab/apputils';
import { PageConfig } from '@jupyterlab/coreutils';
import * as React from 'react';
/**
* A toolbar widget to launch Voila.
*/
export default class Voila extends ReactWidget {
constructor(path: string) {
super();
this._path = path;
}
render(): JSX.Element {
const onClick = (): void => {
const baseUrl = PageConfig.getBaseUrl();
const conf = '?voila-template=gridstack';
const win = window.open(
`${baseUrl}voila/render/${this._path + conf}`,
'_blank'
);
win?.focus();
};
return (
<ToolbarButtonComponent
iconClass="jp-MaterialIcon jp-VoilaIcon"
onClick={onClick}
tooltip={'Open with Voilà in a New Browser Tab'}
/>
);
}
private _path: string;
}