mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Controls] Undefine selected field when data view changes (#129611)
* Undefine field when dataview changes * Adjust functional tests * Only set state if new data view selected * Clean up async code based on nit
This commit is contained in:
parent
9295f13dd9
commit
d89343d922
5 changed files with 25 additions and 9 deletions
|
@ -85,10 +85,13 @@ export const OptionsListEditor = ({
|
|||
selectedDataViewId={dataView?.id}
|
||||
onChangeDataViewId={(dataViewId) => {
|
||||
setLastUsedDataViewId?.(dataViewId);
|
||||
if (dataViewId === dataView?.id) return;
|
||||
|
||||
onChange({ dataViewId });
|
||||
get(dataViewId).then((newDataView) =>
|
||||
setState((s) => ({ ...s, dataView: newDataView }))
|
||||
);
|
||||
setState((s) => ({ ...s, fieldName: undefined }));
|
||||
get(dataViewId).then((newDataView) => {
|
||||
setState((s) => ({ ...s, dataView: newDataView }));
|
||||
});
|
||||
}}
|
||||
trigger={{
|
||||
label: state.dataView?.title ?? OptionsListStrings.editor.getNoDataViewTitle(),
|
||||
|
|
|
@ -81,10 +81,13 @@ export const RangeSliderEditor = ({
|
|||
selectedDataViewId={dataView?.id}
|
||||
onChangeDataViewId={(dataViewId) => {
|
||||
setLastUsedDataViewId?.(dataViewId);
|
||||
if (dataViewId === dataView?.id) return;
|
||||
|
||||
onChange({ dataViewId });
|
||||
get(dataViewId).then((newDataView) =>
|
||||
setState((s) => ({ ...s, dataView: newDataView }))
|
||||
);
|
||||
setState((s) => ({ ...s, fieldName: undefined }));
|
||||
get(dataViewId).then((newDataView) => {
|
||||
setState((s) => ({ ...s, dataView: newDataView }));
|
||||
});
|
||||
}}
|
||||
trigger={{
|
||||
label: state.dataView?.title ?? RangeSliderStrings.editor.getNoDataViewTitle(),
|
||||
|
|
|
@ -80,10 +80,13 @@ export const TimeSliderEditor = ({
|
|||
selectedDataViewId={dataView?.id}
|
||||
onChangeDataViewId={(dataViewId) => {
|
||||
setLastUsedDataViewId?.(dataViewId);
|
||||
if (dataViewId === dataView?.id) return;
|
||||
|
||||
onChange({ dataViewId });
|
||||
get(dataViewId).then((newDataView) =>
|
||||
setState((s) => ({ ...s, dataView: newDataView }))
|
||||
);
|
||||
setState((s) => ({ ...s, fieldName: undefined }));
|
||||
get(dataViewId).then((newDataView) => {
|
||||
setState((s) => ({ ...s, dataView: newDataView }));
|
||||
});
|
||||
}}
|
||||
trigger={{
|
||||
label: state.dataView?.title ?? TimeSliderStrings.editor.getNoDataViewTitle(),
|
||||
|
|
|
@ -100,7 +100,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
const firstId = (await dashboardControls.getAllControlIds())[0];
|
||||
await dashboardControls.editExistingControl(firstId);
|
||||
|
||||
const saveButton = await testSubjects.find('control-editor-save');
|
||||
expect(await saveButton.isEnabled()).to.be(true);
|
||||
await dashboardControls.controlsEditorSetDataView('animals-*');
|
||||
expect(await saveButton.isEnabled()).to.be(false);
|
||||
await dashboardControls.controlsEditorSetfield('animal.keyword');
|
||||
await dashboardControls.controlEditorSave();
|
||||
|
||||
|
|
|
@ -104,7 +104,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
it('can edit range slider control', async () => {
|
||||
const firstId = (await dashboardControls.getAllControlIds())[0];
|
||||
await dashboardControls.editExistingControl(firstId);
|
||||
|
||||
const saveButton = await testSubjects.find('control-editor-save');
|
||||
expect(await saveButton.isEnabled()).to.be(true);
|
||||
await dashboardControls.controlsEditorSetDataView('kibana_sample_data_flights');
|
||||
expect(await saveButton.isEnabled()).to.be(false);
|
||||
await dashboardControls.controlsEditorSetfield('dayOfWeek');
|
||||
await dashboardControls.controlEditorSave();
|
||||
await dashboardControls.rangeSliderWaitForLoading();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue