-
Notifications
You must be signed in to change notification settings - Fork 953
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
[Discover] A bunch of navigation fixes #5168
Changes from all commits
ca16442
4e9ee48
e8db30f
b8316cd
d8b133b
21c71a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,8 @@ | |
&:focus { | ||
opacity: 1; | ||
} | ||
|
||
@include ouiBreakpoint("xs", "s", "m") { | ||
opacity: 1; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ import { | |
import { DiscoverState, setSavedSearchId } from '../../utils/state_management'; | ||
import { DOC_HIDE_TIME_COLUMN_SETTING, SORT_DEFAULT_ORDER_SETTING } from '../../../../common'; | ||
import { getSortForSearchSource } from '../../view_components/utils/get_sort_for_search_source'; | ||
import { getRootBreadcrumbs } from '../../helpers/breadcrumbs'; | ||
|
||
export const getTopNavLinks = ( | ||
services: DiscoverViewServices, | ||
|
@@ -45,11 +46,9 @@ export const getTopNavLinks = ( | |
defaultMessage: 'New Search', | ||
}), | ||
run() { | ||
setTimeout(() => { | ||
history().push('/'); | ||
// 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); | ||
core.application.navigateToApp('discover', { | ||
path: '#/', | ||
}); | ||
Comment on lines
+49
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would this reload the page if i was already on discover? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it does :) |
||
}, | ||
testId: 'discoverNewButton', | ||
}; | ||
|
@@ -103,15 +102,7 @@ export const getTopNavLinks = ( | |
history().push(`/view/${encodeURIComponent(id)}`); | ||
} else { | ||
chrome.docTitle.change(savedSearch.lastSavedTitle); | ||
chrome.setBreadcrumbs([ | ||
{ | ||
text: i18n.translate('discover.discoverBreadcrumbTitle', { | ||
defaultMessage: 'Discover', | ||
}), | ||
href: '#/', | ||
}, | ||
{ text: savedSearch.title }, | ||
]); | ||
chrome.setBreadcrumbs([...getRootBreadcrumbs(), { text: savedSearch.title }]); | ||
} | ||
|
||
// set App state to clean | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
*/ | ||
|
||
import React, { useEffect, useState, useRef, useCallback } from 'react'; | ||
import { EuiFlexGroup, EuiFlexItem, EuiPanel } from '@elastic/eui'; | ||
import { EuiPanel } from '@elastic/eui'; | ||
import { TopNav } from './top_nav'; | ||
import { ViewProps } from '../../../../../data_explorer/public'; | ||
import { DiscoverTable } from './discover_table'; | ||
|
@@ -20,6 +20,7 @@ import { useOpenSearchDashboards } from '../../../../../opensearch_dashboards_re | |
import { filterColumns } from '../utils/filter_columns'; | ||
import { DEFAULT_COLUMNS_SETTING } from '../../../../common'; | ||
import './discover_canvas.scss'; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default function DiscoverCanvas({ setHeaderActionMenu, history }: ViewProps) { | ||
const { data$, refetch$, indexPattern } = useDiscoverContext(); | ||
|
@@ -77,38 +78,36 @@ export default function DiscoverCanvas({ setHeaderActionMenu, history }: ViewPro | |
const timeField = indexPattern?.timeFieldName ? indexPattern.timeFieldName : undefined; | ||
|
||
return ( | ||
<EuiFlexGroup direction="column" gutterSize="none" className="dscCanvas"> | ||
<EuiFlexItem grow={false}> | ||
<TopNav | ||
opts={{ | ||
setHeaderActionMenu, | ||
onQuerySubmit, | ||
}} | ||
/> | ||
</EuiFlexItem> | ||
<EuiPanel | ||
hasBorder={false} | ||
hasShadow={false} | ||
color="transparent" | ||
paddingSize="none" | ||
className="dscCanvas" | ||
> | ||
<TopNav | ||
opts={{ | ||
setHeaderActionMenu, | ||
onQuerySubmit, | ||
}} | ||
/> | ||
{status === ResultStatus.NO_RESULTS && ( | ||
<EuiFlexItem> | ||
<DiscoverNoResults timeFieldName={timeField} queryLanguage={''} /> | ||
</EuiFlexItem> | ||
<DiscoverNoResults timeFieldName={timeField} queryLanguage={''} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this appear at the vertical and horizontal center of the page? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It spans the width of the container but does not center to the vertical center. The flex was originally added to make the app appear as a full page application. Users have since complained about its usability like that so this change reverts it to a simpler layout allowing for scrolling, so having a centered component would not be really helpful. |
||
)} | ||
{status === ResultStatus.UNINITIALIZED && ( | ||
<DiscoverUninitialized onRefresh={() => refetch$.next()} /> | ||
)} | ||
{status === ResultStatus.LOADING && <LoadingSpinner />} | ||
{status === ResultStatus.READY && ( | ||
<> | ||
<EuiFlexItem grow={false}> | ||
<EuiPanel hasBorder={false} hasShadow={false} color="transparent" paddingSize="s"> | ||
<EuiPanel> | ||
<DiscoverChartContainer {...fetchState} /> | ||
</EuiPanel> | ||
<EuiPanel hasBorder={false} hasShadow={false} color="transparent" paddingSize="s"> | ||
<EuiPanel> | ||
<DiscoverChartContainer {...fetchState} /> | ||
</EuiPanel> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<DiscoverTable history={history} /> | ||
</EuiFlexItem> | ||
</EuiPanel> | ||
<DiscoverTable history={history} /> | ||
</> | ||
)} | ||
</EuiFlexGroup> | ||
</EuiPanel> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we hold this for better testing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the reason for this is because of the shared data model of OSD where the state is maintained in both the URL and the react memory. So far the assumption i've made is to have redux be the source of truth and update every other place from there. The problem here is that when the user navigates back using browser history, the URL state is no longer in sync with the redux state. The
opensearch_dashboard_util
wrappers that do the url state sync do something very similar.The one big concern I had with this was a race condition. This here is mitigated for both a URL update and Redux store update using the check to see if the url update was a pop action and if the states are identical. I'm open to improvements here but I think we should ship with this given that its a jarring expereince for users who have relied on browser navigation for discover.