Skip to content

Commit

Permalink
[Data Explorer] Fixes save search glitch + misc (#4870) (#4880)
Browse files Browse the repository at this point in the history
* Hide view toggle



* misc fixes



* fixes save behavior



---------


(cherry picked from commit 51c5360)

Signed-off-by: Ashwin P Chandran <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 200ca6c commit fae4e3c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 175 deletions.
5 changes: 3 additions & 2 deletions src/plugins/data_explorer/public/components/sidebar/index.tsx
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

0 comments on commit fae4e3c

Please sign in to comment.