Skip to content

Commit efdc495

Browse files
authored
Merge branch 'main' into fix-metrics-single-line-visability
2 parents 332c09d + cb845f2 commit efdc495

File tree

10 files changed

+199
-207
lines changed

10 files changed

+199
-207
lines changed

common/constants/data_sources.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,7 @@ export const ACCELERATION_AGGREGRATION_FUNCTIONS = [
9090
];
9191

9292
export const SPARK_PARTITION_INFO = `# Partition Information`;
93+
export const OBS_DEFAULT_CLUSTER = 'observability-default'; // prefix key for generating data source id for default cluster in data selector
94+
export const OBS_S3_DATA_SOURCE = 'observability-s3'; // prefix key for generating data source id for s3 data sources in data selector
95+
export const S3_DATA_SOURCE_GROUP_DISPLAY_NAME = 'Amazon S3'; // display group name for Amazon-managed-s3 data sources in data selector
96+
export const S3_DATA_SOURCE_GROUP_SPARK_DISPLAY_NAME = 'Spark'; // display group name for OpenSearch-spark-s3 data sources in data selector

common/constants/shared.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ export const VISUALIZATION_ERROR = {
258258
NO_METRIC: 'Invalid Metric MetaData',
259259
};
260260

261-
export const S3_DATASOURCE_TYPE = 'S3_DATASOURCE';
261+
export const S3_DATA_SOURCE_TYPE = 's3glue';
262262

263263
export const ASYNC_QUERY_SESSION_ID = 'async-query-session-id';
264264
export const ASYNC_QUERY_DATASOURCE_CACHE = 'async-query-catalog-cache';

public/components/common/search/__tests__/__snapshots__/search.test.tsx.snap

Lines changed: 3 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -405,17 +405,17 @@ exports[`Explorer Search component renders basic component 1`] = `
405405
onTimeChange={[Function]}
406406
recentlyUsedRanges={Array []}
407407
refreshInterval={0}
408-
showUpdateButton={true}
408+
showUpdateButton={false}
409409
start="now-15m"
410410
timeFormat="HH:mm"
411411
>
412412
<EuiFlexGroup
413-
className="euiSuperDatePicker__flexWrapper"
413+
className="euiSuperDatePicker__flexWrapper euiSuperDatePicker__flexWrapper--noUpdateButton"
414414
gutterSize="s"
415415
responsive={false}
416416
>
417417
<div
418-
className="euiFlexGroup euiFlexGroup--gutterSmall euiFlexGroup--directionRow euiSuperDatePicker__flexWrapper"
418+
className="euiFlexGroup euiFlexGroup--gutterSmall euiFlexGroup--directionRow euiSuperDatePicker__flexWrapper euiSuperDatePicker__flexWrapper--noUpdateButton"
419419
>
420420
<EuiFlexItem>
421421
<div
@@ -724,146 +724,6 @@ exports[`Explorer Search component renders basic component 1`] = `
724724
</EuiFormControlLayout>
725725
</div>
726726
</EuiFlexItem>
727-
<EuiFlexItem
728-
grow={false}
729-
>
730-
<div
731-
className="euiFlexItem euiFlexItem--flexGrowZero"
732-
>
733-
<EuiSuperUpdateButton
734-
data-test-subj="superDatePickerApplyTimeButton"
735-
isDisabled={false}
736-
isLoading={false}
737-
needsUpdate={false}
738-
onClick={[Function]}
739-
showTooltip={true}
740-
>
741-
<EuiToolTip
742-
delay="regular"
743-
position="bottom"
744-
>
745-
<span
746-
className="euiToolTipAnchor"
747-
onKeyUp={[Function]}
748-
onMouseOut={[Function]}
749-
onMouseOver={[Function]}
750-
>
751-
<EuiButton
752-
className="euiSuperUpdateButton"
753-
color="primary"
754-
data-test-subj="superDatePickerApplyTimeButton"
755-
fill={true}
756-
iconType="refresh"
757-
isDisabled={false}
758-
isLoading={false}
759-
onBlur={[Function]}
760-
onClick={[Function]}
761-
onFocus={[Function]}
762-
textProps={
763-
Object {
764-
"className": "euiSuperUpdateButton__text",
765-
}
766-
}
767-
>
768-
<EuiButtonDisplay
769-
baseClassName="euiButton"
770-
className="euiSuperUpdateButton"
771-
color="primary"
772-
data-test-subj="superDatePickerApplyTimeButton"
773-
disabled={false}
774-
element="button"
775-
fill={true}
776-
iconType="refresh"
777-
isDisabled={false}
778-
isLoading={false}
779-
onBlur={[Function]}
780-
onClick={[Function]}
781-
onFocus={[Function]}
782-
textProps={
783-
Object {
784-
"className": "euiSuperUpdateButton__text",
785-
}
786-
}
787-
type="button"
788-
>
789-
<button
790-
className="euiButton euiButton--primary euiButton--fill euiSuperUpdateButton"
791-
data-test-subj="superDatePickerApplyTimeButton"
792-
disabled={false}
793-
onBlur={[Function]}
794-
onClick={[Function]}
795-
onFocus={[Function]}
796-
style={
797-
Object {
798-
"minWidth": undefined,
799-
}
800-
}
801-
type="button"
802-
>
803-
<EuiButtonContent
804-
className="euiButton__content"
805-
iconSide="left"
806-
iconType="refresh"
807-
isLoading={false}
808-
textProps={
809-
Object {
810-
"className": "euiButton__text euiSuperUpdateButton__text",
811-
}
812-
}
813-
>
814-
<span
815-
className="euiButtonContent euiButton__content"
816-
>
817-
<EuiIcon
818-
className="euiButtonContent__icon"
819-
color="inherit"
820-
size="m"
821-
type="refresh"
822-
>
823-
<EuiIconBeaker
824-
aria-hidden={true}
825-
className="euiIcon euiIcon--medium euiIcon--inherit euiIcon-isLoading euiButtonContent__icon"
826-
focusable="false"
827-
role="img"
828-
style={null}
829-
>
830-
<svg
831-
aria-hidden={true}
832-
className="euiIcon euiIcon--medium euiIcon--inherit euiIcon-isLoading euiButtonContent__icon"
833-
focusable="false"
834-
height={16}
835-
role="img"
836-
style={null}
837-
viewBox="0 0 16 16"
838-
width={16}
839-
xmlns="http://www.w3.org/2000/svg"
840-
>
841-
<path
842-
d="M5.277 10.088c.02.014.04.03.057.047.582.55 1.134.812 1.666.812.586 0 1.84-.293 3.713-.88L9 6.212V2H7v4.212l-1.723 3.876Zm-.438.987L3.539 14h8.922l-1.32-2.969C9.096 11.677 7.733 12 7 12c-.74 0-1.463-.315-2.161-.925ZM6 2H5V1h6v1h-1v4l3.375 7.594A1 1 0 0 1 12.461 15H3.54a1 1 0 0 1-.914-1.406L6 6V2Z"
843-
/>
844-
</svg>
845-
</EuiIconBeaker>
846-
</EuiIcon>
847-
<span
848-
className="euiButton__text euiSuperUpdateButton__text"
849-
>
850-
<EuiI18n
851-
default="Refresh"
852-
token="euiSuperUpdateButton.refreshButtonLabel"
853-
>
854-
Refresh
855-
</EuiI18n>
856-
</span>
857-
</span>
858-
</EuiButtonContent>
859-
</button>
860-
</EuiButtonDisplay>
861-
</EuiButton>
862-
</span>
863-
</EuiToolTip>
864-
</EuiSuperUpdateButton>
865-
</div>
866-
</EuiFlexItem>
867727
</div>
868728
</EuiFlexGroup>
869729
</EuiSuperDatePicker>

public/components/common/search/date_picker.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export function DatePicker(props: IDatePickerProps) {
2222
onTimeChange={handleTimeChange}
2323
onRefresh={handleTimeRangePickerRefresh}
2424
className="osdQueryBar__datePicker"
25+
showUpdateButton={false}
2526
/>
2627
);
2728
}

public/components/event_analytics/explorer/datasources/datasources_selection.tsx

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55

66
import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react';
77
import { batch, useDispatch, useSelector } from 'react-redux';
8+
import { htmlIdGenerator } from '@elastic/eui';
89
import { LogExplorerRouterContext } from '../..';
910
import {
11+
DataSource,
1012
DataSourceGroup,
1113
DataSourceSelectable,
1214
DataSourceType,
@@ -20,6 +22,7 @@ import {
2022
DEFAULT_DATA_SOURCE_TYPE,
2123
DEFAULT_DATA_SOURCE_TYPE_NAME,
2224
INDEX_URL_PARAM_KEY,
25+
OBS_DEFAULT_CLUSTER,
2326
OLLY_QUESTION_URL_PARAM_KEY,
2427
QUERY_LANGUAGE,
2528
} from '../../../../../common/constants/data_sources';
@@ -90,6 +93,21 @@ const removeDataSourceFromURLParams = (currURL: string) => {
9093
}
9194
};
9295

96+
const getMatchedOption = (
97+
dataSourceList: DataSourceGroup[],
98+
dataSourceName: string,
99+
dataSourceType: string
100+
) => {
101+
if (!dataSourceName || !dataSourceType) return [];
102+
for (const dsGroup of dataSourceList) {
103+
const matchedOption = dsGroup.options.find(
104+
(item) => item.type === dataSourceType && item.name === dataSourceName
105+
);
106+
if (matchedOption !== undefined) return [matchedOption];
107+
}
108+
return [];
109+
};
110+
93111
export const DataSourceSelection = ({ tabId }: { tabId: string }) => {
94112
const { dataSources, http } = coreRefs;
95113
const sqlService = new SQLService(http!);
@@ -99,7 +117,11 @@ export const DataSourceSelection = ({ tabId }: { tabId: string }) => {
99117
const [activeDataSources, setActiveDataSources] = useState<DataSourceType[]>([]);
100118
const [dataSourceOptionList, setDataSourceOptionList] = useState<DataSourceGroup[]>([]);
101119
const [selectedSources, setSelectedSources] = useState<SelectedDataSource[]>(
102-
getDataSourceState(explorerSearchMetadata.datasources)
120+
getMatchedOption(
121+
dataSourceOptionList,
122+
explorerSearchMetadata.datasources?.[0]?.name || '',
123+
explorerSearchMetadata.datasources?.[0]?.type || ''
124+
)
103125
);
104126

105127
/**
@@ -149,8 +171,14 @@ export const DataSourceSelection = ({ tabId }: { tabId: string }) => {
149171
};
150172

151173
useEffect(() => {
152-
setSelectedSources(getDataSourceState(explorerSearchMetadata.datasources));
153-
}, [explorerSearchMetadata.datasources]);
174+
setSelectedSources(
175+
getMatchedOption(
176+
memorizedDataSourceOptionList,
177+
explorerSearchMetadata.datasources?.[0]?.name || '',
178+
explorerSearchMetadata.datasources?.[0]?.type || ''
179+
)
180+
);
181+
}, [explorerSearchMetadata.datasources, dataSourceOptionList]);
154182

155183
const handleDataSetFetchError = useCallback(() => {
156184
return (error: Error) => {
@@ -162,22 +190,33 @@ export const DataSourceSelection = ({ tabId }: { tabId: string }) => {
162190
* Subscribe to data source updates and manage the active data sources state.
163191
*/
164192
useEffect(() => {
165-
const subscription = dataSources.dataSourceService.dataSources$.subscribe(
166-
(currentDataSources) => {
193+
const subscription = dataSources.dataSourceService
194+
.getDataSources$()
195+
.subscribe((currentDataSources: DataSource[]) => {
167196
// temporary solution for 2.11 to render OpenSearch / default cluster for observability
168197
// local indices and index patterns, while keep listing all index patterns for data explorer
169198
// it filters the registered index pattern data sources in data plugin, and attach default cluster
170199
// for all indices
171200
setActiveDataSources([
172201
new ObservabilityDefaultDataSource({
202+
id: htmlIdGenerator(OBS_DEFAULT_CLUSTER)(DEFAULT_DATA_SOURCE_TYPE),
173203
name: DEFAULT_DATA_SOURCE_NAME,
174204
type: DEFAULT_DATA_SOURCE_TYPE,
175-
metadata: null,
205+
metadata: {
206+
ui: {
207+
label: DEFAULT_DATA_SOURCE_OBSERVABILITY_DISPLAY_NAME,
208+
groupType: DEFAULT_DATA_SOURCE_OBSERVABILITY_DISPLAY_NAME,
209+
selector: {
210+
displayDatasetsAsSource: false, // when true, selector UI will render data sets with source by calling getDataSets()
211+
},
212+
},
213+
},
176214
}),
177-
...Object.values(currentDataSources).filter((ds) => ds.type !== DEFAULT_DATA_SOURCE_TYPE),
215+
...Object.values(currentDataSources).filter(
216+
(ds) => ds.getType() !== DEFAULT_DATA_SOURCE_TYPE
217+
),
178218
]);
179-
}
180-
);
219+
});
181220

182221
return () => subscription.unsubscribe();
183222
}, []);
@@ -259,6 +298,10 @@ export const DataSourceSelection = ({ tabId }: { tabId: string }) => {
259298
});
260299
}, [dataSourceOptionList]);
261300

301+
const onRefresh = useCallback(() => {
302+
dataSources.dataSourceService.reload();
303+
}, [dataSources.dataSourceService]);
304+
262305
return (
263306
<DataSourceSelectable
264307
className="dsc-selector"
@@ -267,9 +310,10 @@ export const DataSourceSelection = ({ tabId }: { tabId: string }) => {
267310
setDataSourceOptionList={setDataSourceOptionList}
268311
selectedSources={selectedSources}
269312
onDataSourceSelect={handleSourceChange}
270-
onFetchDataSetError={handleDataSetFetchError}
271313
singleSelection={{ asPlainText: true }}
272314
dataSourceSelectorConfigs={DATA_SOURCE_SELECTOR_CONFIGS}
315+
onGetDataSetError={handleDataSetFetchError}
316+
onRefresh={onRefresh}
273317
/>
274318
);
275319
};

public/components/event_analytics/explorer/log_explorer.tsx

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/* eslint-disable react-hooks/exhaustive-deps */
66
import { isEmpty } from 'lodash';
77
import React, { useContext, useEffect, useRef, useState } from 'react';
8-
import { batch, useSelector, useDispatch } from 'react-redux';
8+
import { useSelector } from 'react-redux';
99
import { useHistory } from 'react-router-dom';
1010
import { LogExplorerRouterContext } from '..';
1111
import {
@@ -26,14 +26,6 @@ import {
2626
} from '../../../../common/constants/shared';
2727
import { coreRefs } from '../../../../public/framework/core_refs';
2828

29-
import { init as initFields } from '../../event_analytics/redux/slices/field_slice';
30-
import { init as initPatterns } from '../../event_analytics/redux/slices/patterns_slice';
31-
import { init as initQueryResult } from '../../event_analytics/redux/slices/query_result_slice';
32-
import { init as initQuery } from '../../event_analytics/redux/slices/query_slice';
33-
import { init as initVisualizationConfig } from '../../event_analytics/redux/slices/viualization_config_slice';
34-
import { resetSummary as initQueryAssistSummary } from '../../event_analytics/redux/slices/query_assistant_summarization_slice';
35-
import { init as initSearchMetaData } from '../../event_analytics/redux/slices/search_meta_data_slice';
36-
3729
const searchBarConfigs = {
3830
[TAB_EVENT_ID]: {
3931
showSaveButton: true,
@@ -60,7 +52,6 @@ export const LogExplorer = ({
6052
dataSourcePluggables,
6153
}: ILogExplorerProps) => {
6254
const history = useHistory();
63-
const dispatch = useDispatch();
6455
const routerContext = useContext(LogExplorerRouterContext);
6556
const tabIds = useSelector(selectQueryTabs).queryTabIds.filter(
6657
(tabid: string) => !tabid.match(APP_ANALYTICS_TAB_ID_REGEX)
@@ -97,20 +88,8 @@ export const LogExplorer = ({
9788
useEffect(() => {
9889
if (!isEmpty(savedObjectId)) {
9990
dispatchSavedObjectId();
100-
} else {
101-
// below piece of code was added to simulate creating a new tab if saved obj isn't being loaded,
102-
// since tabs being visually removed means 'new tab' cannot be created any other way
103-
const tabId = tabIds[0];
104-
batch(() => {
105-
dispatch(initQuery({ tabId }));
106-
dispatch(initQueryResult({ tabId }));
107-
dispatch(initFields({ tabId }));
108-
dispatch(initVisualizationConfig({ tabId }));
109-
dispatch(initPatterns({ tabId }));
110-
dispatch(initQueryAssistSummary({ tabId }));
111-
dispatch(initSearchMetaData({ tabId }));
112-
});
11391
}
92+
11493
if (routerContext && routerContext.searchParams.has(CREATE_TAB_PARAM_KEY)) {
11594
// need to wait for current redux event loop to finish
11695
setImmediate(() => {

0 commit comments

Comments
 (0)