-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Fleet] Add redesigned Fleet Server flyout #127786
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
Merged
kpollich
merged 65 commits into
elastic:main
from
kpollich:125640-redesign-fleet-server-flyout
Apr 26, 2022
Merged
Changes from all commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
c3be6f3
WIP new fleet server flyout
kpollich ad6ec87
WIP finish up quick start tab
kpollich 4ed4f39
Refactor quick start steps into separate files:
kpollich a62ed8e
Initial refactor of existing fleet server instructions
kpollich b1e053b
Move quick start form return value to explicit type
kpollich dfefd46
Merge branch 'main' into 125640-redesign-fleet-server-flyout
kpollich 8200ced
Flesh out fleet server commands
kpollich 54d5309
Fix translation error
kpollich f0a82f3
Merge branch 'main' into 125640-redesign-fleet-server-flyout
kibanamachine 95e76ba
Migrate on prem instructions component over to new file structure
kpollich 3f736d9
Makes quick start tab actually create policy
kpollich ef9501d
Fix type errors
kpollich 587a079
Fix missing hooks + update snapshots
kpollich ee9cad7
Fix paths in mocks
kpollich 32c77f1
Merge branch 'main' into 125640-redesign-fleet-server-flyout
kibanamachine d56dc36
Fix translations
kpollich 861cab9
WIP test fixes
kpollich f2bdc98
Implement enabled/disabled state for new steps
kpollich e9c49b9
Fix cypress tests
kpollich 4445ec0
Force re-render to get last test passing
kpollich 55fa9af
Merge branch 'main' into 125640-redesign-fleet-server-flyout
kibanamachine 7803951
Merge branch 'main' into 125640-redesign-fleet-server-flyout
kibanamachine 0f1b433
Merge branch 'main' into 125640-redesign-fleet-server-flyout
kpollich 8b0b935
Fix failing tests
kpollich 9efcc32
Merge branch 'main' into 125640-redesign-fleet-server-flyout
kibanamachine 6cb6159
Merge branch 'main' into 125640-redesign-fleet-server-flyout
kpollich dbb8df6
Fix import errors after conflicts
kpollich 4da4500
Fix snapshot tests
kpollich 203d8d4
Use id instead of full policy for policy selector
kpollich 6d00c52
Merge branch 'main' into 125640-redesign-fleet-server-flyout
kibanamachine e8c49ec
Replace Fleet Server instructions w/ Advanced Tab contents
kpollich 95aefe0
Merge branch 'main' into 125640-redesign-fleet-server-flyout
kpollich b30c863
First pass at integrating add agent/fleet server flyouts
kpollich 38e112f
Merge branch 'main' into 125640-redesign-fleet-server-flyout
kpollich a14d03a
Merge branch 'main' into 125640-redesign-fleet-server-flyout
kpollich 180bcbb
Test commit
kpollich d3474f5
Fix imports
kpollich 069fb53
Fix imports
kpollich cedcf9e
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine 77f6694
Enforce https-only fleet server URL's + improve errors
kpollich 463b9e6
Fix failing tests
kpollich 14832b4
Fix fleet server command in quick start
kpollich 2c13ec0
Show success state in Quick start when policy exists + use first flee…
kpollich 8f6a0ca
Set initial service token value when Fleet Server policy ID is initia…
kpollich 4025091
Generate service token instead of enrollment token
kpollich d9e5e76
Fix fleet server flyout opening from unhealthy callout
kpollich 46fc10b
Merge branch 'main' into 125640-redesign-fleet-server-flyout
kibanamachine 7df14b3
Revert service token change + use EuiComboBox for fleet server host
kpollich 558e9f9
Fix checks + use custom option text
kpollich aebd3f0
Move fleet server host combobox to component
kpollich 0d51642
Use new combobox in advanced tab
kpollich 6275fbe
Merge branch 'main' into 125640-redesign-fleet-server-flyout
kpollich ebb4ab4
Fix translations
kpollich 6a3fe45
Fix unused import
kpollich fccda94
Don't recreate quick start policy if it already exists
kpollich 420586d
Actually use quick start policy fields 🙃
kpollich 08edc05
Fix policy check
kpollich 72e4f80
Merge branch 'main' into 125640-redesign-fleet-server-flyout
kibanamachine 3778c54
Merge branch 'main' into 125640-redesign-fleet-server-flyout
kibanamachine 42c43bd
Merge branch 'main' into 125640-redesign-fleet-server-flyout
kibanamachine cb0ee61
Update x-pack/plugins/fleet/public/applications/fleet/components/flee…
kpollich d7317a0
Update x-pack/plugins/fleet/public/applications/fleet/components/flee…
kpollich abe3524
Update x-pack/plugins/fleet/public/applications/fleet/components/flee…
kpollich 1cfe1b7
Fix formatting issue
kpollich 4d93d05
Clean up fleet server settings variable declaration per PR review
kpollich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...ins/fleet/public/applications/fleet/components/fleet_server_instructions/advanced_tab.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
| import { EuiSteps } from '@elastic/eui'; | ||
| import React from 'react'; | ||
|
|
||
| import { useAdvancedForm } from './hooks'; | ||
|
|
||
| import { | ||
| getAddFleetServerHostStep, | ||
| getSelectAgentPolicyStep, | ||
| getGenerateServiceTokenStep, | ||
| getSetDeploymentModeStep, | ||
| getInstallFleetServerStep, | ||
| getConfirmFleetServerConnectionStep, | ||
| } from './steps'; | ||
|
|
||
| export const AdvancedTab: React.FunctionComponent = () => { | ||
| const { | ||
| eligibleFleetServerPolicies, | ||
| refreshEligibleFleetServerPolicies, | ||
| fleetServerPolicyId, | ||
| setFleetServerPolicyId, | ||
| isFleetServerReady, | ||
| serviceToken, | ||
| isLoadingServiceToken, | ||
| generateServiceToken, | ||
| fleetServerHostForm, | ||
| deploymentMode, | ||
| setDeploymentMode, | ||
| } = useAdvancedForm(); | ||
|
|
||
| const steps = [ | ||
| getSelectAgentPolicyStep({ | ||
| policyId: fleetServerPolicyId, | ||
| setPolicyId: setFleetServerPolicyId, | ||
| eligibleFleetServerPolicies, | ||
| refreshEligibleFleetServerPolicies, | ||
| }), | ||
| getSetDeploymentModeStep({ | ||
| deploymentMode, | ||
| setDeploymentMode, | ||
| disabled: !Boolean(fleetServerPolicyId), | ||
| }), | ||
| getAddFleetServerHostStep({ fleetServerHostForm, disabled: !Boolean(fleetServerPolicyId) }), | ||
| getGenerateServiceTokenStep({ | ||
| serviceToken, | ||
| generateServiceToken, | ||
| isLoadingServiceToken, | ||
| disabled: !Boolean(fleetServerHostForm.isFleetServerHostSubmitted), | ||
| }), | ||
| getInstallFleetServerStep({ | ||
| isFleetServerReady, | ||
| serviceToken, | ||
| fleetServerHost: fleetServerHostForm.fleetServerHost, | ||
| fleetServerPolicyId, | ||
| disabled: !Boolean(serviceToken), | ||
| }), | ||
| getConfirmFleetServerConnectionStep({ isFleetServerReady, disabled: !Boolean(serviceToken) }), | ||
| ]; | ||
|
|
||
| return <EuiSteps steps={steps} className="eui-textLeft" />; | ||
| }; | ||
77 changes: 77 additions & 0 deletions
77
...ions/fleet/components/fleet_server_instructions/components/fleet_server_host_combobox.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
| import React, { useState } from 'react'; | ||
| import type { EuiComboBoxOptionOption } from '@elastic/eui'; | ||
| import { EuiComboBox, EuiText } from '@elastic/eui'; | ||
| import { FormattedMessage } from '@kbn/i18n-react'; | ||
| import { i18n } from '@kbn/i18n'; | ||
|
|
||
| interface Props { | ||
| fleetServerHost: string | undefined; | ||
| fleetServerHostSettings: string[]; | ||
| isDisabled: boolean; | ||
| isInvalid: boolean; | ||
| onFleetServerHostChange: (host: string) => void; | ||
| } | ||
|
|
||
| export const FleetServerHostComboBox: React.FunctionComponent<Props> = ({ | ||
| fleetServerHost, | ||
| fleetServerHostSettings, | ||
| isDisabled = false, | ||
| isInvalid = false, | ||
| onFleetServerHostChange, | ||
| }) => { | ||
| // Track options that are created inline | ||
| const [createdOptions, setCreatedOptions] = useState<string[]>([]); | ||
|
|
||
| const options = [...createdOptions, ...fleetServerHostSettings].map((option) => ({ | ||
| label: option, | ||
| value: option, | ||
| })); | ||
|
|
||
| const handleChange = (selectedOptions: Array<EuiComboBoxOptionOption<string>>) => { | ||
| const host = selectedOptions[0].value ?? ''; | ||
| onFleetServerHostChange(host); | ||
| }; | ||
|
|
||
| const handleCreateOption = (option: string) => { | ||
| setCreatedOptions([...createdOptions, option]); | ||
| onFleetServerHostChange(option); | ||
| }; | ||
|
|
||
| return ( | ||
| <EuiComboBox<string> | ||
| fullWidth | ||
| isClearable={false} | ||
| singleSelection={{ asPlainText: true }} | ||
| placeholder="https://fleet-server-host.com:8220" | ||
| options={options} | ||
| customOptionText={i18n.translate( | ||
| 'xpack.fleet.fleetServerSetup.addFleetServerHostCustomOptionText', | ||
| { | ||
| defaultMessage: 'Add {searchValuePlaceholder} as a new Fleet Server host', | ||
| values: { searchValuePlaceholder: '{searchValue}' }, | ||
| } | ||
| )} | ||
| selectedOptions={fleetServerHost ? [{ label: fleetServerHost, value: fleetServerHost }] : []} | ||
| prepend={ | ||
| <EuiText> | ||
| <FormattedMessage | ||
| id="xpack.fleet.fleetServerSetup.addFleetServerHostInputLabel" | ||
| defaultMessage="Fleet Server host" | ||
| /> | ||
| </EuiText> | ||
| } | ||
| noSuggestions={fleetServerHostSettings.length === 0} | ||
| data-test-subj="fleetServerHostInput" | ||
| isDisabled={isDisabled} | ||
| isInvalid={isInvalid} | ||
| onChange={handleChange} | ||
| onCreateOption={handleCreateOption} | ||
| /> | ||
| ); | ||
| }; |
7 changes: 7 additions & 0 deletions
7
.../fleet/public/applications/fleet/components/fleet_server_instructions/components/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
| export * from './fleet_server_host_combobox'; |
33 changes: 33 additions & 0 deletions
33
...s/fleet/public/applications/fleet/components/fleet_server_instructions/flyout.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
| import { EuiButton } from '@elastic/eui'; | ||
|
|
||
| import { FleetServerFlyout as FleetServerFlyoutComponent } from '.'; | ||
|
|
||
| export const FleetServerFlyout = () => { | ||
| const [isOpen, setIsOpen] = React.useState(false); | ||
|
|
||
| return ( | ||
| <div style={{ width: 900 }}> | ||
| <EuiButton size="m" fill color="primary" onClick={() => setIsOpen(true)}> | ||
| Show flyout | ||
| </EuiButton> | ||
| {isOpen && <FleetServerFlyoutComponent onClose={() => setIsOpen(false)} />} | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| FleetServerFlyout.args = { | ||
| isCloudEnabled: false, | ||
| }; | ||
|
|
||
| export default { | ||
| component: FleetServerFlyout, | ||
| title: 'Sections/Fleet/Agents/Fleet Server Instructions/In Flyout', | ||
| }; |
18 changes: 18 additions & 0 deletions
18
...ugins/fleet/public/applications/fleet/components/fleet_server_instructions/hooks/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| // These hooks are tightly coupled to each tab of the Fleet server instructions component, and provide | ||
| // all necessary data to drive those UI's | ||
| export * from './use_advanced_form'; | ||
| export * from './use_quick_start_form'; | ||
|
|
||
| // These are individual hooks for one-off consumption. These are typically composed in the hooks above, | ||
| // but exported here to support individual usage. | ||
| export * from './use_wait_for_fleet_server'; | ||
| export * from './use_select_fleet_server_policy'; | ||
| export * from './use_service_token'; | ||
| export * from './use_fleet_server_host'; |
46 changes: 46 additions & 0 deletions
46
...public/applications/fleet/components/fleet_server_instructions/hooks/use_advanced_form.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import { useState } from 'react'; | ||
|
|
||
| import type { DeploymentMode } from '../steps'; | ||
|
|
||
| import { useFleetServerHost } from './use_fleet_server_host'; | ||
| import { useSelectFleetServerPolicy } from './use_select_fleet_server_policy'; | ||
| import { useServiceToken } from './use_service_token'; | ||
| import { useWaitForFleetServer } from './use_wait_for_fleet_server'; | ||
|
|
||
| /** | ||
| * Provides all data/state required for the "advanced" tab in the Fleet Server instructions/flyout | ||
| */ | ||
| export const useAdvancedForm = (defaultAgentPolicyId?: string) => { | ||
| const { | ||
| eligibleFleetServerPolicies, | ||
| refreshEligibleFleetServerPolicies, | ||
| fleetServerPolicyId, | ||
| setFleetServerPolicyId, | ||
| } = useSelectFleetServerPolicy(defaultAgentPolicyId); | ||
| const { isFleetServerReady } = useWaitForFleetServer(); | ||
| const { serviceToken, isLoadingServiceToken, generateServiceToken } = useServiceToken(); | ||
| const fleetServerHostForm = useFleetServerHost(); | ||
|
|
||
| const [deploymentMode, setDeploymentMode] = useState<DeploymentMode>('quickstart'); | ||
|
|
||
| return { | ||
| eligibleFleetServerPolicies, | ||
| refreshEligibleFleetServerPolicies, | ||
| fleetServerPolicyId, | ||
| setFleetServerPolicyId, | ||
| isFleetServerReady, | ||
| serviceToken, | ||
| isLoadingServiceToken, | ||
| generateServiceToken, | ||
| fleetServerHostForm, | ||
| deploymentMode, | ||
| setDeploymentMode, | ||
| }; | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 was a little on the fence about wrapping all of this data up into a single hook like this, and I could probably be convinced that it'd be better to simply compose multiple hooks in these "tab" files instead. The only real problem this solves is in
managed_instructions.tsxwhere we import this sameuseAdvancedFormhook because we need almost all of this state again, so it made sense to simply ship the "composed" set of hooks all at once to prevent too much repetition between these two places.However, I could see the argument that our hooks should be a little more specific than this, which is very coupled to a given UI.