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. Commercial Alternative to JupyterHub.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/components/store/run-limit.tsx
Views: 923
1
/*
2
* This file is part of CoCalc: Copyright © 2022 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { Divider, Form } from "antd";
7
import A from "components/misc/A";
8
import IntegerSlider from "components/misc/integer-slider";
9
10
export const MAX_ALLOWED_RUN_LIMIT = 10000;
11
12
export function RunLimit({
13
showExplanations,
14
form,
15
onChange,
16
disabled = false,
17
boost = false,
18
}) {
19
function extra() {
20
if (!showExplanations) return;
21
22
return (
23
<div style={{ marginTop: "5px" }}>
24
{boost ? (
25
<div style={{ fontWeight: "bold" }}>
26
It's not necessary to match the run limit of the license you want to
27
boost!
28
</div>
29
) : undefined}
30
Simultaneously run this many projects using this license. You, and
31
anyone you share the license code with, can apply the license to an
32
unlimited number of projects, but it will only be used up to the run
33
limit. When{" "}
34
<A href="https://doc.cocalc.com/teaching-instructors.html">
35
teaching a course
36
</A>
37
,{" "}
38
<b>
39
<i>
40
the run limit is typically 2 more than the number of students (one
41
for each student, one for the shared project and one for the
42
instructor project)
43
</i>
44
</b>
45
.
46
</div>
47
);
48
}
49
50
return (
51
<>
52
<Divider plain>Simultaneous Project Upgrades</Divider>
53
<Form.Item
54
label="Run Limit"
55
name="run_limit"
56
initialValue={1}
57
extra={extra()}
58
>
59
<EditRunLimit
60
disabled={disabled}
61
onChange={(run_limit) => {
62
form.setFieldsValue({ run_limit });
63
onChange();
64
}}
65
/>
66
</Form.Item>
67
</>
68
);
69
}
70
71
export function EditRunLimit({
72
value,
73
onChange,
74
disabled,
75
}: {
76
value?;
77
onChange?;
78
disabled?;
79
}) {
80
return (
81
<IntegerSlider
82
value={value}
83
min={1}
84
disabled={disabled}
85
max={300}
86
maxText={MAX_ALLOWED_RUN_LIMIT}
87
onChange={onChange}
88
units={"projects"}
89
presets={[1, 2, 10, 50, 100, 250, 500]}
90
/>
91
);
92
}
93
94