Skip to content

Commit

Permalink
refactor: copy change
Browse files Browse the repository at this point in the history
  • Loading branch information
mbondyra committed Jan 23, 2020
1 parent 4ab5ace commit 0eb9b9e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ import {
EuiSwitch,
EuiSwitchEvent,
EuiToolTip,
EuiFlexGroup,
EuiFlexItem,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ export class Form extends PureComponent<FormProps> {
.find(el => el.name === key);
};

getCountOfUnsavedSettings = (): number => {
getCountOfUnsavedChanges = (): number => {
return Object.keys(this.state.unsavedChanges).length;
};

getCountOfHiddenUnsavedSettings = (): number => {
getCountOfHiddenUnsavedChanges = (): number => {
const unsavedSettings = Object.keys(this.state.unsavedChanges).map(key => ({ name: key }));
const displayedUnsavedCount = intersectionBy(
unsavedSettings,
Expand Down Expand Up @@ -123,7 +123,7 @@ export class Form extends PureComponent<FormProps> {
});
};

clearUnsaved = () => {
clearAllUnsaved = () => {
this.setState({ unsavedChanges: {} });
};

Expand Down Expand Up @@ -165,7 +165,7 @@ export class Form extends PureComponent<FormProps> {

try {
await this.props.save(configToSave);
this.clearUnsaved();
this.clearAllUnsaved();
if (requiresReload) {
this.renderPageReloadToast();
}
Expand Down Expand Up @@ -296,8 +296,8 @@ export class Form extends PureComponent<FormProps> {
}

renderBottomBar = () => {
const unsavedCount = this.getCountOfUnsavedSettings();
const hiddenUnsavedCount = this.getCountOfHiddenUnsavedSettings();
const unsavedCount = this.getCountOfUnsavedChanges();
const hiddenUnsavedCount = this.getCountOfHiddenUnsavedChanges();
return (
<EuiBottomBar>
<EuiFlexGroup justifyContent="spaceBetween" alignItems="center">
Expand Down Expand Up @@ -330,7 +330,7 @@ export class Form extends PureComponent<FormProps> {
color="ghost"
size="s"
iconType="cross"
onClick={this.clearUnsaved}
onClick={this.clearAllUnsaved}
aria-label={i18n.translate('kbn.management.settings.form.cancelButtonAriaLabel', {
defaultMessage: 'Cancel all changes',
})}
Expand Down

0 comments on commit 0eb9b9e

Please sign in to comment.