Skip to content

Commit

Permalink
Upgrade EUI to v14.9.0 (elastic#49678)
Browse files Browse the repository at this point in the history
* eui to 14.9.0

* euiswitch updtates

* misc snapshot

* x-pack functional fixes

* more euiswitch functional test fixes

* label-less switches for spaces management

* more euiswitch fixes

* telemetry form a11y

* snapshot update

* label updates

* more switch updates

* lint
  • Loading branch information
thompsongl authored and chrisronline committed Nov 14, 2019
1 parent 8bbb602 commit faf77b2
Show file tree
Hide file tree
Showing 62 changed files with 542 additions and 435 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"@elastic/charts": "^14.0.0",
"@elastic/datemath": "5.0.2",
"@elastic/ems-client": "1.0.5",
"@elastic/eui": "14.8.0",
"@elastic/eui": "14.9.0",
"@elastic/filesaver": "1.1.2",
"@elastic/good": "8.1.1-kibana2",
"@elastic/numeral": "2.3.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
EuiPopoverTitle,
EuiSpacer,
EuiSwitch,
EuiSwitchEvent,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react';
Expand Down Expand Up @@ -431,7 +432,7 @@ class FilterEditorUI extends Component<Props, State> {
this.setState({ selectedOperator, params });
};

private onCustomLabelSwitchChange = (event: React.ChangeEvent<HTMLInputElement>) => {
private onCustomLabelSwitchChange = (event: EuiSwitchEvent) => {
const useCustomLabel = event.target.checked;
const customLabel = event.target.checked ? '' : null;
this.setState({ useCustomLabel, customLabel });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ test('handleCheckboxOptionChange - multiselect', async () => {
component.update();

const checkbox = findTestSubject(component, 'listControlMultiselectInput');
checkbox.simulate('change', { target: { checked: true } });
checkbox.simulate('click');
sinon.assert.notCalled(handleFieldNameChange);
sinon.assert.notCalled(handleIndexPatternChange);
sinon.assert.notCalled(handleNumberOptionChange);
Expand All @@ -247,7 +247,9 @@ test('handleCheckboxOptionChange - multiselect', async () => {
expectedControlIndex,
expectedOptionName,
sinon.match((evt) => {
if (evt.target.checked === true) {
// Synthetic `evt.target.checked` does not get altered by EuiSwitch,
// but its aria attribute is correctly updated
if (evt.target.getAttribute('aria-checked') === 'true') {
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,26 @@ describe('OptionsTab', () => {

it('should update updateFiltersOnChange', () => {
const component = mountWithIntl(<OptionsTab {...props} />);
const checkbox = component.find('[data-test-subj="inputControlEditorUpdateFiltersOnChangeCheckbox"] input[type="checkbox"]');
checkbox.simulate('change', { target: { checked: true } });
const checkbox = component.find('[data-test-subj="inputControlEditorUpdateFiltersOnChangeCheckbox"] button');
checkbox.simulate('click');

expect(props.setValue).toHaveBeenCalledTimes(1);
expect(props.setValue).toHaveBeenCalledWith('updateFiltersOnChange', true);
});

it('should update useTimeFilter', () => {
const component = mountWithIntl(<OptionsTab {...props} />);
const checkbox = component.find('[data-test-subj="inputControlEditorUseTimeFilterCheckbox"] input[type="checkbox"]');
checkbox.simulate('change', { target: { checked: true } });
const checkbox = component.find('[data-test-subj="inputControlEditorUseTimeFilterCheckbox"] button');
checkbox.simulate('click');

expect(props.setValue).toHaveBeenCalledTimes(1);
expect(props.setValue).toHaveBeenCalledWith('useTimeFilter', true);
});

it('should update pinFilters', () => {
const component = mountWithIntl(<OptionsTab {...props} />);
const checkbox = component.find('[data-test-subj="inputControlEditorPinFiltersCheckbox"] input[type="checkbox"]');
checkbox.simulate('change', { target: { checked: true } });
const checkbox = component.find('[data-test-subj="inputControlEditorPinFiltersCheckbox"] button');
checkbox.simulate('click');

expect(props.setValue).toHaveBeenCalledTimes(1);
expect(props.setValue).toHaveBeenCalledWith('pinFilters', true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe('DiscoverFieldSearch', () => {
// @ts-ignore
(aggregtableButtonGroup.props() as EuiButtonGroupProps).onChange('aggregatable-true', null);
});
missingSwitch.simulate('change', { target: { value: false } });
missingSwitch.simulate('click');
expect(onChange).toBeCalledTimes(2);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
EuiPopoverTitle,
EuiSelect,
EuiSwitch,
EuiSwitchEvent,
EuiForm,
EuiFormRow,
EuiButtonGroup,
Expand Down Expand Up @@ -154,7 +155,7 @@ export function DiscoverFieldSearch({ onChange, value, types }: Props) {
setActiveFiltersCount(activeFiltersCount + diff);
};

const handleMissingChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const handleMissingChange = (e: EuiSwitchEvent) => {
const missingValue = e.target.checked;
handleValueChange('missing', missingValue);
};
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { getConfigTelemetryDesc, PRIVACY_STATEMENT_URL } from '../../common/cons
import { OptInExampleFlyout } from './opt_in_details_component';
import { Field } from 'ui/management';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';

const SEARCH_TERMS = ['telemetry', 'usage', 'data', 'usage data'];

Expand Down Expand Up @@ -117,6 +118,7 @@ export class TelemetryForm extends Component {
value: telemetryOptInProvider.getOptIn() || false,
description: this.renderDescription(),
defVal: false,
ariaName: i18n.translate('telemetry.provideUsageStatisticsLabel', { defaultMessage: 'Provide usage statistics' })
}}
save={this.toggleOptIn}
clear={this.toggleOptIn}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { EuiSwitch, EuiFormRow } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { AggParamEditorProps } from '..';

function AutoPrecisionParamEditor({ value, setValue }: AggParamEditorProps<boolean>) {
function AutoPrecisionParamEditor({ value = false, setValue }: AggParamEditorProps<boolean>) {
const label = i18n.translate('common.ui.aggTypes.changePrecisionLabel', {
defaultMessage: 'Change precision on map zoom',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface SwitchParamEditorProps extends AggParamEditorProps<boolean> {
}

function SwitchParamEditor({
value,
value = false,
setValue,
dataTestSubj,
displayToolTip,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { EuiSwitch, EuiFormRow } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { AggParamEditorProps } from '..';

function UseGeocentroidParamEditor({ value, setValue }: AggParamEditorProps<boolean>) {
function UseGeocentroidParamEditor({ value = false, setValue }: AggParamEditorProps<boolean>) {
const label = i18n.translate('common.ui.aggTypes.placeMarkersOffGridLabel', {
defaultMessage: 'Place markers off grid (use geocentroid)',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ test('Can set title to an empty string', async () => {
);

const inputField = findTestSubject(component, 'customizePanelHideTitle');
inputField.simulate('change');
inputField.simulate('click');

findTestSubject(component, 'saveNewTitleButton').simulate('click');
expect(inputField.props().value).toBeUndefined();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import React from 'react';
import { EuiFormRow, EuiSwitch } from '@elastic/eui';
import { EuiFormRow, EuiSwitch, EuiSwitchEvent } from '@elastic/eui';

import { FieldHook } from '../../hook_form_lib';
import { getFieldValidityAndErrorMessage } from '../helpers';
Expand All @@ -33,6 +33,14 @@ interface Props {
export const ToggleField = ({ field, euiFieldProps = {}, ...rest }: Props) => {
const { isInvalid, errorMessage } = getFieldValidityAndErrorMessage(field);

// Shim for sufficient overlap between EuiSwitchEvent and FieldHook[onChange] event
const onChange = (e: EuiSwitchEvent) => {
const event = ({ ...e, value: `${e.target.checked}` } as unknown) as React.ChangeEvent<{
value: string;
}>;
field.onChange(event);
};

return (
<EuiFormRow
helpText={field.helpText}
Expand All @@ -45,7 +53,7 @@ export const ToggleField = ({ field, euiFieldProps = {}, ...rest }: Props) => {
<EuiSwitch
label={field.label}
checked={field.value as boolean}
onChange={field.onChange}
onChange={onChange}
data-test-subj="input"
{...euiFieldProps}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
EuiOverlayMask,
EuiSpacer,
EuiSwitch,
EuiSwitchEvent,
EuiTextArea,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
Expand Down Expand Up @@ -227,7 +228,7 @@ export class SavedObjectSaveModal extends React.Component<Props, State> {
});
};

private onCopyOnSaveChange = (event: React.ChangeEvent<HTMLInputElement>) => {
private onCopyOnSaveChange = (event: EuiSwitchEvent) => {
this.setState({
copyOnSave: event.target.checked,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ export default function ({ getService, getPageObjects }) {
describe('updateFiltersOnChange is true', () => {
before(async () => {
await PageObjects.visualize.clickVisEditorTab('options');
await PageObjects.visualize.checkCheckbox('inputControlEditorUpdateFiltersOnChangeCheckbox');
await PageObjects.visualize.checkSwitch('inputControlEditorUpdateFiltersOnChangeCheckbox');
await PageObjects.visualize.clickGo();
});

after(async () => {
await PageObjects.visualize.clickVisEditorTab('options');
await PageObjects.visualize.uncheckCheckbox('inputControlEditorUpdateFiltersOnChangeCheckbox');
await PageObjects.visualize.uncheckSwitch('inputControlEditorUpdateFiltersOnChangeCheckbox');
await PageObjects.visualize.clickGo();
});

Expand Down
8 changes: 5 additions & 3 deletions test/functional/page_objects/dashboard_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ export function DashboardPageProvider({ getService, getPageObjects }) {

async clickSave() {
log.debug('DashboardPage.clickSave');
await testSubjects.clickWhenNotDisabled('confirmSaveSavedObjectButton');
await testSubjects.click('confirmSaveSavedObjectButton');
}

async pressEnterKey() {
Expand Down Expand Up @@ -543,19 +543,21 @@ export function DashboardPageProvider({ getService, getPageObjects }) {
async setSaveAsNewCheckBox(checked) {
log.debug('saveAsNewCheckbox: ' + checked);
const saveAsNewCheckbox = await testSubjects.find('saveAsNewCheckbox');
const isAlreadyChecked = (await saveAsNewCheckbox.getAttribute('checked') === 'true');
const isAlreadyChecked = (await saveAsNewCheckbox.getAttribute('aria-checked') === 'true');
if (isAlreadyChecked !== checked) {
log.debug('Flipping save as new checkbox');
const saveAsNewCheckbox = await testSubjects.find('saveAsNewCheckbox');
await retry.try(() => saveAsNewCheckbox.click());
}
}

async setStoreTimeWithDashboard(checked) {
log.debug('Storing time with dashboard: ' + checked);
const storeTimeCheckbox = await testSubjects.find('storeTimeWithDashboard');
const isAlreadyChecked = (await storeTimeCheckbox.getAttribute('checked') === 'true');
const isAlreadyChecked = (await storeTimeCheckbox.getAttribute('aria-checked') === 'true');
if (isAlreadyChecked !== checked) {
log.debug('Flipping store time checkbox');
const storeTimeCheckbox = await testSubjects.find('storeTimeWithDashboard');
await retry.try(() => storeTimeCheckbox.click());
}
}
Expand Down
24 changes: 23 additions & 1 deletion test/functional/page_objects/visualize_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,28 @@ export function VisualizePageProvider({ getService, getPageObjects, updateBaseli
}
}

async isSwitchChecked(selector) {
const checkbox = await testSubjects.find(selector);
const isChecked = await checkbox.getAttribute('aria-checked');
return isChecked === 'true';
}

async checkSwitch(selector) {
const isChecked = await this.isSwitchChecked(selector);
if (!isChecked) {
log.debug(`checking switch ${selector}`);
await testSubjects.click(selector);
}
}

async uncheckSwitch(selector) {
const isChecked = await this.isSwitchChecked(selector);
if (isChecked) {
log.debug(`unchecking switch ${selector}`);
await testSubjects.click(selector);
}
}

async setSelectByOptionText(selectId, optionText) {
const selectField = await find.byCssSelector(`#${selectId}`);
const options = await find.allByCssSelector(`#${selectId} > option`);
Expand Down Expand Up @@ -1009,7 +1031,7 @@ export function VisualizePageProvider({ getService, getPageObjects, updateBaseli

async setIsFilteredByCollarCheckbox(value = true) {
await retry.try(async () => {
const isChecked = await this.isChecked('isFilteredByCollarCheckbox');
const isChecked = await this.isSwitchChecked('isFilteredByCollarCheckbox');
if (isChecked !== value) {
await testSubjects.click('isFilteredByCollarCheckbox');
throw new Error('isFilteredByCollar not set correctly');
Expand Down
8 changes: 5 additions & 3 deletions test/functional/services/saved_query_management_component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,17 @@ export function SavedQueryManagementComponentProvider({ getService }: FtrProvide
await testSubjects.setValue('saveQueryFormDescription', description);

const currentIncludeFiltersValue =
(await testSubjects.getAttribute('saveQueryFormIncludeFiltersOption', 'checked')) ===
(await testSubjects.getAttribute('saveQueryFormIncludeFiltersOption', 'aria-checked')) ===
'true';
if (currentIncludeFiltersValue !== includeFilters) {
await testSubjects.click('saveQueryFormIncludeFiltersOption');
}

const currentIncludeTimeFilterValue =
(await testSubjects.getAttribute('saveQueryFormIncludeTimeFilterOption', 'checked')) ===
'true';
(await testSubjects.getAttribute(
'saveQueryFormIncludeTimeFilterOption',
'aria-checked'
)) === 'true';
if (currentIncludeTimeFilterValue !== includeTimeFilter) {
await testSubjects.click('saveQueryFormIncludeTimeFilterOption');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"license": "Apache-2.0",
"dependencies": {
"@elastic/eui": "14.8.0",
"@elastic/eui": "14.9.0",
"react": "^16.8.0",
"react-dom": "^16.8.0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"license": "Apache-2.0",
"dependencies": {
"@elastic/eui": "14.8.0",
"@elastic/eui": "14.9.0",
"react": "^16.8.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"license": "Apache-2.0",
"dependencies": {
"@elastic/eui": "14.8.0",
"@elastic/eui": "14.9.0",
"react": "^16.8.0"
},
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"license": "Apache-2.0",
"dependencies": {
"@elastic/eui": "14.8.0",
"@elastic/eui": "14.9.0",
"react": "^16.8.0"
},
"scripts": {
Expand Down
Loading

0 comments on commit faf77b2

Please sign in to comment.