Skip to content

Commit

Permalink
Merge branch 'main' into fix/top-nav-back
Browse files Browse the repository at this point in the history
  • Loading branch information
ananzh authored Jul 30, 2024
2 parents 00da116 + 5f19c37 commit b4790c5
Show file tree
Hide file tree
Showing 72 changed files with 1,693 additions and 1,066 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @ananzh @kavilla @AMoo-Miki @ashwin-pc @joshuarrrr @abbyhu2000 @zengyan-amazon @zhongnansu @manasvinibs @ZilongX @Flyingliuhub @curq @bandinib-amzn @SuZhou-Joe @ruanyl @BionIT @xinruiba @zhyuanqi @mengweieric @LDrago27 @virajsanghvi @sejli
* @ananzh @kavilla @AMoo-Miki @ashwin-pc @joshuarrrr @abbyhu2000 @zengyan-amazon @zhongnansu @manasvinibs @ZilongX @Flyingliuhub @curq @bandinib-amzn @SuZhou-Joe @ruanyl @BionIT @xinruiba @zhyuanqi @mengweieric @LDrago27 @virajsanghvi @sejli @joshuali925
1 change: 1 addition & 0 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ This document contains a list of maintainers in this repo. See [opensearch-proje
| Suchit Sahoo | [LDrago27](https://github.com/LDrago27) | Amazon |
| Viraj Sanghvi | [virajsanghvi](https://github.com/virajsanghvi) | Amazon |
| Sean Li | [sejli](https://github.com/sejli) | Amazon |
| Joshua Li | [joshuali925](https://github.com/joshuali925) | Amazon |

## Emeritus

Expand Down
2 changes: 2 additions & 0 deletions changelogs/fragments/7528.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Fix data source picker trigger local cluster call by default ([#7528](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7528))
2 changes: 2 additions & 0 deletions changelogs/fragments/7530.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
refactor:
- [Look&Feel] Discover and Query Management fix ([#7530](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7530))
2 changes: 2 additions & 0 deletions changelogs/fragments/7546.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Fixes Discover next styling ([#7546](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7546))
2 changes: 2 additions & 0 deletions changelogs/fragments/7553.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
doc:
- Add Joshua as maintainer ([#7553](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7553))
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,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 Expand Up @@ -144,7 +144,7 @@
"dependencies": {
"@aws-crypto/client-node": "^3.1.1",
"@elastic/datemath": "5.0.3",
"@elastic/eui": "npm:@opensearch-project/oui@1.8.0",
"@elastic/eui": "npm:@opensearch-project/oui@1.8.1",
"@elastic/good": "^9.0.1-kibana3",
"@elastic/numeral": "npm:@amoo-miki/numeral@2.6.0",
"@elastic/request-crypto": "2.0.0",
Expand Down
4 changes: 3 additions & 1 deletion packages/osd-stylelint-config/config/global_selectors.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"packages/osd-ui-framework/src/components/button/button_group/_button_group.scss",
"src/plugins/discover/public/application/components/data_grid/data_grid_table_cell_value.scss",
"src/plugins/discover/public/application/view_components/canvas/discover_canvas.scss",
"src/plugins/discover/public/application/components/sidebar/discover_sidebar.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"
]
}
}
2 changes: 1 addition & 1 deletion packages/osd-ui-framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"enzyme-adapter-react-16": "^1.9.1"
},
"devDependencies": {
"@elastic/eui": "npm:@opensearch-project/oui@1.8.0",
"@elastic/eui": "npm:@opensearch-project/oui@1.8.1",
"@osd/babel-preset": "1.0.0",
"@osd/optimizer": "1.0.0",
"comment-stripper": "^0.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/osd-ui-shared-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"dependencies": {
"@elastic/charts": "31.1.0",
"@elastic/eui": "npm:@opensearch-project/oui@1.8.0",
"@elastic/eui": "npm:@opensearch-project/oui@1.8.1",
"@elastic/numeral": "npm:@amoo-miki/numeral@2.6.0",
"@opensearch/datemath": "5.0.3",
"@osd/i18n": "1.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const getSuggestions = async ({
services,
}: QuerySuggestionGetFnArgs): Promise<QuerySuggestion[]> => {
const { api } = services.uiSettings;
const dataSetManager = services.data.query.dataSet;
const dataSetManager = services.data.query.dataSetManager;
const suggestions = getOpenSearchSqlAutoCompleteSuggestions(query, {
line: position?.lineNumber || selectionStart,
column: position?.column || selectionEnd,
Expand Down
40 changes: 34 additions & 6 deletions src/plugins/data/public/query/dataset_manager/dataset_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { BehaviorSubject } from 'rxjs';
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 @@ export class DataSetManager {
}

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;
}

this.defaultDataSet = {
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 @@ export class DataSetManager {
*/
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 @@ export class DataSetManager {
}

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

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

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
35 changes: 19 additions & 16 deletions src/plugins/data/public/query/state_sync/connect_to_query_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ import { validateTimeRange } from '../timefilter';
*/
export const connectStorageToQueryState = async (
{
dataSet,
dataSetManager,
filterManager,
queryString,
state$,
}: Pick<
QueryStart | QuerySetup,
'timefilter' | 'filterManager' | 'queryString' | 'dataSet' | 'state$'
'timefilter' | 'filterManager' | 'queryString' | 'dataSetManager' | 'state$'
>,
OsdUrlStateStorage: IOsdUrlStateStorage,
syncConfig: {
Expand All @@ -89,7 +89,7 @@ export const connectStorageToQueryState = async (
filters: filterManager.getAppFilters(),
...(uiSettings &&
uiSettings.get(UI_SETTINGS.QUERY_ENHANCEMENTS_ENABLED) && {
dataSet: dataSet.getDataSet(),
dataSet: dataSetManager.getDataSet(),
}),
};

Expand All @@ -106,13 +106,16 @@ export const connectStorageToQueryState = async (
}
}

if (syncConfig.dataSet && !_.isEqual(initialStateFromURL.dataSet, dataSet.getDataSet())) {
if (
syncConfig.dataSet &&
!_.isEqual(initialStateFromURL.dataSet, dataSetManager.getDataSet())
) {
if (initialStateFromURL.dataSet) {
dataSet.setDataSet(_.cloneDeep(initialStateFromURL.dataSet));
dataSetManager.setDataSet(_.cloneDeep(initialStateFromURL.dataSet));
} else {
const defaultDataSet = await dataSet.getDefaultDataSet();
const defaultDataSet = await dataSetManager.getDefaultDataSet();
if (defaultDataSet) {
dataSet.setDataSet(defaultDataSet);
dataSetManager.setDataSet(defaultDataSet);
}
}
}
Expand Down Expand Up @@ -150,7 +153,7 @@ export const connectStorageToQueryState = async (
}

if (syncConfig.dataSet && changes.dataSet) {
newState.dataSet = dataSet.getDataSet();
newState.dataSet = dataSetManager.getDataSet();
}

return newState;
Expand Down Expand Up @@ -182,11 +185,11 @@ export const connectToQueryState = <S extends QueryState>(
timefilter: { timefilter },
filterManager,
queryString,
dataSet,
dataSetManager,
state$,
}: Pick<
QueryStart | QuerySetup,
'timefilter' | 'filterManager' | 'dataSet' | 'queryString' | 'state$'
'timefilter' | 'filterManager' | 'dataSetManager' | 'queryString' | 'state$'
>,
stateContainer: BaseStateContainer<S>,
syncConfig: {
Expand Down Expand Up @@ -278,7 +281,7 @@ export const connectToQueryState = <S extends QueryState>(
}

if (syncConfig.dataSet && !initialState.dataSet) {
initialState.dataSet = dataSet.getDefaultDataSet();
initialState.dataSet = dataSetManager.getDefaultDataSet();
initialDirty = true;
}

Expand Down Expand Up @@ -320,7 +323,7 @@ export const connectToQueryState = <S extends QueryState>(
}
}
if (syncConfig.dataSet && changes.dataSet) {
newState.dataSet = dataSet.getDataSet();
newState.dataSet = dataSetManager.getDataSet();
}
return newState;
})
Expand Down Expand Up @@ -382,14 +385,14 @@ export const connectToQueryState = <S extends QueryState>(
}

if (syncConfig.dataSet) {
const currentDataSet = dataSet.getDataSet();
const currentDataSet = dataSetManager.getDataSet();
if (!_.isEqual(state.dataSet, currentDataSet)) {
if (state.dataSet) {
dataSet.setDataSet(state.dataSet);
dataSetManager.setDataSet(state.dataSet);
} else {
const defaultDataSet = await dataSet.getDefaultDataSet();
const defaultDataSet = dataSetManager.getDefaultDataSet();
if (defaultDataSet) {
dataSet.setDataSet(defaultDataSet);
dataSetManager.setDataSet(defaultDataSet);
stateContainer.set({ ...stateContainer.get(), dataSet: defaultDataSet });
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ export function createQueryStateObservable({
timefilter: { timefilter },
filterManager,
queryString,
dataSet,
dataSetManager,
}: {
timefilter: TimefilterSetup;
filterManager: FilterManager;
queryString: QueryStringContract;
dataSet: DataSetContract;
dataSetManager: DataSetContract;
}): Observable<{ changes: QueryStateChange; state: QueryState }> {
return new Observable((subscriber) => {
const state = createStateContainer<QueryState>({
time: timefilter.getTime(),
refreshInterval: timefilter.getRefreshInterval(),
filters: filterManager.getFilters(),
query: queryString.getQuery(),
dataSet: dataSet.getDataSet(),
dataSet: dataSetManager.getDataSet(),
});

let currentChange: QueryStateChange = {};
Expand All @@ -64,9 +64,9 @@ export function createQueryStateObservable({
currentChange.query = true;
state.set({ ...state.get(), query: queryString.getQuery() });
}),
dataSet.getUpdates$().subscribe(() => {
dataSetManager.getUpdates$().subscribe(() => {
currentChange.dataSet = true;
state.set({ ...state.get(), dataSet: dataSet.getDataSet() });
state.set({ ...state.get(), dataSet: dataSetManager.getDataSet() });
}),
timefilter.getTimeUpdate$().subscribe(() => {
currentChange.time = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ setupMock.uiSettings.get.mockImplementation((key: string) => {
return 'kuery';
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
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,23 @@ const GLOBAL_STATE_STORAGE_KEY = '_g';
export const syncQueryStateWithUrl = (
query: Pick<
QueryStart | QuerySetup,
'filterManager' | 'timefilter' | 'queryString' | 'dataSet' | 'state$'
'filterManager' | 'timefilter' | 'queryString' | 'dataSetManager' | 'state$'
>,
osdUrlStateStorage: IOsdUrlStateStorage,
uiSettings?: CoreStart['uiSettings']
) => {
const {
timefilter: { timefilter },
filterManager,
dataSet,
dataSetManager,
} = query;
const defaultState: QueryState = {
time: timefilter.getTime(),
refreshInterval: timefilter.getRefreshInterval(),
filters: filterManager.getGlobalFilters(),
...(uiSettings &&
uiSettings.get(UI_SETTINGS.QUERY_ENHANCEMENTS_ENABLED) && {
dataSet: dataSet.getDataSet(),
dataSet: dataSetManager.getDataSet(),
}),
};

Expand Down
Loading

0 comments on commit b4790c5

Please sign in to comment.