@@ -226,58 +226,83 @@ export const DesignerChangesPreviewButton = () => {
226
226
</ >
227
227
) ;
228
228
229
- const previewLoadedSuccessDialogContents = ( ) => (
230
- < >
231
- < DialogContent >
232
- < div className = { classes . markdownContainer } >
233
- < ReactMarkdown >
234
- { metadata ?. generatePreviewReportResult ?. report }
235
- </ ReactMarkdown >
236
- </ div >
237
- < Checkbox
238
- label = {
239
- locConstants . tableDesigner . designerPreviewConfirmation
240
- }
241
- checked = { isConfirmationChecked }
242
- onChange = { ( _event , data ) => {
243
- setIsConfirmationChecked ( data . checked as boolean ) ;
244
- } }
245
- />
246
- </ DialogContent >
247
- < DialogActions >
248
- < Button
249
- className = { classes . updateDatabase }
250
- disabled = {
251
- ! (
252
- isConfirmationChecked &&
253
- metadata . apiState ?. previewState === LoadState . Loaded
254
- )
255
- }
256
- appearance = "primary"
257
- onClick = { ( ) => {
258
- designerContext . provider . publishChanges ( ) ;
259
- } }
260
- >
261
- { locConstants . tableDesigner . updateDatabase }
262
- </ Button >
263
- < DialogTrigger action = "close" >
229
+ const previewLoadedSuccessDialogContents = ( ) => {
230
+ return (
231
+ < >
232
+ < DialogContent >
233
+ < div className = { classes . markdownContainer } >
234
+ < ReactMarkdown >
235
+ { metadata ?. generatePreviewReportResult ?. report }
236
+ </ ReactMarkdown >
237
+ </ div >
238
+ < Checkbox
239
+ label = {
240
+ locConstants . tableDesigner
241
+ . designerPreviewConfirmation
242
+ }
243
+ required
244
+ checked = { isConfirmationChecked }
245
+ onChange = { ( _event , data ) => {
246
+ setIsConfirmationChecked ( data . checked as boolean ) ;
247
+ } }
248
+ // Setting initial focus on the checkbox when it is rendered.
249
+ autoFocus
250
+ /**
251
+ * The focus outline is not visible on the checkbox when it is focused programmatically.
252
+ * This is a workaround to make the focus outline visible on the checkbox when it is focused programmatically.
253
+ * This is most likely a bug in the browser.
254
+ */
255
+ onFocus = { ( event ) => {
256
+ if ( event . target . parentElement ) {
257
+ event . target . parentElement . style . outlineStyle =
258
+ "solid" ;
259
+ }
260
+ } }
261
+ onBlur = { ( event ) => {
262
+ if ( event . target . parentElement ) {
263
+ event . target . parentElement . style . outline =
264
+ "none" ;
265
+ }
266
+ } }
267
+ />
268
+ </ DialogContent >
269
+ < DialogActions >
270
+ { getDialogCloseButton ( ) }
271
+ < DialogTrigger action = "close" >
272
+ < Button
273
+ icon = { generateScriptIcon ( ) }
274
+ iconPosition = "after"
275
+ className = { classes . openScript }
276
+ disabled = {
277
+ metadata . apiState ?. previewState !==
278
+ LoadState . Loaded
279
+ }
280
+ appearance = "secondary"
281
+ onClick = { designerContext . provider . generateScript }
282
+ >
283
+ { locConstants . tableDesigner . generateScript }
284
+ </ Button >
285
+ </ DialogTrigger >
264
286
< Button
265
- icon = { generateScriptIcon ( ) }
266
- iconPosition = "after"
267
- className = { classes . openScript }
268
- disabled = {
269
- metadata . apiState ?. previewState !== LoadState . Loaded
287
+ className = { classes . updateDatabase }
288
+ disabled = { ! isConfirmationChecked }
289
+ title = {
290
+ ! isConfirmationChecked
291
+ ? locConstants . tableDesigner
292
+ . youMustReviewAndAccept
293
+ : locConstants . tableDesigner . updateDatabase
270
294
}
271
295
appearance = "primary"
272
- onClick = { designerContext . provider . generateScript }
296
+ onClick = { ( ) => {
297
+ designerContext . provider . publishChanges ( ) ;
298
+ } }
273
299
>
274
- { locConstants . tableDesigner . generateScript }
300
+ { locConstants . tableDesigner . updateDatabase }
275
301
</ Button >
276
- </ DialogTrigger >
277
- { getDialogCloseButton ( ) }
278
- </ DialogActions >
279
- </ >
280
- ) ;
302
+ </ DialogActions >
303
+ </ >
304
+ ) ;
305
+ } ;
281
306
282
307
const getDialogContent = ( ) => {
283
308
if ( metadata ?. apiState ?. publishState === LoadState . Loading ) {
0 commit comments