Skip to content

Commit 586d8cf

Browse files
cursoragentandeplane
authored andcommitted
feat: Add disabled state and tooltip to notebook analysis
Co-authored-by: andershaf <andershaf@gmail.com>
1 parent ef0d092 commit 586d8cf

2 files changed

Lines changed: 27 additions & 11 deletions

File tree

src/App.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ function getItem(
7373
children?: MenuItem[],
7474
onClick?: () => void,
7575
disabled?: boolean,
76+
title?: string,
7677
): MenuItem {
7778
return {
7879
key,
@@ -81,6 +82,7 @@ function getItem(
8182
label,
8283
onClick,
8384
disabled,
85+
title,
8486
} as MenuItem;
8587
}
8688

@@ -197,7 +199,15 @@ const App: React.FC = () => {
197199
const items: MenuItem[] = [
198200
getItem("View", "view", <AlignLeftOutlined />),
199201
getItem("Console", "console", <BorderOuterOutlined />),
200-
getItem("Notebook", "notebook", <LineChartOutlined />),
202+
getItem(
203+
"Notebook",
204+
"notebook",
205+
<LineChartOutlined />,
206+
undefined,
207+
undefined,
208+
running || paused,
209+
running || paused ? "Can only analyze in Jupyter notebook after simulation has finished" : undefined,
210+
),
201211
getItem(
202212
editMenuLabel,
203213
"edit",

src/containers/Main.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Modal, Tabs, Progress, Button, Layout } from "antd";
1+
import { Modal, Tabs, Progress, Button, Layout, Tooltip } from "antd";
22
import { useState, useEffect, useMemo } from "react";
33
import View from "./View";
44
import Notebook from "./Notebook";
@@ -20,6 +20,7 @@ const Main = ({ isEmbedded }: { isEmbedded: boolean }) => {
2020
);
2121
const selectedMenu = useStoreState((state) => state.app.selectedMenu);
2222
const running = useStoreState((state) => state.simulation.running);
23+
const paused = useStoreState((state) => state.simulation.paused);
2324

2425
const setPreferredView = useStoreActions(
2526
(actions) => actions.app.setPreferredView,
@@ -103,16 +104,21 @@ const Main = ({ isEmbedded }: { isEmbedded: boolean }) => {
103104
width={"80%"}
104105
footer={[
105106
<>
106-
<Button
107-
key="analyze"
108-
onClick={() => {
109-
setShowConsole(false);
110-
setPreferredView(undefined);
111-
setPreferredView("notebook");
112-
}}
107+
<Tooltip
108+
title={running || paused ? "Can only analyze in Jupyter notebook after simulation has finished" : ""}
113109
>
114-
Analyze in notebook
115-
</Button>
110+
<Button
111+
key="analyze"
112+
disabled={running || paused}
113+
onClick={() => {
114+
setShowConsole(false);
115+
setPreferredView(undefined);
116+
setPreferredView("notebook");
117+
}}
118+
>
119+
Analyze in notebook
120+
</Button>
121+
</Tooltip>
116122
<Button key="close" onClick={() => setShowConsole(false)}>
117123
Close
118124
</Button>

0 commit comments

Comments
 (0)