-
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] Add Endpoint empty states for onboarding #69626
Changes from 19 commits
f9982f1
a319fc1
d203642
08afb5a
899f0cf
4316454
08bbc88
6260e5e
1c55b23
f5e3999
eb4b259
b9129eb
a93a1fa
3206882
439e8e9
e683508
7f656f8
71690bf
310b8ef
3529c1c
f364e74
8399f0e
18dd954
9689d04
d425f46
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 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -3,8 +3,8 @@ | |||||||||
* or more contributor license agreements. Licensed under the Elastic License; | ||||||||||
* you may not use this file except in compliance with the Elastic License. | ||||||||||
*/ | ||||||||||
import React, { useMemo, useState } from 'react'; | ||||||||||
import { Redirect, useRouteMatch, Switch, Route, useHistory } from 'react-router-dom'; | ||||||||||
import React, { useMemo, useState, useCallback } from 'react'; | ||||||||||
import { Redirect, useRouteMatch, Switch, Route, useHistory, useLocation } from 'react-router-dom'; | ||||||||||
import { i18n } from '@kbn/i18n'; | ||||||||||
import { FormattedMessage, FormattedDate } from '@kbn/i18n/react'; | ||||||||||
import { | ||||||||||
|
@@ -21,14 +21,16 @@ import { | |||||||||
} from '@elastic/eui'; | ||||||||||
import { Props as EuiTabProps } from '@elastic/eui/src/components/tabs/tab'; | ||||||||||
import styled from 'styled-components'; | ||||||||||
import { AgentConfig } from '../../../types'; | ||||||||||
import queryString from 'query-string'; | ||||||||||
import { AgentConfig, AgentConfigDetailsDeployAgentAction } from '../../../types'; | ||||||||||
import { PAGE_ROUTING_PATHS } from '../../../constants'; | ||||||||||
import { useGetOneAgentConfig, useLink, useBreadcrumbs } from '../../../hooks'; | ||||||||||
import { useGetOneAgentConfig, useLink, useBreadcrumbs, useCore } from '../../../hooks'; | ||||||||||
import { Loading } from '../../../components'; | ||||||||||
import { WithHeaderLayout } from '../../../layouts'; | ||||||||||
import { ConfigRefreshContext, useGetAgentStatus, AgentStatusRefreshContext } from './hooks'; | ||||||||||
import { LinkedAgentCount, AgentConfigActionMenu } from '../components'; | ||||||||||
import { ConfigDatasourcesView, ConfigSettingsView } from './components'; | ||||||||||
import { useIntraAppState } from '../../../hooks/use_intra_app_state'; | ||||||||||
|
||||||||||
const Divider = styled.div` | ||||||||||
width: 0; | ||||||||||
|
@@ -48,7 +50,13 @@ export const AgentConfigDetailsPage: React.FunctionComponent = () => { | |||||||||
const [redirectToAgentConfigList] = useState<boolean>(false); | ||||||||||
const agentStatusRequest = useGetAgentStatus(configId); | ||||||||||
const { refreshAgentStatus } = agentStatusRequest; | ||||||||||
const { | ||||||||||
application: { navigateToApp }, | ||||||||||
} = useCore(); | ||||||||||
const routeState = useIntraAppState<AgentConfigDetailsDeployAgentAction>(); | ||||||||||
const agentStatus = agentStatusRequest.data?.results; | ||||||||||
const openEnrollmentFlyoutOpenByDefault = | ||||||||||
queryString.parse(useLocation().search).openEnrollmentFlyout === 'true'; | ||||||||||
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. Can we use
Suggested change
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. FYI - If I remember correctly, the last time I tried to use URLSearchParams I had issues in the Jest UT environment because I think 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. I just pulled in the |
||||||||||
|
||||||||||
const headerLeftContent = useMemo( | ||||||||||
() => ( | ||||||||||
|
@@ -95,6 +103,12 @@ export const AgentConfigDetailsPage: React.FunctionComponent = () => { | |||||||||
[getHref, agentConfig, configId] | ||||||||||
); | ||||||||||
|
||||||||||
const enrollmentCancelClickHandler = useCallback(() => { | ||||||||||
if (routeState && routeState.onDoneNavigateTo) { | ||||||||||
navigateToApp(routeState.onDoneNavigateTo[0], routeState.onDoneNavigateTo[1]); | ||||||||||
} | ||||||||||
}, [routeState, navigateToApp]); | ||||||||||
|
||||||||||
const headerRightContent = useMemo( | ||||||||||
() => ( | ||||||||||
<EuiFlexGroup justifyContent={'flexEnd'} direction="row"> | ||||||||||
|
@@ -155,6 +169,12 @@ export const AgentConfigDetailsPage: React.FunctionComponent = () => { | |||||||||
onCopySuccess={(newAgentConfig: AgentConfig) => { | ||||||||||
history.push(getPath('configuration_details', { configId: newAgentConfig.id })); | ||||||||||
}} | ||||||||||
enrollmentFlyoutOpenByDefault={openEnrollmentFlyoutOpenByDefault} | ||||||||||
onCancelEnrollment={ | ||||||||||
routeState && routeState.onDoneNavigateTo | ||||||||||
? enrollmentCancelClickHandler | ||||||||||
: undefined | ||||||||||
} | ||||||||||
/> | ||||||||||
), | ||||||||||
}, | ||||||||||
|
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.
It's not clear to me what's happening here, and I'm a bit uneasy with the chain of string operations on the url.
After playing around a bit I think I see the intent and, IIUC, I'd prefer something more explicit/safe like
URL
which is available in the browser and nodeThere 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.
@jfsiii @paul-tavares I solved this by just passing in the url base path as well from the state so that we can control it from there. It saves us from having to parse potential query params and is more exact. let me know your thoughts