Skip to content

Commit

Permalink
Revert "[Manual backport 2.x] [Discover]Sample Queries and Saved Quer…
Browse files Browse the repository at this point in the history
…ies in No Results Page opensearch-project#8616  (opensearch-project#8663)"

This reverts commit 74a69d6.
  • Loading branch information
ashwin-pc committed Oct 19, 2024
1 parent bde23d9 commit c43dcfe
Show file tree
Hide file tree
Showing 54 changed files with 176 additions and 1,133 deletions.
2 changes: 0 additions & 2 deletions changelogs/fragments/8616.yml

This file was deleted.

2 changes: 0 additions & 2 deletions changelogs/fragments/8651.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.context-nav-wrapper {
border: none !important;
border-top-right-radius: $euiSizeL;
border-bottom-right-radius: $euiSizeL;
background-color: $euiSideNavBackgroundColor;
overflow: hidden;
box-shadow: 1px 0 0 $euiBorderColor !important;

.nav-link-item {
padding: $euiSizeS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ import { includes } from 'lodash';
import { IndexPatternsContract } from './index_patterns';
import { UiSettingsCommon } from '../types';

export type EnsureDefaultIndexPattern = (
shouldRedirect?: boolean
) => Promise<unknown | void> | undefined;
export type EnsureDefaultIndexPattern = () => Promise<unknown> | undefined;

export const createEnsureDefaultIndexPattern = (
uiSettings: UiSettingsCommon,
Expand All @@ -44,10 +42,7 @@ export const createEnsureDefaultIndexPattern = (
* Checks whether a default index pattern is set and exists and defines
* one otherwise.
*/
return async function ensureDefaultIndexPattern(
this: IndexPatternsContract,
shouldRedirect: boolean = true
) {
return async function ensureDefaultIndexPattern(this: IndexPatternsContract) {
const patterns = await this.getIds();
let defaultId = await uiSettings.get('defaultIndex');
let defined = !!defaultId;
Expand All @@ -67,8 +62,7 @@ export const createEnsureDefaultIndexPattern = (
defaultId = patterns[0];
await uiSettings.set('defaultIndex', defaultId);
} else {
if (shouldRedirect) return onRedirectNoIndexPattern();
else return;
return onRedirectNoIndexPattern();
}
};
};
11 changes: 1 addition & 10 deletions src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,7 @@ import {
} from '../common';

import { FilterLabel } from './ui';
export {
createEditor,
DefaultInput,
DQLBody,
SingleLineInput,
DatasetSelector,
AdvancedSelector,
NoIndexPatternsPanel,
DatasetSelectorAppearance,
} from './ui';
export { createEditor, DefaultInput, DQLBody, SingleLineInput } from './ui';

import {
generateFilters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,6 @@ export class DatasetService {
return Number(this.sessionStorage.get('lastCacheTime')) || undefined;
}

public removeFromRecentDatasets(datasetId: string): void {
this.recentDatasets.del(datasetId);
this.serializeRecentDatasets();
}

private setLastCacheTime(time: number): void {
this.sessionStorage.set('lastCacheTime', time);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

import { SavedObjectsClientContract } from 'opensearch-dashboards/public';
import { i18n } from '@osd/i18n';
import { DataSourceAttributes } from '../../../../../../data_source/common/data_sources';
import {
DEFAULT_DATA,
Expand Down Expand Up @@ -71,29 +70,6 @@ export const indexPatternTypeConfig: DatasetTypeConfig = {
}
return ['kuery', 'lucene', 'PPL', 'SQL'];
},

getSampleQueries: (dataset: Dataset, language: string) => {
switch (language) {
case 'PPL':
return [
{
title: i18n.translate('data.indexPatternType.sampleQuery.basicPPLQuery', {
defaultMessage: 'Sample query for PPL',
}),
query: `source = ${dataset.title}`,
},
];
case 'SQL':
return [
{
title: i18n.translate('data.indexPatternType.sampleQuery.basicSQLQuery', {
defaultMessage: 'Sample query for SQL',
}),
query: `SELECT * FROM ${dataset.title} LIMIT 10`,
},
];
}
},
};

const fetchIndexPatterns = async (client: SavedObjectsClientContract): Promise<DataStructure[]> => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import { SavedObjectsClientContract } from 'opensearch-dashboards/public';
import { map } from 'rxjs/operators';
import { i18n } from '@osd/i18n';
import {
DEFAULT_DATA,
DataStructure,
Expand Down Expand Up @@ -89,29 +88,6 @@ export const indexTypeConfig: DatasetTypeConfig = {
supportedLanguages: (dataset: Dataset): string[] => {
return ['SQL', 'PPL'];
},

getSampleQueries: (dataset: Dataset, language: string) => {
switch (language) {
case 'PPL':
return [
{
title: i18n.translate('data.indexType.sampleQuery.basicPPLQuery', {
defaultMessage: 'Sample query for PPL',
}),
query: `source = ${dataset.title}`,
},
];
case 'SQL':
return [
{
title: i18n.translate('data.indexType.sampleQuery.basicSQLQuery', {
defaultMessage: 'Sample query for SQL',
}),
query: `SELECT * FROM ${dataset.title} LIMIT 10`,
},
];
}
},
};

const fetchDataSources = async (client: SavedObjectsClientContract) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,4 @@ export interface DatasetTypeConfig {
* @see https://github.com/opensearch-project/OpenSearch-Dashboards/issues/8362.
*/
combineDataStructures?: (dataStructures: DataStructure[]) => DataStructure | undefined;
/**
* Returns a list of sample queries for this dataset type
*/
getSampleQueries?: (dataset: Dataset, language: string) => any;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { i18n } from '@osd/i18n';
import { LanguageConfig } from '../types';
import { ISearchInterceptor } from '../../../../search';

Expand All @@ -26,51 +25,5 @@ export const getDQLLanguageConfig = (
showDocLinks: true,
editorSupportedAppNames: ['discover'],
supportedAppNames: ['discover', 'dashboards', 'visualize', 'data-explorer', 'vis-builder', '*'],
sampleQueries: [
{
title: i18n.translate('data.dqlLanguage.sampleQuery.titleContainsWind', {
defaultMessage: 'The title field contains the word wind.',
}),
query: 'title: wind',
},
{
title: i18n.translate('data.dqlLanguage.sampleQuery.titleContainsWindOrWindy', {
defaultMessage: 'The title field contains the word wind or the word windy.',
}),
query: 'title: (wind OR windy)',
},
{
title: i18n.translate('data.dqlLanguage.sampleQuery.titleContainsPhraseWindRises', {
defaultMessage: 'The title field contains the phrase wind rises.',
}),
query: 'title: "wind rises"',
},
{
title: i18n.translate('data.dqlLanguage.sampleQuery.titleKeywordExactMatch', {
defaultMessage: 'The title.keyword field exactly matches The wind rises.',
}),
query: 'title.keyword: The wind rises',
},
{
title: i18n.translate('data.dqlLanguage.sampleQuery.titleFieldsContainWind', {
defaultMessage:
'Any field that starts with title (for example, title and title.keyword) contains the word wind',
}),
query: 'title*: wind',
},
{
title: i18n.translate('data.dqlLanguage.sampleQuery.articleTitleContainsWind', {
defaultMessage:
'The field that starts with article and ends with title contains the word wind. Matches the field article title.',
}),
query: 'article*title: wind',
},
{
title: i18n.translate('data.dqlLanguage.sampleQuery.descriptionFieldExists', {
defaultMessage: 'Documents in which the field description exists.',
}),
query: 'description:*',
},
],
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { i18n } from '@osd/i18n';
import { LanguageConfig } from '../types';
import { ISearchInterceptor } from '../../../../search';

Expand All @@ -26,51 +25,5 @@ export const getLuceneLanguageConfig = (
showDocLinks: true,
editorSupportedAppNames: ['discover'],
supportedAppNames: ['discover', 'dashboards', 'visualize', 'data-explorer', 'vis-builder', '*'],
sampleQueries: [
{
title: i18n.translate('data.luceneLanguage.sampleQuery.titleContainsWind', {
defaultMessage: 'The title field contains the word wind.',
}),
query: 'title: wind',
},
{
title: i18n.translate('data.luceneLanguage.sampleQuery.titleContainsWindOrWindy', {
defaultMessage: 'The title field contains the word wind or the word windy.',
}),
query: 'title: (wind OR windy)',
},
{
title: i18n.translate('data.luceneLanguage.sampleQuery.titleContainsPhraseWindRises', {
defaultMessage: 'The title field contains the phrase wind rises.',
}),
query: 'title: "wind rises"',
},
{
title: i18n.translate('data.luceneLanguage.sampleQuery.titleKeywordExactMatch', {
defaultMessage: 'The title.keyword field exactly matches The wind rises.',
}),
query: 'title.keyword: The wind rises',
},
{
title: i18n.translate('data.luceneLanguage.sampleQuery.titleFieldsContainWind', {
defaultMessage:
'Any field that starts with title (for example, title and title.keyword) contains the word wind',
}),
query: 'title*: wind',
},
{
title: i18n.translate('data.luceneLanguage.sampleQuery.articleTitleContainsWind', {
defaultMessage:
'The field that starts with article and ends with title contains the word wind. Matches the field article title.',
}),
query: 'article*title: wind',
},
{
title: i18n.translate('data.luceneLanguage.sampleQuery.descriptionFieldExists', {
defaultMessage: 'Documents in which the field description exists.',
}),
query: 'description:*',
},
],
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ export interface EditorEnhancements {
queryEditorExtension?: QueryEditorExtensionConfig;
}

export interface SampleQuery {
title: string;
query: string;
}

export interface LanguageConfig {
id: string;
title: string;
Expand All @@ -58,5 +53,4 @@ export interface LanguageConfig {
editorSupportedAppNames?: string[];
supportedAppNames?: string[];
hideDatePicker?: boolean;
sampleQueries?: SampleQuery[];
}
16 changes: 0 additions & 16 deletions src/plugins/data/public/ui/_common.scss

This file was deleted.

1 change: 0 additions & 1 deletion src/plugins/data/public/ui/_index.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@import "./common";
@import "./filter_bar/index";
@import "./typeahead/index";
@import "./saved_query_management/index";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
&__advancedModal {
width: 1200px;
height: 800px;

// euiOverlayMask pushes the modal up due to having padding-bottom: 10vh
max-height: calc(90vh - $euiSizeL);
max-height: calc(100vh - $euiSizeS);

.euiModal__flex {
max-height: none;
Expand Down
Loading

0 comments on commit c43dcfe

Please sign in to comment.