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

[2.x manual backport] BP for #7542, #7540, #7552, #7566, #7567 #7574

Merged
merged 5 commits into from
Jul 30, 2024
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
2 changes: 2 additions & 0 deletions changelogs/fragments/7542.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Fix tables not displaying in navigator and add local cluster to datasources ([#7542](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7542))
2 changes: 2 additions & 0 deletions changelogs/fragments/7567.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Fixes databases not being displayed upon success ([#7567](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7567))
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"start": "scripts/use_node scripts/opensearch_dashboards --dev",
"start:docker": "scripts/use_node scripts/opensearch_dashboards --dev --opensearch.hosts=$OPENSEARCH_HOSTS --opensearch.ignoreVersionMismatch=true --server.host=$SERVER_HOST",
"start:security": "scripts/use_node scripts/opensearch_dashboards --dev --security",
"start:enhancements": "scripts/use_node scripts/opensearch_dashboards --dev --uiSettings.overrides['query:enhancements:enabled']=true --uiSettings.overrides['home:useNewHomePage']=true",
"start:enhancements": "scripts/use_node scripts/opensearch_dashboards --dev --uiSettings.overrides['query:enhancements:enabled']=true --uiSettings.overrides['home:useNewHomePage']=true --uiSettings.overrides['state:storeInSessionStorage']=true",
"debug": "scripts/use_node --nolazy --inspect scripts/opensearch_dashboards --dev",
"debug-break": "scripts/use_node --nolazy --inspect-brk scripts/opensearch_dashboards --dev",
"lint": "yarn run lint:es && yarn run lint:style",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"src/plugins/discover/public/application/view_components/canvas/discover_canvas.scss",
"src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss",
"src/plugins/data/public/ui/query_string_input/_query_bar.scss",
"src/plugins/data/public/ui/query_editor/_query_editor.scss"
"src/plugins/data/public/ui/query_editor/_query_editor.scss",
"src/plugins/data/public/ui/dataset_navigator/_dataset_navigator.scss"
]
}
}
4 changes: 4 additions & 0 deletions src/core/public/notifications/toasts/toasts_api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ export interface ErrorToastOptions extends ToastOptions {
* message will still be shown in the detailed error modal.
*/
toastMessage?: string;
/**
* The id of the error.
*/
id?: string;
}

const normalizeToast = (toastOrTitle: ToastInput): ToastInputFields => {
Expand Down

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 @@ -46,7 +46,7 @@
services,
}: QuerySuggestionGetFnArgs): Promise<QuerySuggestion[]> => {
const { api } = services.uiSettings;
const dataSetManager = services.data.query.dataSet;
const dataSetManager = services.data.query.dataSetManager;

Check warning on line 49 in src/plugins/data/public/antlr/opensearch_sql/code_completion.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/antlr/opensearch_sql/code_completion.ts#L49

Added line #L49 was not covered by tests
const suggestions = getOpenSearchSqlAutoCompleteSuggestions(query, {
line: position?.lineNumber || selectionStart,
column: position?.column || selectionEnd,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const createSetupContractMock = () => {
setDataSet: jest.fn(),
getUpdates$: jest.fn(),
getDefaultDataSet: jest.fn(),
fetchDefaultDataSet: jest.fn(),
initWithIndexPattern: jest.fn(),
};
return dataSetManagerMock;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ describe('DataSetManager', () => {
service = new DataSetManager(uiSettingsMock);
});

test('getUpdates$ emits initially and after data set changes', () => {
test('getUpdates$ is a cold emits only after dataset changes', () => {
const obs$ = service.getUpdates$();
const emittedValues: Array<SimpleDataSet | undefined> = [];
const emittedValues: SimpleDataSet[] = [];
obs$.subscribe((v) => {
emittedValues.push(v);
emittedValues.push(v!);
});
expect(emittedValues).toHaveLength(0);
expect(emittedValues[0]).toEqual(undefined);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { CoreStart } from 'opensearch-dashboards/public';
import { skip } from 'rxjs/operators';
import {
IndexPattern,
SIMPLE_DATA_SET_TYPES,
SimpleDataSet,
SimpleDataSource,
Expand All @@ -24,9 +25,33 @@
}

public init = async (indexPatterns: IndexPatternsContract) => {
if (!this.uiSettings.get(UI_SETTINGS.QUERY_ENHANCEMENTS_ENABLED)) return;
this.indexPatterns = indexPatterns;
this.defaultDataSet = await this.fetchDefaultDataSet();
return this.defaultDataSet;
};

public initWithIndexPattern = (indexPattern: IndexPattern | null) => {
if (!this.uiSettings.get(UI_SETTINGS.QUERY_ENHANCEMENTS_ENABLED)) return;
if (!indexPattern || !indexPattern.id) {
return undefined;

Check warning on line 36 in src/plugins/data/public/query/dataset_manager/dataset_manager.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/query/dataset_manager/dataset_manager.ts#L36

Added line #L36 was not covered by tests
}

this.defaultDataSet = {

Check warning on line 39 in src/plugins/data/public/query/dataset_manager/dataset_manager.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/query/dataset_manager/dataset_manager.ts#L39

Added line #L39 was not covered by tests
id: indexPattern.id,
title: indexPattern.title,
type: SIMPLE_DATA_SET_TYPES.INDEX_PATTERN,
timeFieldName: indexPattern.timeFieldName,
fields: indexPattern.fields,
...(indexPattern.dataSourceRef
? {
dataSourceRef: {
id: indexPattern.dataSourceRef?.id,
name: indexPattern.dataSourceRef?.name,
type: indexPattern.dataSourceRef?.type,
} as SimpleDataSource,
}
: {}),
};
};

public getUpdates$ = () => {
Expand All @@ -43,6 +68,13 @@
*/
public setDataSet = (dataSet: SimpleDataSet | undefined) => {
if (!this.uiSettings.get(UI_SETTINGS.QUERY_ENHANCEMENTS_ENABLED)) return;

// if (dataSet) {
// const { fields, ...dataSetWithoutFields } = dataSet;
// this.dataSet$.next(dataSetWithoutFields);
// } else {
// this.dataSet$.next(undefined);
// }
this.dataSet$.next(dataSet);
};

Expand All @@ -57,11 +89,7 @@
}

const indexPattern = await this.indexPatterns?.get(defaultIndexPatternId);
if (!indexPattern) {
return undefined;
}

if (!indexPattern.id) {
if (!indexPattern || !indexPattern.id) {
return undefined;
}

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/data/public/query/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const createSetupContractMock = () => {
filterManager: createFilterManagerMock(),
timefilter: timefilterServiceMock.createSetupContract(),
queryString: queryStringManagerMock.createSetupContract(),
dataSet: dataSetManagerMock.createSetupContract(),
dataSetManager: dataSetManagerMock.createSetupContract(),
state$: new Observable(),
};

Expand All @@ -57,7 +57,7 @@ const createStartContractMock = () => {
savedQueries: jest.fn() as any,
state$: new Observable(),
timefilter: timefilterServiceMock.createStartContract(),
dataSet: dataSetManagerMock.createStartContract(),
dataSetManager: dataSetManagerMock.createStartContract(),
getOpenSearchQuery: jest.fn(),
};

Expand Down
10 changes: 5 additions & 5 deletions src/plugins/data/public/query/query_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { TimefilterService, TimefilterSetup } from './timefilter';
import { createSavedQueryService } from './saved_query/saved_query_service';
import { createQueryStateObservable } from './state_sync/create_global_query_observable';
import { QueryStringManager, QueryStringContract } from './query_string';
import { DataSetManager } from './dataset_manager';
import { DataSetContract, DataSetManager } from './dataset_manager';
import { buildOpenSearchQuery, getOpenSearchQueryConfig, IndexPatternsService } from '../../common';
import { getUiSettings } from '../services';
import { IndexPattern } from '..';
Expand All @@ -63,7 +63,7 @@ export class QueryService {
filterManager!: FilterManager;
timefilter!: TimefilterSetup;
queryStringManager!: QueryStringContract;
dataSetManager!: DataSetManager;
dataSetManager!: DataSetContract;

state$!: ReturnType<typeof createQueryStateObservable>;

Expand All @@ -83,14 +83,14 @@ export class QueryService {
filterManager: this.filterManager,
timefilter: this.timefilter,
queryString: this.queryStringManager,
dataSet: this.dataSetManager,
dataSetManager: this.dataSetManager,
}).pipe(share());

return {
filterManager: this.filterManager,
timefilter: this.timefilter,
queryString: this.queryStringManager,
dataSet: this.dataSetManager,
dataSetManager: this.dataSetManager,
state$: this.state$,
};
}
Expand All @@ -109,7 +109,7 @@ export class QueryService {
}),
filterManager: this.filterManager,
queryString: this.queryStringManager,
dataSet: this.dataSetManager,
dataSetManager: this.dataSetManager,
savedQueries: createSavedQueryService(savedObjectsClient),
state$: this.state$,
timefilter: this.timefilter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ setupMock.uiSettings.get.mockImplementation((key: string) => {
return { from: 'now-15m', to: 'now' };
case UI_SETTINGS.TIMEPICKER_REFRESH_INTERVAL_DEFAULTS:
return { pause: false, value: 0 };
case UI_SETTINGS.QUERY_ENHANCEMENTS_ENABLED:
return false;
default:
throw new Error(`sync_query test: not mocked uiSetting: ${key}`);
}
Expand Down
Loading
Loading