@@ -8,8 +8,7 @@ The Snapshots button pops up a model that:
8
8
9
9
import { useEffect , useRef , useState } from "react" ;
10
10
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" ;
13
12
import { Icon } from "@cocalc/frontend/components/icon" ;
14
13
import ShowError from "@cocalc/frontend/components/error" ;
15
14
import { useProjectContext } from "@cocalc/frontend/project/context" ;
@@ -63,69 +62,71 @@ export default function CreateSnapshot() {
63
62
< Button disabled = { open } onClick = { ( ) => setOpen ( ! open ) } >
64
63
< Icon name = "disk-snapshot" /> New Snapshot
65
64
</ 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 = { [
77
98
< 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
+ } }
82
104
>
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
+ ) }
125
126
< Input
126
127
allowClear
127
128
ref = { inputRef }
128
- style = { { flex : 1 } }
129
+ style = { { flex : 1 , width : "100%" , marginTop : "5px" } }
129
130
value = { name }
130
131
onChange = { ( e ) => setName ( e . target . value ) }
131
132
placeholder = "Name of snapshot to create..."
@@ -135,13 +136,13 @@ export default function CreateSnapshot() {
135
136
}
136
137
} }
137
138
/>
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
+ ) }
145
146
</ >
146
147
) ;
147
148
}
0 commit comments