Skip to content

Commit

Permalink
Attach notification bar to top (opensearch-project#3336)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrey Myssak <[email protected]>
Signed-off-by: Sergey Myssak <[email protected]>
  • Loading branch information
SergeyMyssak and andreymyssak committed Apr 26, 2023
1 parent 755f16b commit b20fa53
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 65 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Table Visualization] Fix table rendering empty unused space ([#3797](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3797))
- [Table Visualization] Fix data table not adjusting height on the initial load ([#3816](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3816))
- Cleanup unused url ([#3847](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3847))
- [BUG] Docked navigation impacts visibility of bottom bar component ([#3949](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3949))

### 🚞 Infrastructure

Expand Down
2 changes: 1 addition & 1 deletion src/core/public/rendering/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/
// SASSTODO: Naming here is too embedded and high up that changing them could cause major breaks
#opensearch-dashboards-body {
overflow-x: hidden;
min-height: 100%;
}

Expand All @@ -25,6 +24,7 @@
}

.app-wrapper-panel {
position: relative;
display: flex;
flex: 1 0 auto;
flex-direction: column;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,21 @@
width: 100%;
}

.osdBody--mgtAdvancedSettingsHasBottomBar .mgtPage__body {
padding-bottom: $euiSizeXL * 2;
.mgtAdvancedSettingsForm {
&__notificationBarMask {
height: 64px;
width: 100%;
}

&__notificationBarArea {
position: absolute;
top: 0;
left: 0;
right: 0;
height: 100%;
}

&__notificationBar {
top: 99px !important;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

import React from 'react';
import { shallowWithI18nProvider, mountWithI18nProvider } from 'test_utils/enzyme_helpers';
import { UiSettingsType } from '../../../../../../core/public';
import { UiSettingsType } from '../../../../../../core/types';

import { findTestSubject } from '@elastic/eui/lib/test';

Expand All @@ -44,6 +44,15 @@ jest.mock('../field', () => ({
},
}));

jest.mock('@elastic/eui', () => {
const lib = jest.requireActual('@elastic/eui');

return {
...lib,
EuiPortal: ({ children }: any) => <>{children}</>,
};
});

beforeAll(() => {
const localStorage: Record<string, any> = {
'core.chrome.isLocked': true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ import {
EuiButton,
EuiToolTip,
EuiButtonEmpty,
EuiPortal,
} from '@elastic/eui';
import { FormattedMessage } from '@osd/i18n/react';
import { isEmpty } from 'lodash';
import { i18n } from '@osd/i18n';
import { DocLinksStart, ToastsStart } from 'opensearch-dashboards/public';
import { toMountPoint } from '../../../../../opensearch_dashboards_react/public';
import { DocLinksStart, ToastsStart } from '../../../../../../core/public';

import { getCategoryName } from '../../lib';
import { Field, getEditableValue } from '../field';
Expand Down Expand Up @@ -335,63 +336,75 @@ export class Form extends PureComponent<FormProps> {
);
};

renderBottomBar = () => {
renderNotificationBar = () => {
const sibling = document.getElementById('globalBannerList')!;
const areChangesInvalid = this.areChangesInvalid();

return (
<EuiBottomBar data-test-subj="advancedSetting-bottomBar">
<EuiFlexGroup
justifyContent="spaceBetween"
alignItems="center"
responsive={false}
gutterSize="s"
>
<EuiFlexItem grow={false} className="mgtAdvancedSettingsForm__unsavedCount">
<p id="aria-describedby.countOfUnsavedSettings">{this.renderCountOfUnsaved()}</p>
</EuiFlexItem>
<EuiFlexItem />
<EuiFlexItem grow={false}>
<EuiButtonEmpty
color="ghost"
size="s"
iconType="cross"
onClick={this.clearAllUnsaved}
aria-describedby="aria-describedby.countOfUnsavedSettings"
data-test-subj="advancedSetting-cancelButton"
>
{i18n.translate('advancedSettings.form.cancelButtonLabel', {
defaultMessage: 'Cancel changes',
})}
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiToolTip
content={
areChangesInvalid &&
i18n.translate('advancedSettings.form.saveButtonTooltipWithInvalidChanges', {
defaultMessage: 'Fix invalid settings before saving.',
})
}
<EuiPortal insert={{ sibling, position: 'after' }}>
<div className="mgtAdvancedSettingsForm__notificationBarMask">
<div className="mgtAdvancedSettingsForm__notificationBarArea">
<EuiBottomBar
data-test-subj="advancedSetting-bottomBar"
position="sticky"
className="mgtAdvancedSettingsForm__notificationBar"
>
<EuiButton
className="mgtAdvancedSettingsForm__button"
disabled={areChangesInvalid}
color="secondary"
fill
size="s"
iconType="check"
onClick={this.saveAll}
aria-describedby="aria-describedby.countOfUnsavedSettings"
isLoading={this.state.loading}
data-test-subj="advancedSetting-saveButton"
<EuiFlexGroup
justifyContent="spaceBetween"
alignItems="center"
responsive={false}
gutterSize="s"
>
{i18n.translate('advancedSettings.form.saveButtonLabel', {
defaultMessage: 'Save changes',
})}
</EuiButton>
</EuiToolTip>
</EuiFlexItem>
</EuiFlexGroup>
</EuiBottomBar>
<EuiFlexItem grow={false} className="mgtAdvancedSettingsForm__unsavedCount">
<p id="aria-describedby.countOfUnsavedSettings">{this.renderCountOfUnsaved()}</p>
</EuiFlexItem>
<EuiFlexItem />
<EuiFlexItem grow={false}>
<EuiButtonEmpty
color="ghost"
size="s"
iconType="cross"
onClick={this.clearAllUnsaved}
aria-describedby="aria-describedby.countOfUnsavedSettings"
data-test-subj="advancedSetting-cancelButton"
>
{i18n.translate('advancedSettings.form.cancelButtonLabel', {
defaultMessage: 'Cancel changes',
})}
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiToolTip
content={
areChangesInvalid &&
i18n.translate('advancedSettings.form.saveButtonTooltipWithInvalidChanges', {
defaultMessage: 'Fix invalid settings before saving.',
})
}
>
<EuiButton
className="mgtAdvancedSettingsForm__button"
disabled={areChangesInvalid}
color="secondary"
fill
size="s"
iconType="check"
onClick={this.saveAll}
aria-describedby="aria-describedby.countOfUnsavedSettings"
isLoading={this.state.loading}
data-test-subj="advancedSetting-saveButton"
>
{i18n.translate('advancedSettings.form.saveButtonLabel', {
defaultMessage: 'Save changes',
})}
</EuiButton>
</EuiToolTip>
</EuiFlexItem>
</EuiFlexGroup>
</EuiBottomBar>
</div>
</div>
</EuiPortal>
);
};

Expand All @@ -401,12 +414,6 @@ export class Form extends PureComponent<FormProps> {
const currentCategories: Category[] = [];
const hasUnsavedChanges = !isEmpty(unsavedChanges);

if (hasUnsavedChanges) {
document.body.classList.add('osdBody--mgtAdvancedSettingsHasBottomBar');
} else {
document.body.classList.remove('osdBody--mgtAdvancedSettingsHasBottomBar');
}

categories.forEach((category) => {
if (visibleSettings[category] && visibleSettings[category].length) {
currentCategories.push(category);
Expand All @@ -426,7 +433,7 @@ export class Form extends PureComponent<FormProps> {
})
: this.maybeRenderNoSettings(clearQuery)}
</div>
{hasUnsavedChanges && this.renderBottomBar()}
{hasUnsavedChanges && this.renderNotificationBar()}
</Fragment>
);
}
Expand Down

0 comments on commit b20fa53

Please sign in to comment.