Skip to content

Commit d12200f

Browse files
committed
Merge remote-tracking branch 'origin/master' into llm-tweak-abuse
2 parents fee5b94 + 4e2f8c0 commit d12200f

File tree

14 files changed

+268
-276
lines changed

14 files changed

+268
-276
lines changed
Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,68 @@
11
import { Button } from "antd";
22
import { Icon } from "./icon";
3-
import { CSSProperties } from "react";
3+
import { CSSProperties, useState } from "react";
4+
import ShowError from "@cocalc/frontend/components/error";
45

56
interface Props {
6-
refresh: () => void;
7+
refresh: Function;
78
style?: CSSProperties;
9+
refreshing?;
10+
setRefreshing?;
811
}
912

10-
export default function Refresh({ refresh, style }: Props) {
13+
export default function Refresh({
14+
refresh,
15+
style,
16+
refreshing,
17+
setRefreshing,
18+
}: Props) {
19+
if (refreshing == null) {
20+
return <UnControlled refresh={refresh} style={style} />;
21+
} else {
22+
return (
23+
<Controlled
24+
refresh={refresh}
25+
style={style}
26+
refreshing={refreshing}
27+
setRefreshing={setRefreshing}
28+
/>
29+
);
30+
}
31+
}
32+
33+
function UnControlled({ refresh, style }) {
34+
const [refreshing, setRefreshing] = useState<boolean>(false);
35+
return (
36+
<Controlled
37+
refresh={refresh}
38+
style={style}
39+
refreshing={refreshing}
40+
setRefreshing={setRefreshing}
41+
/>
42+
);
43+
}
44+
45+
function Controlled({ refresh, style, refreshing, setRefreshing }) {
46+
const [error, setError] = useState<string>("");
1147
return (
12-
<Button onClick={refresh} style={style}>
13-
<Icon name="refresh" /> Refresh
14-
</Button>
48+
<>
49+
<Button
50+
onClick={async () => {
51+
try {
52+
setError("");
53+
setRefreshing?.(true);
54+
await refresh();
55+
} catch (err) {
56+
setError(`${err}`);
57+
} finally {
58+
setRefreshing?.(false);
59+
}
60+
}}
61+
style={style}
62+
>
63+
<Icon name="refresh" spin={refreshing} /> Refresh
64+
</Button>
65+
<ShowError error={error} setError={setError} />
66+
</>
1567
);
1668
}

src/packages/frontend/compute/cloud-filesystem/cloud-filesystems.tsx

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import { Button, Spin } from "antd";
1414
import CreateCloudFilesystem from "./create";
1515
import CloudFilesystem from "./cloud-filesystem";
1616
import { Icon } from "@cocalc/frontend/components/icon";
17+
import { A } from "@cocalc/frontend/components/A";
18+
import RefreshButton from "@cocalc/frontend/components/refresh";
1719
import { cmp } from "@cocalc/util/misc";
1820
import {
1921
SortableList,
@@ -148,11 +150,11 @@ export default function CloudFilesystems({ project_id }: Props) {
148150

149151
return (
150152
<div>
151-
<Button style={{ position: "absolute", right: 0 }} onClick={refresh}>
152-
<Icon name="refresh" />
153-
Refresh{" "}
154-
{refreshing ? <Spin style={{ marginLeft: "15px" }} /> : undefined}
155-
</Button>
153+
<RefreshButton
154+
refresh={refresh}
155+
style={{ position: "absolute", right: 0 }}
156+
refreshing={refreshing}
157+
/>
156158
<h2 style={{ textAlign: "center" }}>Cloud File Systems</h2>
157159
<div style={{ textAlign: "center" }}>
158160
<Button
@@ -163,9 +165,20 @@ export default function CloudFilesystems({ project_id }: Props) {
163165
<Icon name="youtube" style={{ color: "red" }} />
164166
Short Demo
165167
</Button>
166-
<Button href="https://youtu.be/uk5eA5piQEo" target="_new">
168+
<Button
169+
href="https://youtu.be/uk5eA5piQEo"
170+
target="_new"
171+
style={{ marginRight: "15px" }}
172+
>
167173
<Icon name="youtube" style={{ color: "red" }} />
168-
Longer Demo
174+
Long Demo
175+
</Button>
176+
<Button
177+
href="https://doc.cocalc.com/cloud_file_system.html"
178+
target="_new"
179+
>
180+
<Icon name="external-link" />
181+
Docs
169182
</Button>
170183
</div>
171184
<p
@@ -176,12 +189,15 @@ export default function CloudFilesystems({ project_id }: Props) {
176189
color: "#666",
177190
}}
178191
>
179-
CoCalc Cloud File Systems are scalable distributed POSIX shared
180-
file systems with fast local caching. Use them simultaneously from all
181-
compute servers in this project. There are no limits on how much data
182-
you can store. You do not specify the size of a cloud file system in
183-
advance. The cost per GB is typically much less than a compute server
184-
disk, but you pay network usage and operations.
192+
<A href="https://doc.cocalc.com/cloud_file_system.html">
193+
CoCalc Cloud File Systems{" "}
194+
</A>
195+
are scalable distributed POSIX shared file systems with fast local
196+
caching. Use them simultaneously from all compute servers in this
197+
project. There are no limits on how much data you can store. You do not
198+
specify the size of a cloud file system in advance. The cost per GB is
199+
typically much less than a compute server disk, but you pay network
200+
usage and operations.
185201
</p>
186202

187203
<div style={{ margin: "5px 0" }}>

src/packages/frontend/compute/inline.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export default function ComputeServer({
5959
}
6060
if (!id) {
6161
setServer({
62-
title: "Default Shared Resources",
62+
title: "Home Base",
6363
color: PROJECT_COLOR,
6464
project_specific_id: 0,
6565
});

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

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -167,29 +167,34 @@ export default function SelectServer({
167167
sort: "project",
168168
state: "",
169169
label: (
170-
<div
171-
style={{
172-
background: PROJECT_COLOR,
173-
color: avatar_fontcolor(PROJECT_COLOR),
174-
padding: "0 5px",
175-
borderRadius: "3px",
176-
}}
170+
<Tooltip
171+
title="The Home Base is the core of your project; it contains your primary files and has limited compute resources to work with them. You can upgrade it using a license. For GPUs, high end CPUs, and root access use a compute server."
172+
placement="right"
177173
>
178-
{value != 0 ? (
179-
<div>
174+
<div
175+
style={{
176+
background: PROJECT_COLOR,
177+
color: avatar_fontcolor(PROJECT_COLOR),
178+
padding: "0 5px",
179+
borderRadius: "3px",
180+
}}
181+
>
182+
{value != 0 ? (
180183
<div>
181-
<Icon name="edit" /> Shared Resources
184+
<div>
185+
<Icon name="edit" /> Home Base
186+
</div>
187+
<div style={{ marginLeft: "15px" }}>
188+
<Icon name="users" /> Standard image
189+
</div>
182190
</div>
183-
<div style={{ marginLeft: "15px" }}>
184-
<Icon name="users" /> Standard image
191+
) : (
192+
<div style={{ padding: "5px 15px" }}>
193+
<Icon name="edit" /> Home Base
185194
</div>
186-
</div>
187-
) : (
188-
<div>
189-
<Icon name="edit" /> Shared Resources
190-
</div>
191-
)}
192-
</div>
195+
)}
196+
</div>
197+
</Tooltip>
193198
),
194199
},
195200
],
@@ -267,9 +272,7 @@ export default function SelectServer({
267272
title={
268273
title ??
269274
`This is open ${
270-
!value
271-
? "on the default shared resources"
272-
: `on compute server ${value}`
275+
!value ? "in your home base" : `on compute server ${value}`
273276
}.`
274277
}
275278
>

src/packages/frontend/purchases/statements.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ export default function Statements({
2424
defaultExpandAllRows,
2525
}: Props) {
2626
const [statements, setStatements] = useState<Statement[] | null>(null);
27-
const [error, setError] = useState<any>("");
27+
const [error, setError] = useState<string>("");
2828
const [loading, setLoading] = useState<boolean>(false);
29-
3029
const refresh = async () => {
3130
try {
3231
setLoading(true);
@@ -112,19 +111,24 @@ export default function Statements({
112111
{ title: "ID", dataIndex: "id", key: "id" },
113112
];
114113

115-
if (loading) {
116-
return <Spin />;
117-
}
118114
const adjective = interval == "day" ? "daily" : "monthly";
119115
return (
120116
<div style={{ minHeight: "50px" }}>
121117
{!noRefresh && (
122-
<Refresh refresh={refresh} style={{ marginBottom: "8px" }} />
118+
<Refresh
119+
refresh={refresh}
120+
style={{ marginBottom: "8px", float: "right" }}
121+
/>
123122
)}
124123
{interval == "day" && (
125124
<EmailDailyStatements style={{ marginLeft: "30px" }} />
126125
)}
127126
<ShowError error={error} setError={setError} />
127+
{loading && (
128+
<div style={{ margin: "0 15px" }}>
129+
<Spin />
130+
</div>
131+
)}
128132
{statements != null && statements?.length > 0 && (
129133
<Table
130134
rowKey="id"

0 commit comments

Comments
 (0)