mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
support local data views in runtime field editor (#134756)
This commit is contained in:
parent
ecd0933e8a
commit
1916efbb1c
3 changed files with 17 additions and 3 deletions
|
@ -158,7 +158,7 @@ export const FieldEditorFlyoutContentContainer = ({
|
|||
dataView.deleteFieldFormat(updatedField.name);
|
||||
}
|
||||
|
||||
await dataViews.updateSavedObject(dataView).then(() => {
|
||||
const afterSave = () => {
|
||||
const message = i18n.translate('indexPatternFieldEditor.deleteField.savedHeader', {
|
||||
defaultMessage: "Saved '{fieldName}'",
|
||||
values: { fieldName: updatedField.name },
|
||||
|
@ -166,6 +166,15 @@ export const FieldEditorFlyoutContentContainer = ({
|
|||
notifications.toasts.addSuccess(message);
|
||||
setIsSaving(false);
|
||||
onSave(editedField);
|
||||
};
|
||||
|
||||
if (!dataView.isPersisted()) {
|
||||
afterSave();
|
||||
return;
|
||||
}
|
||||
|
||||
await dataViews.updateSavedObject(dataView).then(() => {
|
||||
afterSave();
|
||||
});
|
||||
} catch (e) {
|
||||
const title = i18n.translate('indexPatternFieldEditor.save.errorTitle', {
|
||||
|
|
|
@ -32,7 +32,9 @@ export async function removeFields(
|
|||
} catch {}
|
||||
|
||||
try {
|
||||
await services.dataViews.updateSavedObject(dataView);
|
||||
if (dataView.isPersisted()) {
|
||||
await services.dataViews.updateSavedObject(dataView);
|
||||
}
|
||||
} catch (e) {
|
||||
const title = i18n.translate('indexPatternFieldEditor.save.deleteErrorTitle', {
|
||||
defaultMessage: 'Failed to save field removal',
|
||||
|
|
|
@ -113,7 +113,10 @@ describe('DataViewFieldEditorPlugin', () => {
|
|||
};
|
||||
const { openDeleteModal } = await plugin.start(coreStartMocked, pluginStartMocked);
|
||||
|
||||
const indexPatternMock = { removeRuntimeField: removeFieldSpy } as unknown as DataView;
|
||||
const indexPatternMock = {
|
||||
removeRuntimeField: removeFieldSpy,
|
||||
isPersisted: () => true,
|
||||
} as unknown as DataView;
|
||||
|
||||
openDeleteModal({
|
||||
onDelete: onDeleteSpy,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue