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

[Backport 2.x] [Data Explorer] Fixes save search glitch + misc #4880

Merged
merged 1 commit into from
Sep 1, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,16 @@ export const Sidebar: FC = ({ children }) => {
dispatch(setIndexPattern(value));
}}
/>
<EuiSpacer size="s" />
{/* Hidden for the 2.10 release of Data Explorer. Uncomment when Data explorer is released */}
{/* <EuiSpacer size="s" />
<EuiSelect
options={viewOptions}
value={view?.id}
onChange={(e) => {
dispatch(setView(e.target.value));
}}
fullWidth
/>
/> */}
</EuiSplitPanel.Inner>
<EuiSplitPanel.Inner paddingSize="none" color="subdued" className="eui-yScroll">
{children}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React from 'react';
import { DiscoverViewServices } from '../../../build_services';
import { showOpenSearchPanel } from './show_open_search_panel';
import { SavedSearch } from '../../../saved_searches';
import { NEW_DISCOVER_APP } from '../../..';
import { NEW_DISCOVER_APP } from '../../../../common';
import { Adapters } from '../../../../../inspector/public';
import { TopNavMenuData } from '../../../../../navigation/public';
import { ISearchSource, unhashUrl } from '../../../opensearch_dashboards_services';
Expand Down Expand Up @@ -102,11 +102,7 @@ export const getTopNavLinks = (
});

if (id !== state.savedSearch) {
setTimeout(() => {
history().push(`/view/${encodeURIComponent(id)}`);
// TODO: figure out why a history push doesn't update the app state. The page reload is a hack around it
window.location.reload();
}, 0);
history().push(`/view/${encodeURIComponent(id)}`);
} else {
chrome.docTitle.change(savedSearch.lastSavedTitle);
chrome.setBreadcrumbs([
Expand All @@ -122,6 +118,8 @@ export const getTopNavLinks = (

// set App state to clean
store!.dispatch({ type: setSavedSearchId.type, payload: id });

return { id };
}
} catch (error) {
toastNotifications.addDanger({
Expand All @@ -136,9 +134,9 @@ export const getTopNavLinks = (

// Reset the original title
savedSearch.title = currentTitle;
}

return { test: true };
return { error };
}
};

const saveModal = (
Expand Down
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 React, { useEffect, useState } from 'react';
import { AppMountParameters } from '../../../../../../core/public';
import { NEW_DISCOVER_APP, PLUGIN_ID } from '../../../../common';
Expand All @@ -12,6 +11,7 @@ import { DiscoverViewServices } from '../../../build_services';
import { IndexPattern } from '../../../opensearch_dashboards_services';
import { getTopNavLinks } from '../../components/top_nav/get_top_nav_links';
import { useDiscoverContext } from '../context';
import { getRootBreadcrumbs } from '../../helpers/breadcrumbs';

export interface TopNavProps {
opts: {
Expand All @@ -30,7 +30,7 @@ export const TopNav = ({ opts }: TopNavProps) => {
ui: { TopNavMenu },
},
core: {
application: { navigateToApp },
application: { navigateToApp, getUrlForApp },
},
data,
chrome,
Expand Down Expand Up @@ -74,25 +74,13 @@ export const TopNav = ({ opts }: TopNavProps) => {

if (savedSearch?.id) {
chrome.setBreadcrumbs([
{
text: i18n.translate('discover.discoverBreadcrumbTitle', {
defaultMessage: 'Discover',
}),
href: '#/',
},
...getRootBreadcrumbs(getUrlForApp(PLUGIN_ID)),
{ text: savedSearch.title },
]);
} else {
chrome.setBreadcrumbs([
{
text: i18n.translate('discover.discoverBreadcrumbTitle', {
defaultMessage: 'Discover',
}),
href: '#/',
},
]);
chrome.setBreadcrumbs([...getRootBreadcrumbs(getUrlForApp(PLUGIN_ID))]);
}
}, [chrome, savedSearch?.id, savedSearch?.title]);
}, [chrome, getUrlForApp, savedSearch?.id, savedSearch?.title]);

return (
<TopNavMenu
Expand Down