[Management] Improve messaging with no index patterns (#16718)

* Improve messaging with no index patterns

* Updated copy

* Adjust messaging
This commit is contained in:
Chris Roberson 2018-02-16 10:17:19 -05:00 committed by GitHub
parent 7164adb282
commit dd7241a501
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 78 additions and 8 deletions

View file

@ -87,3 +87,31 @@ exports[`StatusMessage should render without a query 1`] = `
</EuiTextColor>
</EuiText>
`;
exports[`StatusMessage should show that no indices exist 1`] = `
<EuiText
size="s"
>
<EuiTextColor
color="default"
>
<span>
No Elasticsearch indices match your pattern.
</span>
</EuiTextColor>
</EuiText>
`;
exports[`StatusMessage should show that system indices exist 1`] = `
<EuiText
size="s"
>
<EuiTextColor
color="default"
>
<span>
No Elasticsearch indices match your pattern. To view the matching system indices, toggle the switch in the upper right.
</span>
</EuiTextColor>
</EuiText>
`;

View file

@ -69,4 +69,28 @@ describe('StatusMessage', () => {
expect(component).toMatchSnapshot();
});
it('should show that system indices exist', () => {
const component = shallow(
<StatusMessage
matchedIndices={[]}
isIncludingSystemIndices={false}
query={''}
/>
);
expect(component).toMatchSnapshot();
});
it('should show that no indices exist', () => {
const component = shallow(
<StatusMessage
matchedIndices={[]}
isIncludingSystemIndices={true}
query={''}
/>
);
expect(component).toMatchSnapshot();
});
});

View file

@ -8,10 +8,11 @@ import {
export const StatusMessage = ({
matchedIndices: {
allIndices,
exactMatchedIndices,
partialMatchedIndices
allIndices = [],
exactMatchedIndices = [],
partialMatchedIndices = []
},
isIncludingSystemIndices,
query,
}) => {
let statusIcon;
@ -21,13 +22,29 @@ export const StatusMessage = ({
if (query.length === 0) {
statusIcon = null;
statusColor = 'default';
statusMessage = allIndices.length > 1
? (
if (allIndices.length > 1) {
statusMessage = (
<span>
Your index pattern can match any of your <strong>{allIndices.length} indices</strong>, below.
</span>
)
: (<span>You only have a single index. You can create an index pattern to match it.</span>);
);
}
else if (!isIncludingSystemIndices) {
statusMessage = (
<span>
No Elasticsearch indices match your pattern. To view the matching system indices, toggle the switch in the upper right.
</span>
);
}
else {
// This should never really happen but let's handle it just in case
statusMessage = (
<span>
No Elasticsearch indices match your pattern.
</span>
);
}
}
else if (exactMatchedIndices.length) {
statusIcon = 'check';

View file

@ -112,7 +112,7 @@ export class StepIndexPattern extends Component {
}
renderStatusMessage(matchedIndices) {
const { query, isLoadingIndices, indexPatternExists } = this.state;
const { query, isLoadingIndices, indexPatternExists, isIncludingSystemIndices } = this.state;
if (isLoadingIndices || indexPatternExists) {
return null;
@ -121,6 +121,7 @@ export class StepIndexPattern extends Component {
return (
<StatusMessage
matchedIndices={matchedIndices}
isIncludingSystemIndices={isIncludingSystemIndices}
query={query}
/>
);