Skip to content

Commit

Permalink
[Fleet] Fleet Server flyout fixes (#136566)
Browse files Browse the repository at this point in the history
* Go to Fleet mode when continue enrolling is selected

Fixes #136080

* Fix max width in Fleet Server flyout

Fixes #136079

* Use fleet mode when fleet server ready, standalone mode otherwise per PR feedback
  • Loading branch information
kpollich authored Jul 19, 2022
1 parent ef3213a commit f862943
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 6 deletions.
8 changes: 8 additions & 0 deletions x-pack/plugins/fleet/.storybook/context/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ export const getHttp = (basepath = BASE_PATH) => {
};
}

if (path.match('/api/fleet/agent_download_sources')) {
return {
items: [
{ name: 'Default Download Source', is_default: true, host: 'https://www.example.com' },
],
};
}

action(path)(`UNSUPPORTED ROUTE: GET ${path}`);
return {};
}) as HttpHandler,
Expand Down
9 changes: 7 additions & 2 deletions x-pack/plugins/fleet/public/applications/fleet/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import type { FleetConfigType, FleetStartServices } from '../../plugin';

import { PackageInstallProvider } from '../integrations/hooks';

import { useAuthz, useFlyoutContext } from './hooks';
import { useAuthz, useFleetStatus, useFlyoutContext } from './hooks';

import {
ConfigContext,
Expand Down Expand Up @@ -304,6 +304,7 @@ const FleetTopNav = memo(
export const AppRoutes = memo(
({ setHeaderActionMenu }: { setHeaderActionMenu: AppMountParameters['setHeaderActionMenu'] }) => {
const flyoutContext = useFlyoutContext();
const fleetStatus = useFleetStatus();

return (
<>
Expand Down Expand Up @@ -361,7 +362,11 @@ export const AppRoutes = memo(
{flyoutContext.isEnrollmentFlyoutOpen && (
<EuiPortal>
<AgentEnrollmentFlyout
defaultMode="standalone"
defaultMode={
fleetStatus.isReady && !fleetStatus.missingRequirements?.includes('fleet_server')
? 'managed'
: 'standalone'
}
isIntegrationFlow={true}
onClose={() => flyoutContext.closeEnrollmentFlyout()}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import { css } from '@emotion/react';

import { useLink } from '../../../hooks';

Expand Down Expand Up @@ -97,7 +98,11 @@ const GettingStartedStepContent: React.FunctionComponent<{

<EuiForm onSubmit={quickStartCreateForm.submit}>
<EuiFlexGroup>
<EuiFlexItem>
<EuiFlexItem
css={css`
max-width: 100%;
`}
>
<FleetServerHostComboBox
fleetServerHost={fleetServerHost}
fleetServerHostSettings={fleetServerHostSettings}
Expand Down
14 changes: 12 additions & 2 deletions x-pack/plugins/fleet/public/applications/integrations/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public';

import type { FleetConfigType, FleetStartServices } from '../../plugin';

import { ConfigContext, FleetStatusProvider, KibanaVersionContext } from '../../hooks';
import {
ConfigContext,
FleetStatusProvider,
KibanaVersionContext,
useFleetStatus,
} from '../../hooks';

import { FleetServerFlyout } from '../fleet/components';

Expand Down Expand Up @@ -110,6 +115,7 @@ export const IntegrationsAppContext: React.FC<{

export const AppRoutes = memo(() => {
const flyoutContext = useFlyoutContext();
const fleetStatus = useFleetStatus();

return (
<>
Expand Down Expand Up @@ -142,7 +148,11 @@ export const AppRoutes = memo(() => {
{flyoutContext.isEnrollmentFlyoutOpen && (
<EuiPortal>
<AgentEnrollmentFlyout
defaultMode="standalone"
defaultMode={
fleetStatus.isReady && fleetStatus.missingRequirements?.includes('fleet_server')
? 'managed'
: 'standalone'
}
isIntegrationFlow={true}
onClose={() => flyoutContext.closeEnrollmentFlyout()}
/>
Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugins/fleet/public/hooks/use_flyout_context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export const FlyoutContextProvider: React.FunctionComponent = ({ children }) =>
<agentFlyoutContext.Provider
value={{
isEnrollmentFlyoutOpen,
openEnrollmentFlyout: () => setIsEnrollmentFlyoutOpen(true),
openEnrollmentFlyout: () => {
setIsEnrollmentFlyoutOpen(true);
},
closeEnrollmentFlyout: () => setIsEnrollmentFlyoutOpen(false),
isFleetServerFlyoutOpen,
openFleetServerFlyout: () => setIsFleetServerFlyoutOpen(true),
Expand Down

0 comments on commit f862943

Please sign in to comment.