Skip to content

Commit 0f2e3f6

Browse files
committed
implement ability to configure snapshot schedule
1 parent 666b67a commit 0f2e3f6

File tree

4 files changed

+255
-142
lines changed

4 files changed

+255
-142
lines changed

src/packages/frontend/project/explorer/misc-side-buttons.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { useStudentProjectFunctionality } from "@cocalc/frontend/course";
1313
import { labels } from "@cocalc/frontend/i18n";
1414
import { serverURL, SPEC } from "@cocalc/frontend/project/named-server-panel";
1515
import track from "@cocalc/frontend/user-tracking";
16-
import { KUCALC_COCALC_COM } from "@cocalc/util/db-schema/site-defaults";
1716
import { useProjectContext } from "@cocalc/frontend/project/context";
1817
import { useTypedRedux } from "@cocalc/frontend/app-framework";
1918
import { type JSX, type MouseEvent } from "react";
@@ -74,11 +73,6 @@ export function MiscSideButtons() {
7473
}
7574

7675
function render_backup(): JSX.Element | undefined {
77-
// NOTE -- snapshots aren't available except in "kucalc" version
78-
// -- they are complicated nontrivial thing that isn't usually setup...
79-
if (kucalc !== KUCALC_COCALC_COM) {
80-
return;
81-
}
8276
return (
8377
<Button bsSize="small" onClick={handle_backup}>
8478
<Icon name="disk-round" />{" "}

src/packages/frontend/project/snapshots/create.tsx

Lines changed: 68 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ The Snapshots button pops up a model that:
88

99
import { useEffect, useRef, useState } from "react";
1010
import type { InputRef } from "antd";
11-
//import { SNAPSHOTS } from "@cocalc/util/consts/snapshots";
12-
import { Button, Flex, Input, Modal, Space, Spin } from "antd";
11+
import { Button, Input, Modal, Spin } from "antd";
1312
import { Icon } from "@cocalc/frontend/components/icon";
1413
import ShowError from "@cocalc/frontend/components/error";
1514
import { useProjectContext } from "@cocalc/frontend/project/context";
@@ -63,69 +62,71 @@ export default function CreateSnapshot() {
6362
<Button disabled={open} onClick={() => setOpen(!open)}>
6463
<Icon name="disk-snapshot" /> New Snapshot
6564
</Button>
66-
<Modal
67-
afterOpenChange={async (open) => {
68-
if (!open) return;
69-
setName(new Date().toISOString());
70-
inputRef.current?.focus({
71-
cursor: "all",
72-
});
73-
}}
74-
title={
75-
<>
76-
<Icon name="disk-snapshot" /> Create Snapshot{" "}
65+
{open && (
66+
<Modal
67+
afterOpenChange={async (open) => {
68+
if (!open) return;
69+
setName(new Date().toISOString());
70+
inputRef.current?.focus({
71+
cursor: "all",
72+
});
73+
}}
74+
title={
75+
<>
76+
<Icon name="disk-snapshot" /> Create Snapshot{" "}
77+
<Button
78+
size="small"
79+
type="text"
80+
style={{ float: "right", marginRight: "15px" }}
81+
onClick={() => setShowHelp(!showHelp)}
82+
>
83+
Help
84+
</Button>
85+
{loading && (
86+
<Spin style={{ float: "right", marginRight: "15px" }} />
87+
)}
88+
</>
89+
}
90+
open={open}
91+
onOk={() => {
92+
setOpen(false);
93+
}}
94+
onCancel={() => {
95+
setOpen(false);
96+
}}
97+
footer={[
7798
<Button
78-
size="small"
79-
type="text"
80-
style={{ float: "right", marginRight: "15px" }}
81-
onClick={() => setShowHelp(!showHelp)}
99+
key="cancel"
100+
onClick={() => {
101+
setOpen(false);
102+
setName("");
103+
}}
82104
>
83-
Help
84-
</Button>
85-
{loading && <Spin style={{ float: "right" }} />}
86-
</>
87-
}
88-
open={open}
89-
onOk={() => {
90-
setOpen(false);
91-
}}
92-
onCancel={() => {
93-
setOpen(false);
94-
}}
95-
footer={[
96-
<Button
97-
key="cancel"
98-
onClick={() => {
99-
setOpen(false);
100-
setName("");
101-
}}
102-
>
103-
Cancel
104-
</Button>,
105-
<Button
106-
key="create"
107-
type="primary"
108-
onClick={createSnapshot}
109-
disabled={!name.trim()}
110-
>
111-
Create Snapshot
112-
</Button>,
113-
]}
114-
>
115-
{showHelp && (
116-
<p>
117-
Create instant lightwight snapshots of the exact state of all files
118-
in your project. Named snapshots remain until you delete them,
119-
whereas the default timestamp snapshots are created and deleted
120-
automatically according to a schedule. Only unique data in snapshots
121-
count against your quota.
122-
</p>
123-
)}
124-
<Flex style={{ width: "100%", marginTop: "5px" }}>
105+
Cancel
106+
</Button>,
107+
<Button
108+
key="create"
109+
type="primary"
110+
onClick={createSnapshot}
111+
disabled={!name.trim()}
112+
>
113+
Create Snapshot
114+
</Button>,
115+
]}
116+
>
117+
{showHelp && (
118+
<p>
119+
Create instant lightwight snapshots of the exact state of all
120+
files in your project. Named snapshots remain until you delete
121+
them, whereas the default timestamp snapshots are created and
122+
deleted automatically according to a schedule. Only unique data in
123+
snapshots count against your quota.
124+
</p>
125+
)}
125126
<Input
126127
allowClear
127128
ref={inputRef}
128-
style={{ flex: 1 }}
129+
style={{ flex: 1, width: "100%", marginTop: "5px" }}
129130
value={name}
130131
onChange={(e) => setName(e.target.value)}
131132
placeholder="Name of snapshot to create..."
@@ -135,13 +136,13 @@ export default function CreateSnapshot() {
135136
}
136137
}}
137138
/>
138-
</Flex>
139-
<ShowError
140-
style={{ marginTop: "10px" }}
141-
error={error}
142-
setError={setError}
143-
/>
144-
</Modal>
139+
<ShowError
140+
style={{ marginTop: "10px" }}
141+
error={error}
142+
setError={setError}
143+
/>
144+
</Modal>
145+
)}
145146
</>
146147
);
147148
}

0 commit comments

Comments
 (0)