Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DataView] show empty matching sources when no matched index pattern #195537

Merged
merged 14 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 11 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
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ export const PreviewPanel = ({ type, allowHidden, title = '', matchedIndices$ }:
currentViewMode = ViewMode.allIndices;
}

const indicesListContent = currentlyVisibleIndices.length ? (
const indicesListContent = matched.allIndices ? (
<IndicesList
data-test-subj="createIndexPatternStep1IndicesList"
query={title}
indices={currentlyVisibleIndices}
indices={currentlyVisibleIndices.length ? currentlyVisibleIndices : matched.allIndices}
isExactMatch={(indexName) =>
title.length > 0 && matched.exactMatchedIndices.some((index) => index.name === indexName)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ describe('getMatchedIndices', () => {
]);
});

it('should return all indices as visible if there are no exact or partial', () => {
it('should return empty array if there are no exact or partial', () => {
const { visibleIndices } = getMatchedIndices(indices, [], [], true);

expect(visibleIndices).toEqual(indices);
expect(visibleIndices).toEqual([]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ export function getMatchedIndices(
// 1) If there are exact matches, show those as the query is good to go
// 2) If there are no exact matches, but there are partial matches,
// show the partial matches
// 3) If there are no exact or partial matches, just show all indices
let visibleIndices;
// 3) If there are no exact or partial matches, show empty indices
let visibleIndices: MatchedItem[];
if (exactMatchedIndices.length) {
visibleIndices = exactMatchedIndices;
} else if (partialMatchedIndices.length) {
visibleIndices = partialMatchedIndices;
} else {
visibleIndices = allIndices;
visibleIndices = [];
}

return {
Expand Down