Skip to content

Commit dfe3ea0

Browse files
authored
Merge branch 'opensearch-project:main' into fix-panel-header
2 parents da742b5 + 677fdf5 commit dfe3ea0

File tree

22 files changed

+323
-246
lines changed

22 files changed

+323
-246
lines changed

CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
1010

1111
### 🛡 Security
1212

13+
- [CVE-2022-25869] Remove AngularJS 1.8 ([#5086](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5086))
1314
- [CVE-2022-37599] Bump loader-utils from `2.0.3` to `2.0.4` ([#3031](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3031)). Backwards-compatible fixes included in v2.6.0 and v1.3.7 releases.
1415
- [CVE-2022-37603] Bump loader-utils from `2.0.3` to `2.0.4` ([#3031](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3031)). Backwards-compatible fixes included in v2.6.0 and v1.3.7 releases.
1516
- [WS-2021-0638] Bump mocha from `7.2.0` to `10.1.0` ([#2711](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2711))
@@ -36,8 +37,9 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
3637
- [Decouple] Allow plugin manifest config to define semver compatible OpenSearch plugin and verify if it is installed on the cluster([#4612](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4612))
3738
- [Advanced Settings] Consolidate settings into new "Appearance" category and add category IDs ([#4845](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4845))
3839
- Adds Data explorer framework and implements Discover using it ([#4806](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4806))
39-
- [Theme] Use themes' definitions to render the initial view ([#4936](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4936/))
40-
- [Theme] Make `next` theme the default ([#4854](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4854/))
40+
- [Theme] Use themes' definitions to render the initial view ([#4936](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4936))
41+
- [Theme] Make `next` theme the default ([#4854](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4854))
42+
- [Discover] Update embeddable for saved searches ([#5081](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5081))
4143

4244
### 🐛 Bug Fixes
4345

@@ -55,6 +57,10 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
5557
- [BUG] Fix buildPointSeriesData unit test fails due to local timezone ([#4992](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4992))
5658
- [BUG][Data Explorer][Discover] Fix total hits issue for no time based data ([#5087](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5087))
5759
- [BUG][Data Explorer][Discover] Add onQuerySubmit to top nav and allow force update to embeddable ([#5160](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5160))
60+
- [BUG][Discover] Fix misc navigation issues ([#5168](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5168))
61+
- [BUG][Discover] Fix mobile view ([#5168](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5168))
62+
- [BUG][Data Explorer][Discover] Automatically load solo added default index pattern ([#5171](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5171))
63+
- [BUG][Data Explorer][Discover] Allow data grid to auto adjust size based on fetched data count ([#5191](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5191))
5864

5965
### 🚞 Infrastructure
6066

src/plugins/dashboard/public/application/utils/use/use_dashboard_app_state.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,17 @@ export const useDashboardAppAndGlobalState = ({
193193

194194
subscriptions.add(stopSyncingFromTimeFilters);
195195

196+
const stopSyncingFromGlobalFilters = filterManager.getUpdates$().subscribe(() => {
197+
refreshDashboardContainer({
198+
dashboardServices: services,
199+
dashboardContainer,
200+
savedDashboard: dashboard!,
201+
appStateData: stateContainer.getState(),
202+
});
203+
});
204+
205+
subscriptions.add(stopSyncingFromGlobalFilters);
206+
196207
unsubscribeFromDashboardContainer = () => {
197208
stopSyncingDashboardContainerInputs();
198209
stopSyncingDashboardContainerOutputs();

src/plugins/data_explorer/public/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,10 @@ export function plugin() {
1414
}
1515
export { DataExplorerPluginSetup, DataExplorerPluginStart, DataExplorerServices } from './types';
1616
export { ViewProps, ViewDefinition, DefaultViewState } from './services/view_service';
17-
export { RootState, useTypedSelector, useTypedDispatch } from './utils/state_management';
17+
export {
18+
RootState,
19+
Store,
20+
useTypedSelector,
21+
useTypedDispatch,
22+
setIndexPattern,
23+
} from './utils/state_management';

src/plugins/data_explorer/public/utils/state_management/store.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ import { reducer as metadataReducer } from './metadata_slice';
99
import { loadReduxState, persistReduxState } from './redux_persistence';
1010
import { DataExplorerServices } from '../../types';
1111

12+
const HYDRATE = 'HYDRATE';
13+
14+
export const hydrate = (newState: RootState) => ({
15+
type: HYDRATE,
16+
payload: newState,
17+
});
18+
1219
const commonReducers = {
1320
metadata: metadataReducer,
1421
};
@@ -22,9 +29,20 @@ let dynamicReducers: {
2229

2330
const rootReducer = combineReducers(dynamicReducers);
2431

32+
const createRootReducer = (): Reducer<RootState> => {
33+
const combinedReducer = combineReducers(dynamicReducers);
34+
35+
return (state: RootState | undefined, action: any): RootState => {
36+
if (action.type === HYDRATE) {
37+
return action.payload;
38+
}
39+
return combinedReducer(state, action);
40+
};
41+
};
42+
2543
export const configurePreloadedStore = (preloadedState: PreloadedState<RootState>) => {
2644
// After registering the slices the root reducer needs to be updated
27-
const updatedRootReducer = combineReducers(dynamicReducers);
45+
const updatedRootReducer = createRootReducer();
2846

2947
return configureStore({
3048
reducer: updatedRootReducer,
@@ -62,6 +80,18 @@ export const getPreloadedStore = async (services: DataExplorerServices) => {
6280
// the store subscriber will automatically detect changes and call handleChange function
6381
const unsubscribe = store.subscribe(handleChange);
6482

83+
// This is necessary because browser navigation updates URL state that isnt reflected in the redux state
84+
services.scopedHistory.listen(async (location, action) => {
85+
const urlState = await loadReduxState(services);
86+
const currentState = store.getState();
87+
88+
// If the url state is different from the current state, then we need to update the store
89+
// the state should have a view property if it was loaded from the url
90+
if (action === 'POP' && urlState.metadata?.view && !isEqual(urlState, currentState)) {
91+
store.dispatch(hydrate(urlState as RootState));
92+
}
93+
});
94+
6595
const onUnsubscribe = () => {
6696
dynamicReducers = {
6797
...commonReducers,

src/plugins/discover/public/application/components/data_grid/data_grid_table.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export interface DataGridTableProps {
2929
onSetColumns: (columns: string[]) => void;
3030
sort: SortOrder[];
3131
displayTimeColumn: boolean;
32-
services: DiscoverServices;
3332
title?: string;
3433
description?: string;
3534
isToolbarVisible?: boolean;

src/plugins/discover/public/application/components/doc_views/surrounding_docs_app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export function SurroundingDocsApp() {
4747

4848
useEffect(() => {
4949
chrome.setBreadcrumbs([
50-
...getRootBreadcrumbs(baseUrl),
50+
...getRootBreadcrumbs(),
5151
{
5252
text: i18n.translate('discover.context.breadcrumb', {
5353
defaultMessage: `Context of #{docId}`,

src/plugins/discover/public/application/components/doc_views/surrounding_docs_view.tsx

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export const SurroundingDocsView = ({ id, indexPattern }: SurroundingDocsViewPar
9393
field,
9494
values,
9595
operation,
96-
indexPattern.id
96+
indexPattern.id || ''
9797
);
9898
return filterManager.addFilters(newFilters);
9999
},
@@ -115,23 +115,25 @@ export const SurroundingDocsView = ({ id, indexPattern }: SurroundingDocsViewPar
115115
[onAddFilter, rows, indexPattern, setContextAppState, contextQueryState, contextAppState]
116116
);
117117

118+
if (isLoading) {
119+
return null;
120+
}
121+
118122
return (
119-
!isLoading && (
120-
<Fragment>
121-
<TopNavMenu
122-
appName={'discover.context.surroundingDocs.topNavMenu'}
123-
showSearchBar={true}
124-
showQueryBar={false}
125-
showDatePicker={false}
126-
indexPatterns={[indexPattern]}
127-
useDefaultBehaviors={true}
128-
/>
129-
<EuiPage className="discover.context.appPage">
130-
<EuiPageContent paddingSize="s" className="dscDocsContent">
131-
{contextAppMemoized}
132-
</EuiPageContent>
133-
</EuiPage>
134-
</Fragment>
135-
)
123+
<Fragment>
124+
<TopNavMenu
125+
appName={'discover.context.surroundingDocs.topNavMenu'}
126+
showSearchBar={true}
127+
showQueryBar={false}
128+
showDatePicker={false}
129+
indexPatterns={[indexPattern]}
130+
useDefaultBehaviors={true}
131+
/>
132+
<EuiPage className="discover.context.appPage">
133+
<EuiPageContent paddingSize="s" className="dscDocsContent">
134+
{contextAppMemoized}
135+
</EuiPageContent>
136+
</EuiPage>
137+
</Fragment>
136138
);
137139
};

src/plugins/discover/public/application/components/sidebar/discover_field.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@
1111
&:focus {
1212
opacity: 1;
1313
}
14+
15+
@include ouiBreakpoint("xs", "s", "m") {
16+
opacity: 1;
17+
}
1418
}

src/plugins/discover/public/application/components/top_nav/get_top_nav_links.tsx

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
import { DiscoverState, setSavedSearchId } from '../../utils/state_management';
2020
import { DOC_HIDE_TIME_COLUMN_SETTING, SORT_DEFAULT_ORDER_SETTING } from '../../../../common';
2121
import { getSortForSearchSource } from '../../view_components/utils/get_sort_for_search_source';
22+
import { getRootBreadcrumbs } from '../../helpers/breadcrumbs';
2223

2324
export const getTopNavLinks = (
2425
services: DiscoverViewServices,
@@ -45,11 +46,9 @@ export const getTopNavLinks = (
4546
defaultMessage: 'New Search',
4647
}),
4748
run() {
48-
setTimeout(() => {
49-
history().push('/');
50-
// TODO: figure out why a history push doesn't update the app state. The page reload is a hack around it
51-
window.location.reload();
52-
}, 0);
49+
core.application.navigateToApp('discover', {
50+
path: '#/',
51+
});
5352
},
5453
testId: 'discoverNewButton',
5554
};
@@ -103,15 +102,7 @@ export const getTopNavLinks = (
103102
history().push(`/view/${encodeURIComponent(id)}`);
104103
} else {
105104
chrome.docTitle.change(savedSearch.lastSavedTitle);
106-
chrome.setBreadcrumbs([
107-
{
108-
text: i18n.translate('discover.discoverBreadcrumbTitle', {
109-
defaultMessage: 'Discover',
110-
}),
111-
href: '#/',
112-
},
113-
{ text: savedSearch.title },
114-
]);
105+
chrome.setBreadcrumbs([...getRootBreadcrumbs(), { text: savedSearch.title }]);
115106
}
116107

117108
// set App state to clean

src/plugins/discover/public/application/components/top_nav/open_search_panel.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ interface Props {
5555
export function OpenSearchPanel({ onClose, makeUrl }: Props) {
5656
const {
5757
services: {
58-
core: { uiSettings, savedObjects },
58+
core: { uiSettings, savedObjects, application },
5959
addBasePath,
6060
},
6161
} = useOpenSearchDashboards<DiscoverViewServices>();
@@ -90,12 +90,8 @@ export function OpenSearchPanel({ onClose, makeUrl }: Props) {
9090
},
9191
]}
9292
onChoose={(id) => {
93-
setTimeout(() => {
94-
window.location.assign(makeUrl(id));
95-
// TODO: figure out why a history push doesn't update the app state. The page reload is a hack around it
96-
window.location.reload();
97-
onClose();
98-
}, 0);
93+
application.navigateToApp('discover', { path: `#/view/${id}` });
94+
onClose();
9995
}}
10096
uiSettings={uiSettings}
10197
savedObjects={savedObjects}

0 commit comments

Comments
 (0)