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/next/components/store/run-limit.tsx
Views: 687
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>the run limit is typically 2 more than the number of students</i>
40
</b>
41
.
42
</div>
43
);
44
}
45
46
return (
47
<>
48
<Divider plain>
49
Simultaneous Project Upgrades
50
</Divider>
51
<Form.Item
52
label="Run Limit"
53
name="run_limit"
54
initialValue={1}
55
extra={extra()}
56
>
57
<EditRunLimit
58
disabled={disabled}
59
onChange={(run_limit) => {
60
form.setFieldsValue({ run_limit });
61
onChange();
62
}}
63
/>
64
</Form.Item>
65
</>
66
);
67
}
68
69
export function EditRunLimit({
70
value,
71
onChange,
72
disabled,
73
}: {
74
value?;
75
onChange?;
76
disabled?;
77
}) {
78
return (
79
<IntegerSlider
80
value={value}
81
min={1}
82
disabled={disabled}
83
max={300}
84
maxText={MAX_ALLOWED_RUN_LIMIT}
85
onChange={onChange}
86
units={"projects"}
87
presets={[1, 2, 10, 50, 100, 250, 500]}
88
/>
89
);
90
}
91
92