Skip to content

Commit 6b91816

Browse files
committed
fix #7678 -- Too many JupyterLabs/VS Code buttons
1 parent 4780ef5 commit 6b91816

File tree

4 files changed

+44
-105
lines changed

4 files changed

+44
-105
lines changed

src/packages/frontend/compute/compute-server-log.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ More precisely this is a little button that you click on, and
55
it shows the log in a modal.
66
*/
77

8-
import { Modal, Button, Spin, Table } from "antd";
8+
import { Modal, Button, Spin, Table, Tooltip } from "antd";
99
import { useEffect, useState } from "react";
1010
import LogEntry from "./log-entry";
1111
import type { ComputeServerEvent } from "@cocalc/util/compute/log";
@@ -25,7 +25,7 @@ export default function ComputeServerLog({
2525
const [open, setOpen] = useState<boolean>(false);
2626

2727
return (
28-
<>
28+
<Tooltip title={"Show configuration and control log"}>
2929
<Button
3030
size={"small"}
3131
type="text"
@@ -37,7 +37,7 @@ export default function ComputeServerLog({
3737
<Icon name="history" /> Log
3838
</Button>
3939
{open && <LogModal id={id} close={() => setOpen(false)} />}
40-
</>
40+
</Tooltip>
4141
);
4242
}
4343

src/packages/frontend/compute/compute-server.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -373,20 +373,20 @@ export default function ComputeServer({
373373
{id != null && (
374374
<div style={{ color: "#888" }}>Id: {project_specific_id}</div>
375375
)}
376-
{id != null && (
377-
<ComputeServerLog id={id} style={{ marginLeft: "-15px" }} />
378-
)}
379-
{id != null &&
380-
configuration.cloud == "google-cloud" &&
381-
(state == "starting" ||
382-
state == "stopping" ||
383-
state == "running") && (
384-
<SerialPortOutput
385-
id={id}
386-
style={{ marginLeft: "-15px" }}
387-
title={title}
388-
/>
389-
)}
376+
<div style={{ display: "flex", marginLeft: "-20px" }}>
377+
{id != null && <ComputeServerLog id={id} />}
378+
{id != null &&
379+
configuration.cloud == "google-cloud" &&
380+
(state == "starting" ||
381+
state == "stopping" ||
382+
state == "running") && (
383+
<SerialPortOutput
384+
id={id}
385+
title={title}
386+
style={{ marginLeft: "-5px" }}
387+
/>
388+
)}
389+
</div>
390390
{id != null && (
391391
<div style={{ marginLeft: "-15px" }}>
392392
<CurrentCost state={state} cost_per_hour={cost_per_hour} />

src/packages/frontend/compute/menu.tsx

Lines changed: 26 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import type { MenuProps } from "antd";
77
import { A, Icon } from "@cocalc/frontend/components";
88
import { useMemo, useState } from "react";
99
import getTitle from "./get-title";
10-
import { avatar_fontcolor } from "@cocalc/frontend/account/avatar/font-color";
1110
import { redux, useTypedRedux } from "@cocalc/frontend/app-framework";
1211
import { LogModal } from "./compute-server-log";
1312
import { EditModal } from "./compute-server";
@@ -46,8 +45,6 @@ function getItems({
4645
id,
4746
project_id,
4847
account_id,
49-
title,
50-
color,
5148
isAdmin,
5249
}: {
5350
id: number;
@@ -82,34 +79,9 @@ function getItems({
8279

8380
const titleAndColor = {
8481
key: "title-color",
85-
icon: <Icon name="server" />,
82+
icon: <Icon name="colors" />,
8683
disabled: !is_owner,
87-
label: (
88-
<div
89-
style={{
90-
fontWeight: "bold",
91-
fontSize: "11pt",
92-
display: "flex",
93-
color: avatar_fontcolor(color),
94-
background: color,
95-
padding: "0 5px",
96-
borderRadius: "3px",
97-
}}
98-
>
99-
<div
100-
style={{
101-
maxWidth: "20ex",
102-
textOverflow: "ellipsis",
103-
overflow: "hidden",
104-
whiteSpace: "nowrap",
105-
marginRight: "5px",
106-
}}
107-
>
108-
{title}
109-
</div>
110-
(Id: {server.project_specific_id})
111-
</div>
112-
),
84+
label: "Edit Title and Color",
11385
};
11486
const jupyterlab = {
11587
key: "top-jupyterlab",
@@ -133,29 +105,10 @@ function getItems({
133105
key: "xpra",
134106
label: "X11 Desktop",
135107
icon: <Icon name="desktop" />,
136-
disabled: apps["xpra"] == null,
137-
};
138-
139-
const logs = {
140-
key: "logs",
141-
label: "Logs",
142-
icon: <Icon name="history" />,
143-
children: [
144-
{
145-
key: "control-log",
146-
icon: <Icon name="history" />,
147-
label: "Control and Configuration Log",
148-
},
149-
{
150-
key: "serial-console-log",
151-
disabled:
152-
server.cloud != "google-cloud" ||
153-
server.state == "off" ||
154-
server.state == "deprovisioned",
155-
icon: <Icon name="laptop" />,
156-
label: "Serial Console Log",
157-
},
158-
],
108+
disabled:
109+
apps["xpra"] == null ||
110+
server.state != "running" ||
111+
!server.data?.externalIp,
159112
};
160113

161114
const optionItems: (
@@ -257,36 +210,6 @@ function getItems({
257210
],
258211
};
259212

260-
const launch = {
261-
key: "launch",
262-
label: "Applications",
263-
icon: <Icon name="global" />,
264-
disabled: server.state != "running",
265-
children: [
266-
{
267-
key: "run-app-on",
268-
type: "group",
269-
label: "Run On Compute Server",
270-
children: [
271-
{ ...jupyterlab, key: "jupyterlab-sub" },
272-
{ ...vscode, key: "vscode-sub" },
273-
{ ...xpra, key: "xpra-sub" },
274-
// {
275-
// key: "pluto",
276-
// label: "Pluto (Julia)",
277-
// icon: <Icon name="julia" />,
278-
// },
279-
// {
280-
// key: "rstudio",
281-
// value:"rstudio",
282-
// label: "R Studio",
283-
// icon: <Icon name="r" />,
284-
// },
285-
],
286-
},
287-
],
288-
};
289-
290213
const help = {
291214
key: "help",
292215
icon: <Icon name="question-circle" />,
@@ -344,17 +267,33 @@ function getItems({
344267
},
345268
jupyterlab,
346269
vscode,
270+
xpra,
347271
{
348272
type: "divider",
349273
},
350-
launch,
351-
logs,
274+
settings,
352275
options,
353276
{
354277
type: "divider",
355278
},
279+
{
280+
key: "control-log",
281+
icon: <Icon name="history" />,
282+
label: "Configuration Log",
283+
},
284+
{
285+
key: "serial-console-log",
286+
disabled:
287+
server.cloud != "google-cloud" ||
288+
server.state == "off" ||
289+
server.state == "deprovisioned",
290+
icon: <Icon name="laptop" />,
291+
label: "Serial Console",
292+
},
293+
{
294+
type: "divider",
295+
},
356296
help,
357-
settings,
358297
// {
359298
// key: "control",
360299
// icon: <Icon name="wrench" />,
@@ -471,7 +410,7 @@ export default function Menu({
471410
setTitle(await getTitle(id));
472411
})();
473412
return {
474-
items: getItems({ ...title, id, project_id, account_id, isAdmin }),
413+
items: getItems({ id, project_id, account_id, isAdmin }),
475414
onClick: async (obj) => {
476415
setOpen(false);
477416
let cmd = obj.key.startsWith("top-") ? obj.key.slice(4) : obj.key;

src/packages/frontend/compute/serial-port-output.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default function SerialPortOutput({
4949
style={{ color: "#666", ...style }}
5050
onClick={() => setShow(!show)}
5151
>
52-
<Icon name="laptop" /> Serial
52+
<Icon name="laptop" />
5353
</Button>
5454
{show && (
5555
<SerialLogModal id={id} title={title} close={() => setShow(false)} />

0 commit comments

Comments
 (0)