Skip to content

Commit

Permalink
[data view mgmt] fix field refresh when index pattern is changed. (#1…
Browse files Browse the repository at this point in the history
…50403)

Data view management now updates the field list of an edited data view
upon save.

Closes: #150248
  • Loading branch information
mattkime authored Feb 8, 2023
1 parent 447cbfd commit a2c5bf8
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ export const EditIndexPattern = withRouter(
const isRollup = new URLSearchParams(useLocation().search).get('type') === 'rollup';
const displayIndexPatternEditor = showEditDialog ? (
<IndexPatternEditor
onSave={() => setShowEditDialog(false)}
onSave={() => {
setFields(indexPattern.getNonScriptedFields());
setShowEditDialog(false);
}}
onCancel={() => setShowEditDialog(false)}
defaultTypeIsRollup={isRollup}
editData={indexPattern}
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 @@ -220,7 +220,7 @@ const getItems = (conflictDescriptions: IndexedFieldItem['conflictDescriptions']
};

export const renderFieldName = (field: IndexedFieldItem, timeFieldName?: string) => (
<span>
<span data-test-subj={`field-name-${field.name}`}>
{field.name}
{field.info && field.info.length ? (
<span>
Expand Down
31 changes: 31 additions & 0 deletions test/functional/apps/management/_index_pattern_create_delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,20 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
describe('creating and deleting default index', function describeIndexTests() {
before(async function () {
await esArchiver.emptyKibanaIndex();
await esArchiver.loadIfNeeded(
'test/functional/fixtures/es_archiver/kibana_sample_data_flights_index_pattern'
);
await kibanaServer.uiSettings.replace({});
await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaIndexPatterns();
});

after(async function () {
await esArchiver.unload(
'test/functional/fixtures/es_archiver/kibana_sample_data_flights_index_pattern'
);
});

describe('can open and close editor', function () {
it('without creating index pattern', async function () {
await PageObjects.settings.clickKibanaIndexPatterns();
Expand Down Expand Up @@ -157,6 +166,28 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
});

describe('index pattern edit', function () {
it('should update field list', async function () {
await PageObjects.settings.editIndexPattern(
'kibana_sample_data_flights',
'timestamp',
undefined,
true
);

await retry.try(async () => {
// verify initial field list
expect(await testSubjects.exists('field-name-AvgTicketPrice')).to.be(true);
});

await PageObjects.settings.editIndexPattern('logstash-*', '@timestamp', undefined, true);
await retry.try(async () => {
// verify updated field list
expect(await testSubjects.exists('field-name-agent')).to.be(true);
});
});
});

describe('index pattern deletion', function indexDelete() {
before(function () {
const expectedAlertText = 'Delete data view';
Expand Down

0 comments on commit a2c5bf8

Please sign in to comment.