Skip to content

Commit f887cc3

Browse files
committed
add docs link for cloud filesystem (also slightly improve Refresh button, maybe)
- spin icon for less redraw flicker (?)
1 parent 18dc2f5 commit f887cc3

File tree

3 files changed

+97
-25
lines changed

3 files changed

+97
-25
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/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)