CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/compute/select-server-for-explorer.tsx
Views: 687
1
/*
2
Dropdown for selecting compute server for the file explorer
3
*/
4
5
import type { CSSProperties } from "react";
6
import SelectServer from "./select-server";
7
import { redux, useTypedRedux } from "@cocalc/frontend/app-framework";
8
9
interface Props {
10
project_id: string;
11
style?: CSSProperties;
12
size?;
13
noLabel?: boolean;
14
}
15
16
export default function SelectComputeServerForFileExplorer({
17
project_id,
18
style,
19
size,
20
noLabel,
21
}: Props) {
22
const compute_servers_enabled = useTypedRedux(
23
"customize",
24
"compute_servers_enabled",
25
);
26
const compute_server_id = useTypedRedux({ project_id }, "compute_server_id");
27
if (!compute_servers_enabled) {
28
return null;
29
}
30
31
return (
32
<SelectServer
33
title={`Showing files ${
34
compute_server_id
35
? `on compute server ${compute_server_id}`
36
: "in the project"
37
}. When you create or open a file, it will by default open ${
38
compute_server_id
39
? `on compute server ${compute_server_id}`
40
: "in the project"
41
}.`}
42
size={size}
43
project_id={project_id}
44
style={style}
45
value={compute_server_id}
46
noLabel={noLabel}
47
setValue={(compute_server_id) => {
48
const actions = redux.getProjectActions(project_id);
49
actions.setComputeServerId(compute_server_id ?? 0);
50
}}
51
/>
52
);
53
}
54
55