@@ -47,8 +47,9 @@ import {
47
47
import { FormattedMessage } from '@osd/i18n/react' ;
48
48
import { isEmpty } from 'lodash' ;
49
49
import { i18n } from '@osd/i18n' ;
50
+ import { DocLinksStart , ToastsStart } from 'opensearch-dashboards/public' ;
51
+ import { createPortal } from 'react-dom' ;
50
52
import { toMountPoint } from '../../../../../opensearch_dashboards_react/public' ;
51
- import { DocLinksStart , ToastsStart } from '../../../../../../core/public' ;
52
53
53
54
import { getCategoryName } from '../../lib' ;
54
55
import { Field , getEditableValue } from '../field' ;
@@ -336,63 +337,69 @@ export class Form extends PureComponent<FormProps> {
336
337
} ;
337
338
338
339
renderBottomBar = ( ) => {
339
- const areChangesInvalid = this . areChangesInvalid ( ) ;
340
- return (
341
- < EuiBottomBar data-test-subj = "advancedSetting-bottomBar" >
342
- < EuiFlexGroup
343
- justifyContent = "spaceBetween"
344
- alignItems = "center"
345
- responsive = { false }
346
- gutterSize = "s"
347
- >
348
- < EuiFlexItem grow = { false } className = "mgtAdvancedSettingsForm__unsavedCount" >
349
- < p id = "aria-describedby.countOfUnsavedSettings" > { this . renderCountOfUnsaved ( ) } </ p >
350
- </ EuiFlexItem >
351
- < EuiFlexItem />
352
- < EuiFlexItem grow = { false } >
353
- < EuiButtonEmpty
354
- color = "ghost"
355
- size = "s"
356
- iconType = "cross"
357
- onClick = { this . clearAllUnsaved }
358
- aria-describedby = "aria-describedby.countOfUnsavedSettings"
359
- data-test-subj = "advancedSetting-cancelButton"
360
- >
361
- { i18n . translate ( 'advancedSettings.form.cancelButtonLabel' , {
362
- defaultMessage : 'Cancel changes' ,
363
- } ) }
364
- </ EuiButtonEmpty >
365
- </ EuiFlexItem >
366
- < EuiFlexItem grow = { false } >
367
- < EuiToolTip
368
- content = {
369
- areChangesInvalid &&
370
- i18n . translate ( 'advancedSettings.form.saveButtonTooltipWithInvalidChanges' , {
371
- defaultMessage : 'Fix invalid settings before saving.' ,
372
- } )
373
- }
374
- >
375
- < EuiButton
376
- className = "mgtAdvancedSettingsForm__button"
377
- disabled = { areChangesInvalid }
378
- color = "secondary"
379
- fill
340
+ try {
341
+ const areChangesInvalid = this . areChangesInvalid ( ) ;
342
+ const bottomBar = (
343
+ < EuiBottomBar data-test-subj = "advancedSetting-bottomBar" position = "sticky" >
344
+ < EuiFlexGroup
345
+ justifyContent = "spaceBetween"
346
+ alignItems = "center"
347
+ responsive = { false }
348
+ gutterSize = "s"
349
+ >
350
+ < EuiFlexItem grow = { false } className = "mgtAdvancedSettingsForm__unsavedCount" >
351
+ < p id = "aria-describedby.countOfUnsavedSettings" > { this . renderCountOfUnsaved ( ) } </ p >
352
+ </ EuiFlexItem >
353
+ < EuiFlexItem />
354
+ < EuiFlexItem grow = { false } >
355
+ < EuiButtonEmpty
356
+ color = "ghost"
380
357
size = "s"
381
- iconType = "check "
382
- onClick = { this . saveAll }
358
+ iconType = "cross "
359
+ onClick = { this . clearAllUnsaved }
383
360
aria-describedby = "aria-describedby.countOfUnsavedSettings"
384
- isLoading = { this . state . loading }
385
- data-test-subj = "advancedSetting-saveButton"
361
+ data-test-subj = "advancedSetting-cancelButton"
386
362
>
387
- { i18n . translate ( 'advancedSettings.form.saveButtonLabel ' , {
388
- defaultMessage : 'Save changes' ,
363
+ { i18n . translate ( 'advancedSettings.form.cancelButtonLabel ' , {
364
+ defaultMessage : 'Cancel changes' ,
389
365
} ) }
390
- </ EuiButton >
391
- </ EuiToolTip >
392
- </ EuiFlexItem >
393
- </ EuiFlexGroup >
394
- </ EuiBottomBar >
395
- ) ;
366
+ </ EuiButtonEmpty >
367
+ </ EuiFlexItem >
368
+ < EuiFlexItem grow = { false } >
369
+ < EuiToolTip
370
+ content = {
371
+ areChangesInvalid &&
372
+ i18n . translate ( 'advancedSettings.form.saveButtonTooltipWithInvalidChanges' , {
373
+ defaultMessage : 'Fix invalid settings before saving.' ,
374
+ } )
375
+ }
376
+ >
377
+ < EuiButton
378
+ className = "mgtAdvancedSettingsForm__button"
379
+ disabled = { areChangesInvalid }
380
+ color = "secondary"
381
+ fill
382
+ size = "s"
383
+ iconType = "check"
384
+ onClick = { this . saveAll }
385
+ aria-describedby = "aria-describedby.countOfUnsavedSettings"
386
+ isLoading = { this . state . loading }
387
+ data-test-subj = "advancedSetting-saveButton"
388
+ >
389
+ { i18n . translate ( 'advancedSettings.form.saveButtonLabel' , {
390
+ defaultMessage : 'Save changes' ,
391
+ } ) }
392
+ </ EuiButton >
393
+ </ EuiToolTip >
394
+ </ EuiFlexItem >
395
+ </ EuiFlexGroup >
396
+ </ EuiBottomBar >
397
+ ) ;
398
+
399
+ return createPortal ( bottomBar , document . getElementById ( 'app-wrapper-panel' ) ! ) ;
400
+ } catch ( e ) {
401
+ return null ;
402
+ }
396
403
} ;
397
404
398
405
render ( ) {
@@ -401,12 +408,6 @@ export class Form extends PureComponent<FormProps> {
401
408
const currentCategories : Category [ ] = [ ] ;
402
409
const hasUnsavedChanges = ! isEmpty ( unsavedChanges ) ;
403
410
404
- if ( hasUnsavedChanges ) {
405
- document . body . classList . add ( 'osdBody--mgtAdvancedSettingsHasBottomBar' ) ;
406
- } else {
407
- document . body . classList . remove ( 'osdBody--mgtAdvancedSettingsHasBottomBar' ) ;
408
- }
409
-
410
411
categories . forEach ( ( category ) => {
411
412
if ( visibleSettings [ category ] && visibleSettings [ category ] . length ) {
412
413
currentCategories . push ( category ) ;
0 commit comments