@@ -3,7 +3,8 @@ ipywidgets rendering using @cocalc/widgets
3
3
*/
4
4
5
5
import { useEffect , useRef , useState } from "react" ;
6
- import { Alert } from "antd" ;
6
+ import { Icon } from "@cocalc/frontend/components/icon" ;
7
+ import { Alert , Button } from "antd" ;
7
8
import type { JupyterActions } from "../browser-actions" ;
8
9
import { Map } from "immutable" ;
9
10
require ( "@jupyter-widgets/controls/css/widgets.css" ) ;
@@ -26,9 +27,10 @@ interface WidgetProps {
26
27
actions ?: JupyterActions ;
27
28
directory ?: string ;
28
29
trust ?: boolean ;
30
+ id ?: string ;
29
31
}
30
32
31
- export function IpyWidget ( { value, actions } : WidgetProps ) {
33
+ export function IpyWidget ( { id : cell_id , value, actions } : WidgetProps ) {
32
34
// console.log("IpyWidget", { value: value.toJS(), actions });
33
35
const [ unknown , setUnknown ] = useState < boolean > ( false ) ;
34
36
const divRef = useRef < any > ( null ) ;
@@ -65,12 +67,27 @@ export function IpyWidget({ value, actions }: WidgetProps) {
65
67
} , [ ] ) ;
66
68
67
69
if ( unknown ) {
70
+ const msg = "Run cell to load widget." ;
68
71
return (
69
72
< Alert
70
73
showIcon
71
74
style = { { margin : "15px" } }
72
75
type = "warning"
73
- message = "Run this cell to load this widget."
76
+ message = {
77
+ actions != null && cell_id ? (
78
+ < Button
79
+ type = "link"
80
+ onClick = { ( ) => {
81
+ console . log ( "hi" , cell_id ) ;
82
+ actions . run_cell ( cell_id ) ;
83
+ } }
84
+ >
85
+ < Icon name = "step-forward" /> { msg }
86
+ </ Button >
87
+ ) : (
88
+ < span > { msg } </ span >
89
+ )
90
+ }
74
91
/>
75
92
) ;
76
93
}
0 commit comments