Skip to content

Commit

Permalink
Revert "[Look&Feel] Updated Discover No Results panel (opensearch-pro…
Browse files Browse the repository at this point in the history
  • Loading branch information
abbyhu2000 committed Sep 24, 2024
1 parent e388b25 commit 52c36b9
Show file tree
Hide file tree
Showing 2 changed files with 163 additions and 143 deletions.
2 changes: 0 additions & 2 deletions changelogs/fragments/7891.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,162 +28,184 @@
* under the License.
*/

import React from 'react';
import { I18nProvider } from '@osd/i18n/react';
import React, { Fragment } from 'react';
import { FormattedMessage, I18nProvider } from '@osd/i18n/react';

import { EuiEmptyPrompt, EuiPanel, EuiText } from '@elastic/eui';
import { i18n } from '@osd/i18n';
import {
EuiCallOut,
EuiCode,
EuiDescriptionList,
EuiLink,
EuiPanel,
EuiSpacer,
EuiText,
} from '@elastic/eui';
import { getServices } from '../../../opensearch_dashboards_services';

interface Props {
timeFieldName?: string;
queryLanguage?: string;
}

export const DiscoverNoResults = ({ timeFieldName, queryLanguage }: Props) => {
// Commented out due to no usage in code
// See: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/8149
//
// let luceneQueryMessage;
//
// if (queryLanguage === 'lucene') {
// const searchExamples = [
// {
// description: <EuiCode>200</EuiCode>,
// title: (
// <EuiText size="s">
// <strong>
// <FormattedMessage
// id="discover.noResults.searchExamples.anyField200StatusCodeExampleTitle"
// defaultMessage="Find requests that contain the number 200, in any field"
// />
// </strong>
// </EuiText>
// ),
// },
// {
// description: <EuiCode>status:200</EuiCode>,
// title: (
// <EuiText size="s">
// <strong>
// <FormattedMessage
// id="discover.noResults.searchExamples.statusField200StatusCodeExampleTitle"
// defaultMessage="Find 200 in the status field"
// />
// </strong>
// </EuiText>
// ),
// },
// {
// description: <EuiCode>status:[400 TO 499]</EuiCode>,
// title: (
// <EuiText size="s">
// <strong>
// <FormattedMessage
// id="discover.noResults.searchExamples.400to499StatusCodeExampleTitle"
// defaultMessage="Find all status codes between 400-499"
// />
// </strong>
// </EuiText>
// ),
// },
// {
// description: <EuiCode>status:[400 TO 499] AND extension:PHP</EuiCode>,
// title: (
// <EuiText size="s">
// <strong>
// <FormattedMessage
// id="discover.noResults.searchExamples.400to499StatusCodeWithPhpExtensionExampleTitle"
// defaultMessage="Find status codes 400-499 with the extension php"
// />
// </strong>
// </EuiText>
// ),
// },
// {
// description: <EuiCode>status:[400 TO 499] AND (extension:php OR extension:html)</EuiCode>,
// title: (
// <EuiText size="s">
// <strong>
// <FormattedMessage
// id="discover.noResults.searchExamples.400to499StatusCodeWithPhpOrHtmlExtensionExampleTitle"
// defaultMessage="Find status codes 400-499 with the extension php or html"
// />
// </strong>
// </EuiText>
// ),
// },
// ];
//
// luceneQueryMessage = (
// <Fragment>
// <EuiSpacer size="xl" />
//
// <EuiText size="s">
// <h3>
// <FormattedMessage
// id="discover.noResults.searchExamples.refineYourQueryTitle"
// defaultMessage="Refine your query"
// />
// </h3>
//
// <p>
// <FormattedMessage
// id="discover.noResults.searchExamples.howTosearchForWebServerLogsDescription"
// defaultMessage="The search bar at the top uses OpenSearch&rsquo;s support for Lucene {queryStringSyntaxLink}.
// Here are some examples of how you can search for web server logs that have been parsed into a few fields."
// values={{
// queryStringSyntaxLink: (
// <EuiLink
// target="_blank"
// href={getServices().docLinks.links.opensearch.queryDSL.base}
// >
// <FormattedMessage
// id="discover.noResults.searchExamples.queryStringSyntaxLinkText"
// defaultMessage="Query String syntax"
// />
// </EuiLink>
// ),
// }}
// />
// </p>
// </EuiText>
//
// <EuiSpacer size="m" />
//
// <EuiDescriptionList type="column" listItems={searchExamples} />
//
// <EuiSpacer size="xl" />
// </Fragment>
// );
// }
let timeFieldMessage;

if (timeFieldName) {
timeFieldMessage = (
<Fragment>
<EuiSpacer size="xl" />

<EuiText size="s">
<h2 data-test-subj="discoverNoResultsTimefilter">
<FormattedMessage
id="discover.noResults.expandYourTimeRangeTitle"
defaultMessage="Expand your time range"
/>
</h2>

<p>
<FormattedMessage
id="discover.noResults.queryMayNotMatchTitle"
defaultMessage="One or more of the indices you&rsquo;re looking at contains a date field. Your query may
not match anything in the current time range, or there may not be any data at all in
the currently selected time range. You can try changing the time range to one which contains data."
/>
</p>
</EuiText>
</Fragment>
);
}

let luceneQueryMessage;

if (queryLanguage === 'lucene') {
const searchExamples = [
{
description: <EuiCode>200</EuiCode>,
title: (
<EuiText size="s">
<strong>
<FormattedMessage
id="discover.noResults.searchExamples.anyField200StatusCodeExampleTitle"
defaultMessage="Find requests that contain the number 200, in any field"
/>
</strong>
</EuiText>
),
},
{
description: <EuiCode>status:200</EuiCode>,
title: (
<EuiText size="s">
<strong>
<FormattedMessage
id="discover.noResults.searchExamples.statusField200StatusCodeExampleTitle"
defaultMessage="Find 200 in the status field"
/>
</strong>
</EuiText>
),
},
{
description: <EuiCode>status:[400 TO 499]</EuiCode>,
title: (
<EuiText size="s">
<strong>
<FormattedMessage
id="discover.noResults.searchExamples.400to499StatusCodeExampleTitle"
defaultMessage="Find all status codes between 400-499"
/>
</strong>
</EuiText>
),
},
{
description: <EuiCode>status:[400 TO 499] AND extension:PHP</EuiCode>,
title: (
<EuiText size="s">
<strong>
<FormattedMessage
id="discover.noResults.searchExamples.400to499StatusCodeWithPhpExtensionExampleTitle"
defaultMessage="Find status codes 400-499 with the extension php"
/>
</strong>
</EuiText>
),
},
{
description: <EuiCode>status:[400 TO 499] AND (extension:php OR extension:html)</EuiCode>,
title: (
<EuiText size="s">
<strong>
<FormattedMessage
id="discover.noResults.searchExamples.400to499StatusCodeWithPhpOrHtmlExtensionExampleTitle"
defaultMessage="Find status codes 400-499 with the extension php or html"
/>
</strong>
</EuiText>
),
},
];

luceneQueryMessage = (
<Fragment>
<EuiSpacer size="xl" />

<EuiText size="s">
<h3>
<FormattedMessage
id="discover.noResults.searchExamples.refineYourQueryTitle"
defaultMessage="Refine your query"
/>
</h3>

<p>
<FormattedMessage
id="discover.noResults.searchExamples.howTosearchForWebServerLogsDescription"
defaultMessage="The search bar at the top uses OpenSearch&rsquo;s support for Lucene {queryStringSyntaxLink}.
Here are some examples of how you can search for web server logs that have been parsed into a few fields."
values={{
queryStringSyntaxLink: (
<EuiLink
target="_blank"
href={getServices().docLinks.links.opensearch.queryDSL.base}
>
<FormattedMessage
id="discover.noResults.searchExamples.queryStringSyntaxLinkText"
defaultMessage="Query String syntax"
/>
</EuiLink>
),
}}
/>
</p>
</EuiText>

<EuiSpacer size="m" />

<EuiDescriptionList type="column" listItems={searchExamples} />

<EuiSpacer size="xl" />
</Fragment>
);
}

return (
<I18nProvider>
<EuiPanel hasBorder={false} hasShadow={false} color="transparent">
<EuiEmptyPrompt
iconType="alert"
iconColor="default"
data-test-subj="discoverNoResults"
<EuiCallOut
title={
<EuiText size="s">
<h2>
{i18n.translate('discover.emptyPrompt.title', {
defaultMessage: 'No Results',
})}
</h2>
</EuiText>
}
body={
<EuiText size="s" data-test-subj="discoverNoResultsTimefilter">
<p>
{i18n.translate('discover.emptyPrompt.body', {
defaultMessage:
'Try selecting a different data source, expanding your time range or modifying the query & filters.',
})}
</p>
</EuiText>
<FormattedMessage
id="discover.noResults.searchExamples.noResultsMatchSearchCriteriaTitle"
defaultMessage="No results match your search criteria"
/>
}
color="warning"
iconType="help"
data-test-subj="discoverNoResults"
/>
{timeFieldMessage}
{luceneQueryMessage}
</EuiPanel>
</I18nProvider>
);
Expand Down

0 comments on commit 52c36b9

Please sign in to comment.