-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Endpoint] Task/add nav bar #58604
[Endpoint] Task/add nav bar #58604
Conversation
Pinging @elastic/endpoint-app-team (Feature:Endpoint) |
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.
@kevinlog should the header navigation component be split off into its own separate component instead of placing it into the index.tsx
?
Also, the array of Nav tabs might become useful as well in other places (later) if we want to reference a centralized place that holds the to
path to the different application pages (in order to build links, or redirect users).
function renderNavTabs(tabs: NavTabs[]) { | ||
return tabs.map((tab, index) => { | ||
return ( | ||
<NavLink |
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.
We should probably use theEuiTabs
component for this and not the NavLink
from react-router. EuiTab
allows for href
to be set as well as a onClick
callback - the callback would be where you can handle calling react-router's history.push
. We might need to styled
the EuiTabs
a little (see example in Ingest just committed recently)
Also - one of the thing the EUI team discourages is to use the internal class names on components directly like this :(
const navTabs: NavTabs[] = [ | ||
{ | ||
name: 'home', | ||
display: 'Home', |
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.
Need to i18n
all display values
@kevinlog just read your question in the PR description re: redux ++ middleware. |
@paul-tavares thanks for the detailed comments. I adjusted the PR to use EuiTabs directly, let me know what you think |
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.
LGTM
Only minor change. Thanks
x-pack/plugins/endpoint/public/applications/endpoint/components/header_nav.tsx
Outdated
Show resolved
Hide resolved
<EuiTab | ||
data-testid={`${tab.id}Link`} | ||
key={index} | ||
onClick={() => { |
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.
I'm ok this now having an href
at this time, but we should decide if we should include one in the tab in order to enable the user to open in separate window/tab.
Actually: question - do you need test cases for this? Probably a few, at least to validate that we're correctly setting the selected tab. Also, what happens when we get routed to an invalid URI (I assume no tab is selected, but nav is still visible). |
…s/header_nav.tsx Co-Authored-By: Paul Tavares <56442535+paul-tavares@users.noreply.github.com>
@elasticmachine merge upstream |
Pinging @elastic/endpoint-response (Team:Endpoint Response) |
Pinging @elastic/endpoint-management (Team:Endpoint Management) |
Pinging @elastic/endpoint-data-visibility-team (Team:Endpoint Data Visibility) |
data-testid={`${tab.id}EndpointTab`} | ||
data-test-subj={`${tab.id}EndpointTab`} | ||
key={index} | ||
href={`/app/endpoint${tab.href}`} |
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.
🔴 You can't hardcode the /app/endpoint
or else you break when kibana is running with base-path. I think @kqualters-elastic has added the use of kibana-react to our application, wich means we can use their hook to retrieve coreStart and then get the base path from the http
service (see this: #58288 (comment)).
An alternative for now is to add a basePath
prop to this component and then send it in from index.tsx
since you should have that info. available there.
@@ -41,6 +42,7 @@ const AppRoot: React.FunctionComponent<RouterProps> = React.memo(({ basename, st | |||
<I18nProvider> | |||
<BrowserRouter basename={basename}> | |||
<RouteCapture> | |||
<HeaderNavigation /> |
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.
Here, you can pass in basename
to HeaderNavigation
data-test-subj={`${tab.id}EndpointTab`} | ||
key={index} | ||
href={`/app/endpoint${tab.href}`} | ||
onClick={(event: MouseEvent) => { |
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.
An idea for how we could emulate react-router when using Eui components.
oatkiller@d6861d8
Things this handles:
- useCallback for the callback
- doesn't navigate when modifier keys are pressed
- can call an additional onClick handler if needed (navigate via a link AND have a callback)
- doesn't navigate if event is 'defaultPrevented'
- logic copied from react-router's link, so behavior is consistent
- should work in EuiLink as well
see react router's implementation for ideas
https://github.com/ReactTraining/react-router/blob/master/packages/react-router-dom/modules/Link.js
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.
Great approach that prevents us having to wrap Eui components 👍
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.
@oatkiller @paul-tavares this doesn't quite work yet, I broke this out to another ticket: https://github.com/elastic/endpoint-app-team/issues/230
Are you OK to merge this as is and I'll investigate the next step for this?
name: i18n.translate('xpack.endpoint.headerNav.management', { | ||
defaultMessage: 'Management', | ||
}), | ||
href: '/management', |
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.
@paul-tavares does the basePath
concern apply here as well?
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.
@bkimmel no - here its ok because we're using this value against react-router which we initialize with a basePath
(the one provided during plugin initialization). So these should be (absolute) relative to basePath
}, | ||
]; | ||
|
||
const Tabs = styled(EuiTabs)` |
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.
❔ There is also EuiTabbedContent
which seems like it would capture some more of what you're trying to accomplish here. Can you elaborate on why you didn't use the EuiTabbedContent
approach?
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.
@bkimmel that styled doesn't make a difference that I can see, so I removed it. m See this for the original context #58604 (comment)
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.
LGTM 👍
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync. |
Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync. |
…dex-server-side * 'master' of github.com:elastic/kibana: (34 commits) [Upgrade Assistant] Remove "boom" from reindex service (elastic#58715) [data] Clean up QueryStringInput unit tests (elastic#58704) [SIEM] Detection Fix typo in Adobe Hijack Persistence rule (elastic#58804) Restores [SIEM][CASE] Init Configure Case Page (elastic#58121) (elastic#58924) Skips additional failing Ingest Manager integration tests Skips failing Ingest Manager integration tests Move dev tools styles to NP (elastic#58855) change to have kibana --ssl cli option use more recent certs (elastic#57933) disable failing suite (elastic#58942) Don't start pollEsNodesVersion unless someone subscribes (elastic#56923) Do not write UUID file during optimize process (elastic#58899) [Endpoint] Task/add nav bar (elastic#58604) [Metric Alerts] Add backend support for multiple expressions per alert (elastic#58672) [Metrics Alerts] Fix alerting on a rate aggregation (elastic#58789) disable flaky suite (elastic#55953) Revert "[SIEM] apollo@3 (elastic#51926)" and "[SIEM][CASE] Init Confi… (elastic#58806) [resubmit] Prep agg types for new platform (elastic#58893) [Lens] Allow number formatting within Lens (elastic#56253) [Autocomplete] Use settings from config rather than UI settings (elastic#58784) Improve action and trigger types (elastic#58657) ... # Conflicts: # x-pack/plugins/upgrade_assistant/server/routes/reindex_indices/reindex_indices.ts
Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync. |
* Add tabs to the Endpoint app. Uses EuiTabs and browser history for integration with react-router Co-authored-by: Paul Tavares <56442535+paul-tavares@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Paul Tavares <56442535+paul-tavares@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Summary
A PR to add a header nav to the endpoint app. Uses EuiTabs with useHistory to add the urls to our router history. Thanks to RouteCapture, will properly update the URL in the redux store.
Now contains tests.
Implements https://github.com/elastic/endpoint-app-team/issues/174
Redux:
Checklist
Delete any items that are not applicable to this PR.
For maintainers