Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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 @@ -88,6 +88,7 @@ export interface FlyoutState {
conflictedSavedObjectsLinkedToSavedSearches?: any[];
conflictedSearchDocs?: any[];
unmatchedReferences?: ProcessedImportResponse['unmatchedReferences'];
unmatchedReferencesTablePagination: { pageIndex: number; pageSize: number };
failedImports?: ProcessedImportResponse['failedImports'];
successfulImports?: ProcessedImportResponse['successfulImports'];
conflictingRecord?: ConflictingRecord;
Expand Down Expand Up @@ -115,6 +116,10 @@ export class Flyout extends Component<FlyoutProps, FlyoutState> {
conflictedSavedObjectsLinkedToSavedSearches: undefined,
conflictedSearchDocs: undefined,
unmatchedReferences: undefined,
unmatchedReferencesTablePagination: {
pageIndex: 0,
pageSize: 5,
},
conflictingRecord: undefined,
error: undefined,
file: undefined,
Expand Down Expand Up @@ -467,7 +472,7 @@ export class Flyout extends Component<FlyoutProps, FlyoutState> {
};

renderUnmatchedReferences() {
const { unmatchedReferences } = this.state;
const { unmatchedReferences, unmatchedReferencesTablePagination: tablePagination } = this.state;

if (!unmatchedReferences) {
return null;
Expand Down Expand Up @@ -527,22 +532,28 @@ export class Flyout extends Component<FlyoutProps, FlyoutState> {
{ defaultMessage: 'New index pattern' }
),
render: (id: string) => {
const options = this.state.indexPatterns!.map(
(indexPattern) =>
({
text: indexPattern.title,
value: indexPattern.id,
'data-test-subj': `indexPatternOption-${indexPattern.title}`,
} as { text: string; value: string; 'data-test-subj'?: string })
);

options.unshift({
text: '-- Skip Import --',
value: '',
});
const options = [
{
text: '-- Skip Import --',
value: '',
},
...this.state.indexPatterns!.map(
(indexPattern) =>
({
text: indexPattern.title,
value: indexPattern.id,
'data-test-subj': `indexPatternOption-${indexPattern.title}`,
} as { text: string; value: string; 'data-test-subj'?: string })
),
];

const selectedValue =
unmatchedReferences?.find((unmatchedRef) => unmatchedRef.existingIndexPatternId === id)
?.newIndexPatternId ?? '';

return (
<EuiSelect
value={selectedValue}
data-test-subj={`managementChangeIndexSelection-${id}`}
onChange={(e) => this.onIndexChanged(id, e)}
options={options}
Expand All @@ -553,6 +564,7 @@ export class Flyout extends Component<FlyoutProps, FlyoutState> {
];

const pagination = {
...tablePagination,
pageSizeOptions: [5, 10, 25],
};

Expand All @@ -561,6 +573,16 @@ export class Flyout extends Component<FlyoutProps, FlyoutState> {
items={unmatchedReferences as any[]}
columns={columns}
pagination={pagination}
onTableChange={({ page }) => {
if (page) {
this.setState({
unmatchedReferencesTablePagination: {
pageSize: page.size,
pageIndex: page.index,
},
});
}
}}
/>
);
}
Expand Down
43 changes: 31 additions & 12 deletions test/functional/apps/management/_import_objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,21 +421,40 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
expect(isSavedObjectImported).to.be(true);
});

it('should import saved objects with index patterns when index patterns does not exists', async () => {
// First, we need to delete the index pattern
await PageObjects.savedObjects.clickCheckboxByTitle('logstash-*');
await PageObjects.savedObjects.clickDelete();

// Then, import the objects
it('should preserve index patterns selection when switching between pages', async () => {
await PageObjects.savedObjects.importFile(
path.join(__dirname, 'exports', '_import_objects_with_index_patterns.json')
path.join(__dirname, 'exports', '_import_objects_missing_all_index_patterns.json')
);
await PageObjects.savedObjects.checkImportSucceeded();
await PageObjects.savedObjects.clickImportDone();

const objects = await PageObjects.savedObjects.getRowTitles();
const isSavedObjectImported = objects.includes('saved object imported with index pattern');
expect(isSavedObjectImported).to.be(true);
await PageObjects.savedObjects.setOverriddenIndexPatternValue(
'missing-index-pattern-1',
'index-pattern-test-1'
);

await testSubjects.click('pagination-button-next');

await PageObjects.savedObjects.setOverriddenIndexPatternValue(
'missing-index-pattern-7',
'index-pattern-test-2'
);

await testSubjects.click('pagination-button-previous');

const selectedIdForMissingIndexPattern1 = await testSubjects.getAttribute(
'managementChangeIndexSelection-missing-index-pattern-1',
'value'
);

expect(selectedIdForMissingIndexPattern1).to.eql('f1e4c910-a2e6-11e7-bb30-233be9be6a20');

await testSubjects.click('pagination-button-next');

const selectedIdForMissingIndexPattern7 = await testSubjects.getAttribute(
'managementChangeIndexSelection-missing-index-pattern-7',
'value'
);

expect(selectedIdForMissingIndexPattern7).to.eql('f1e4c910-a2e6-11e7-bb30-233be9be6a87');
});
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
[
{
"_id": "test-vis-1",
"_type": "visualization",
"_source": {
"title": "Test VIS 1",
"visState": "{\"title\":\"test vis 1\",\"type\":\"histogram\"}",
"uiStateJSON": "{}",
"description": "",
"version": 1,
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{\"index\":\"missing-index-pattern-1\",\"query\":{}}"
}
},
"_meta": {
"savedObjectVersion": 2
}
},
{
"_id": "test-vis-2",
"_type": "visualization",
"_source": {
"title": "Test VIS 2",
"visState": "{\"title\":\"test vis 2\",\"type\":\"histogram\"}",
"uiStateJSON": "{}",
"description": "",
"version": 1,
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{\"index\":\"missing-index-pattern-2\",\"query\":{}}"
}
},
"_meta": {
"savedObjectVersion": 2
}
},
{
"_id": "test-vis-3",
"_type": "visualization",
"_source": {
"title": "Test VIS 3",
"visState": "{\"title\":\"test vis 3\",\"type\":\"histogram\"}",
"uiStateJSON": "{}",
"description": "",
"version": 1,
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{\"index\":\"missing-index-pattern-3\",\"query\":{}}"
}
},
"_meta": {
"savedObjectVersion": 2
}
},
{
"_id": "test-vis-4",
"_type": "visualization",
"_source": {
"title": "Test VIS 4",
"visState": "{\"title\":\"test vis 4\",\"type\":\"histogram\"}",
"uiStateJSON": "{}",
"description": "",
"version": 1,
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{\"index\":\"missing-index-pattern-4\",\"query\":{}}"
}
},
"_meta": {
"savedObjectVersion": 2
}
},
{
"_id": "test-vis-5",
"_type": "visualization",
"_source": {
"title": "Test VIS 5",
"visState": "{\"title\":\"test vis 5\",\"type\":\"histogram\"}",
"uiStateJSON": "{}",
"description": "",
"version": 1,
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{\"index\":\"missing-index-pattern-5\",\"query\":{}}"
}
},
"_meta": {
"savedObjectVersion": 2
}
},
{
"_id": "test-vis-6",
"_type": "visualization",
"_source": {
"title": "Test VIS 6",
"visState": "{\"title\":\"test vis 6\",\"type\":\"histogram\"}",
"uiStateJSON": "{}",
"description": "",
"version": 1,
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{\"index\":\"missing-index-pattern-6\",\"query\":{}}"
}
},
"_meta": {
"savedObjectVersion": 2
}
},
{
"_id": "test-vis-7",
"_type": "visualization",
"_source": {
"title": "Test VIS 7",
"visState": "{\"title\":\"test vis 7\",\"type\":\"histogram\"}",
"uiStateJSON": "{}",
"description": "",
"version": 1,
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{\"index\":\"missing-index-pattern-7\",\"query\":{}}"
}
},
"_meta": {
"savedObjectVersion": 2
}
}
]
6 changes: 6 additions & 0 deletions test/functional/page_objects/management/saved_objects_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ export function SavedObjectsPageProvider({ getService, getPageObjects }: FtrProv
}
}

async setOverriddenIndexPatternValue(oldName: string, newName: string) {
const select = await testSubjects.find(`managementChangeIndexSelection-${oldName}`);
const option = await testSubjects.findDescendant(`indexPatternOption-${newName}`, select);
await option.click();
}

async clickCopyToSpaceByTitle(title: string) {
const table = keyBy(await this.getElementsInTable(), 'title');
// should we check if table size > 0 and log error if not?
Expand Down