@@ -14,18 +14,8 @@ import { Icon } from "@cocalc/frontend/components/icon";
14
14
import ShowError from "@cocalc/frontend/components/error" ;
15
15
import { useProjectContext } from "@cocalc/frontend/project/context" ;
16
16
import { webapp_client } from "@cocalc/frontend/webapp-client" ;
17
- import { delay } from "awaiting" ;
18
17
19
- export default function Snapshots ( ) {
20
- return (
21
- < Space . Compact >
22
- < CreateSnapshot />
23
- < EditSchedule />
24
- </ Space . Compact >
25
- ) ;
26
- }
27
-
28
- function CreateSnapshot ( ) {
18
+ export default function CreateSnapshot ( ) {
29
19
const { actions, project_id } = useProjectContext ( ) ;
30
20
const [ loading , setLoading ] = useState < boolean > ( false ) ;
31
21
const [ open , setOpen ] = useState < boolean > ( false ) ;
@@ -77,7 +67,6 @@ function CreateSnapshot() {
77
67
afterOpenChange = { async ( open ) => {
78
68
if ( ! open ) return ;
79
69
setName ( new Date ( ) . toISOString ( ) ) ;
80
- await delay ( 1 ) ;
81
70
inputRef . current ?. focus ( {
82
71
cursor : "all" ,
83
72
} ) ;
@@ -156,115 +145,3 @@ function CreateSnapshot() {
156
145
</ >
157
146
) ;
158
147
}
159
-
160
- function EditSchedule ( ) {
161
- const { actions, project_id } = useProjectContext ( ) ;
162
- const [ loading , setLoading ] = useState < boolean > ( false ) ;
163
- const [ open , setOpen ] = useState < boolean > ( false ) ;
164
- const [ name , setName ] = useState < string > ( "" ) ;
165
- const [ error , setError ] = useState < string > ( "" ) ;
166
- const inputRef = useRef < InputRef > ( null ) ;
167
-
168
- useEffect ( ( ) => {
169
- if ( ! open ) {
170
- return ;
171
- }
172
- actions ?. setState ( { disableExplorerKeyhandler : true } ) ;
173
- return ( ) => {
174
- actions ?. setState ( { disableExplorerKeyhandler : false } ) ;
175
- } ;
176
- } , [ open ] ) ;
177
-
178
- if ( ! project_id ) {
179
- return null ;
180
- }
181
-
182
- async function createSnapshot ( ) {
183
- try {
184
- setLoading ( true ) ;
185
- setError ( "" ) ;
186
- await webapp_client . conat_client . hub . projects . createSnapshot ( {
187
- project_id,
188
- name,
189
- } ) ;
190
- setName ( "" ) ;
191
- setOpen ( false ) ;
192
- } catch ( err ) {
193
- setError ( err ) ;
194
- } finally {
195
- setLoading ( false ) ;
196
- }
197
- }
198
-
199
- return (
200
- < >
201
- < Button
202
- disabled = { open }
203
- onClick = { ( ) => {
204
- setOpen ( ! open ) ;
205
- } }
206
- >
207
- < Icon name = "clock" /> Schedule
208
- </ Button >
209
- < Modal
210
- afterOpenChange = { ( open ) => {
211
- if ( ! open ) return ;
212
- setName ( new Date ( ) . toISOString ( ) ) ;
213
- inputRef . current ?. focus ( {
214
- cursor : "all" ,
215
- } ) ;
216
- } }
217
- title = {
218
- < >
219
- < Icon name = "clock" /> Edit Schedule{ " " }
220
- { loading && < Spin style = { { float : "right" } } /> }
221
- </ >
222
- }
223
- open = { open }
224
- onOk = { ( ) => {
225
- setName ( "" ) ;
226
- setOpen ( false ) ;
227
- } }
228
- onCancel = { ( ) => {
229
- setName ( "" ) ;
230
- setOpen ( false ) ;
231
- } }
232
- footer = { [
233
- < Button
234
- key = "cancel"
235
- onClick = { ( ) => {
236
- setOpen ( false ) ;
237
- setName ( "" ) ;
238
- } }
239
- >
240
- Cancel
241
- </ Button > ,
242
- < Button
243
- key = "create"
244
- type = "primary"
245
- onClick = { createSnapshot }
246
- disabled = { ! name . trim ( ) }
247
- >
248
- Create Snapshot
249
- </ Button > ,
250
- ] }
251
- >
252
- < Flex style = { { width : "100%" } } >
253
- < Input
254
- ref = { inputRef }
255
- style = { { flex : 1 } }
256
- value = { name }
257
- onChange = { ( e ) => setName ( e . target . value ) }
258
- placeholder = "Name of snapshot..."
259
- onPressEnter = { createSnapshot }
260
- />
261
- </ Flex >
262
- < ShowError
263
- style = { { marginTop : "10px" } }
264
- error = { error }
265
- setError = { setError }
266
- />
267
- </ Modal >
268
- </ >
269
- ) ;
270
- }
0 commit comments