From a488732161c217aedae13eb321d2bc514d043d2d Mon Sep 17 00:00:00 2001 From: Yngrid Coello Date: Mon, 14 Aug 2023 20:18:43 +0200 Subject: [PATCH] [Logs onboarding] Install steps for windows (#163735) Closes https://github.com/elastic/kibana/issues/162976. ### Changes: - `installAgentPlatformOptions` now have options for disabling the steps and rendering a custom children. - `WindowsInstallStep` component was created and used in customLogs and systemLogs. - Small fix where systemLogs was occupying the whole screen instead of the content space. - Return proper path depending on the platform selected. #### Before changes ##### system onboarding image ##### customLogs onboarding image #### After changes ##### system onboarding https://github.com/elastic/kibana/assets/1313018/6e566618-a790-4ffd-ac39-041678f8d362 ##### customLogs onboarding https://github.com/elastic/kibana/assets/1313018/bf908caf-e1d7-4273-8944-2923b9d0ec42 --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> --- .../wizard/install_elastic_agent.tsx | 6 +- .../app/system_logs/install_elastic_agent.tsx | 29 +- .../shared/install_elastic_agent_steps.tsx | 276 ++++++++++-------- .../shared/windows_install_step.tsx | 52 ++++ .../public/routes/templates/system_logs.tsx | 9 +- 5 files changed, 244 insertions(+), 128 deletions(-) create mode 100644 x-pack/plugins/observability_onboarding/public/components/shared/windows_install_step.tsx diff --git a/x-pack/plugins/observability_onboarding/public/components/app/custom_logs/wizard/install_elastic_agent.tsx b/x-pack/plugins/observability_onboarding/public/components/app/custom_logs/wizard/install_elastic_agent.tsx index 9d57f94cdde10..184ef62d81277 100644 --- a/x-pack/plugins/observability_onboarding/public/components/app/custom_logs/wizard/install_elastic_agent.tsx +++ b/x-pack/plugins/observability_onboarding/public/components/app/custom_logs/wizard/install_elastic_agent.tsx @@ -38,6 +38,7 @@ import { import { ApiKeyBanner } from './api_key_banner'; import { BackButton } from './back_button'; import { getDiscoverNavigationParams } from '../../utils'; +import { WindowsInstallStep } from '../../../shared/windows_install_step'; import { TroubleshootingLink } from '../../../shared/troubleshooting_link'; export function InstallElasticAgent() { @@ -328,7 +329,10 @@ export function InstallElasticAgent() { { defaultMessage: 'Windows' } ), id: 'windows', - isDisabled: true, + disableSteps: true, + children: ( + + ), }, ]} onSelectPlatform={(id) => setElasticAgentPlatform(id)} diff --git a/x-pack/plugins/observability_onboarding/public/components/app/system_logs/install_elastic_agent.tsx b/x-pack/plugins/observability_onboarding/public/components/app/system_logs/install_elastic_agent.tsx index 470ce4517bed4..5a71c588c0711 100644 --- a/x-pack/plugins/observability_onboarding/public/components/app/system_logs/install_elastic_agent.tsx +++ b/x-pack/plugins/observability_onboarding/public/components/app/system_logs/install_elastic_agent.tsx @@ -37,6 +37,7 @@ import { } from '../../shared/step_panel'; import { ApiKeyBanner } from '../custom_logs/wizard/api_key_banner'; import { getDiscoverNavigationParams } from '../utils'; +import { WindowsInstallStep } from '../../shared/windows_install_step'; import { SystemIntegrationBanner } from './system_integration_banner'; import { TroubleshootingLink } from '../../shared/troubleshooting_link'; @@ -249,9 +250,31 @@ export function InstallElasticAgent() { + ), + }, ]} onSelectPlatform={(id) => setElasticAgentPlatform(id)} selectedPlatform={elasticAgentPlatform} diff --git a/x-pack/plugins/observability_onboarding/public/components/shared/install_elastic_agent_steps.tsx b/x-pack/plugins/observability_onboarding/public/components/shared/install_elastic_agent_steps.tsx index 7eef98b4bc301..16996a18d05b0 100644 --- a/x-pack/plugins/observability_onboarding/public/components/shared/install_elastic_agent_steps.tsx +++ b/x-pack/plugins/observability_onboarding/public/components/shared/install_elastic_agent_steps.tsx @@ -23,7 +23,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { Buffer } from 'buffer'; -import React from 'react'; +import React, { ReactNode } from 'react'; import { intersection } from 'lodash'; import { FormattedMessage } from '@kbn/i18n-react'; import { StepStatus } from './step_status'; @@ -42,6 +42,8 @@ interface Props { label: string; id: PlatformId; isDisabled?: boolean; + disableSteps?: boolean; + children?: ReactNode; }>; onSelectPlatform: (id: PlatformId) => void; selectedPlatform: PlatformId; @@ -75,9 +77,134 @@ export function InstallElasticAgentSteps({ const isInstallStarted = intersection( Object.keys(installProgressSteps), - Object.keys(PROGRESS_STEP_TITLES) + Object.keys(PROGRESS_STEP_TITLES(selectedPlatform)) ).length > 0; - const autoDownloadConfigStep = getStep('ea-config', installProgressSteps); + const autoDownloadConfigStep = getStep( + 'ea-config', + installProgressSteps, + selectedPlatform + ); + + const customInstallStep = installAgentPlatformOptions.find( + (step) => step.id === selectedPlatform + )?.children; + const disableSteps = installAgentPlatformOptions.find( + (step) => step.id === selectedPlatform + )?.disableSteps; + + const installStepDefault = ( + <> + + {installAgentCommand} + + + {showInstallProgressSteps && ( + <> + + + {( + ['ea-download', 'ea-extract', 'ea-install', 'ea-status'] as const + ).map((stepId) => { + const { title, status, message } = getStep( + stepId, + installProgressSteps, + selectedPlatform + ); + return ( + + ); + })} + + + )} + + ); + + const configureStep = ( + <> + +

+ {autoDownloadConfig + ? i18n.translate( + 'xpack.observability_onboarding.installElasticAgent.configStep.auto.description', + { + defaultMessage: + 'The agent config below will be downloaded by the install script and written to ({configPath}). This will overwrite any existing agent configuration.', + values: { + configPath: '/opt/Elastic/Agent/elastic-agent.yml', + }, + } + ) + : i18n.translate( + 'xpack.observability_onboarding.installElasticAgent.configStep.manual.description', + { + defaultMessage: + 'Add the following configuration to {configPath} on the host where you installed the Elastic agent.', + values: { + configPath: '/opt/Elastic/Agent/elastic-agent.yml', + }, + } + )} +

+
+ + + + {configureAgentYaml} + + + + + {i18n.translate( + 'xpack.observability_onboarding.installElasticAgent.configStep.downloadConfigButton', + { defaultMessage: 'Download config file' } + )} + + {showInstallProgressSteps && autoDownloadConfig ? ( + <> + + + + + + ) : null} + + ); + return ( ({ } checked={autoDownloadConfig} onChange={onToggleAutoDownloadConfig} - disabled={isInstallStarted} + disabled={disableSteps || isInstallStarted} /> {autoDownloadConfig && ( @@ -186,38 +313,7 @@ export function InstallElasticAgentSteps({ isDisabled={isInstallStarted} /> - - {installAgentCommand} - - - {showInstallProgressSteps && ( - <> - - - {( - [ - 'ea-download', - 'ea-extract', - 'ea-install', - 'ea-status', - ] as const - ).map((stepId) => { - const { title, status, message } = getStep( - stepId, - installProgressSteps - ); - return ( - - ); - })} - - - )} + {customInstallStep || installStepDefault} ), }, @@ -226,88 +322,14 @@ export function InstallElasticAgentSteps({ 'xpack.observability_onboarding.installElasticAgent.configureStep.title', { defaultMessage: 'Configure the Elastic agent' } ), - status: configureAgentStatus, - children: ( - <> - -

- {autoDownloadConfig - ? i18n.translate( - 'xpack.observability_onboarding.installElasticAgent.configStep.auto.description', - { - defaultMessage: - 'The agent config below will be downloaded by the install script and written to ({configPath}). This will overwrite any existing agent configuration.', - values: { - configPath: '/opt/Elastic/Agent/elastic-agent.yml', - }, - } - ) - : i18n.translate( - 'xpack.observability_onboarding.installElasticAgent.configStep.manual.description', - { - defaultMessage: - 'Add the following configuration to {configPath} on the host where you installed the Elastic agent.', - values: { - configPath: '/opt/Elastic/Agent/elastic-agent.yml', - }, - } - )} -

-
- - - - {configureAgentYaml} - - - - - {i18n.translate( - 'xpack.observability_onboarding.installElasticAgent.configStep.downloadConfigButton', - { defaultMessage: 'Download config file' } - )} - - {showInstallProgressSteps && autoDownloadConfig ? ( - <> - - - - - - ) : null} - - ), + status: disableSteps ? 'disabled' : configureAgentStatus, + children: disableSteps ? <> : configureStep, }, - ...appendedSteps.map((euiStep) => ({ children: null, ...euiStep })), + ...appendedSteps.map((euiStep) => ({ + children: null, + ...euiStep, + status: disableSteps ? 'disabled' : euiStep.status, + })), ]} /> ); @@ -315,10 +337,11 @@ export function InstallElasticAgentSteps({ function getStep( id: ProgressStepId, - installProgressSteps: Props['installProgressSteps'] + installProgressSteps: Props['installProgressSteps'], + selectedPlatform: string ): { title: string; status: EuiStepStatus; message?: string } { const { loadingTitle, completedTitle, incompleteTitle } = - PROGRESS_STEP_TITLES[id]; + PROGRESS_STEP_TITLES(selectedPlatform)[id]; const stepProgress = installProgressSteps[id]; if (stepProgress) { const { status, message } = stepProgress; @@ -341,10 +364,12 @@ function getStep( }; } -const PROGRESS_STEP_TITLES: Record< +const PROGRESS_STEP_TITLES: ( + selectedPlatform: string +) => Record< ProgressStepId, Record<'incompleteTitle' | 'loadingTitle' | 'completedTitle', string> -> = { +> = (selectedPlatform: string) => ({ 'ea-download': { incompleteTitle: i18n.translate( 'xpack.observability_onboarding.installElasticAgent.progress.eaDownload.incompleteTitle', @@ -418,8 +443,13 @@ const PROGRESS_STEP_TITLES: Record< 'xpack.observability_onboarding.installElasticAgent.progress.eaConfig.completedTitle', { defaultMessage: 'Elastic Agent config written to {configPath}', - values: { configPath: '/opt/Elastic/Agent/elastic-agent.yml' }, + values: { + configPath: + selectedPlatform === 'macos' + ? '/Library/Elastic/Agent/elastic-agent.yml' + : '/opt/Elastic/Agent/elastic-agent.yml', + }, } ), }, -}; +}); diff --git a/x-pack/plugins/observability_onboarding/public/components/shared/windows_install_step.tsx b/x-pack/plugins/observability_onboarding/public/components/shared/windows_install_step.tsx new file mode 100644 index 0000000000000..42677924a4706 --- /dev/null +++ b/x-pack/plugins/observability_onboarding/public/components/shared/windows_install_step.tsx @@ -0,0 +1,52 @@ +/* + * 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 { EuiButton, EuiFlexGroup, EuiFlexItem, EuiText } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import React from 'react'; + +const DEFAULT_STANDALONE_ELASTIC_AGENT_DOCS = + 'https://www.elastic.co/guide/en/fleet/current/install-standalone-elastic-agent.html'; + +export function WindowsInstallStep({ + docsLink = DEFAULT_STANDALONE_ELASTIC_AGENT_DOCS, +}: { + docsLink?: string; +}) { + return ( + + + +

+ {i18n.translate( + 'xpack.observability_onboarding.windows.installStep.description', + { + defaultMessage: + 'This onboarding is currently only available for Linux and MacOS systems. See our documentation for information on streaming log files to Elastic from a Windows system.', + } + )} +

+
+
+ + + {i18n.translate( + 'xpack.observability_onboarding.windows.installStep.link.label', + { defaultMessage: 'Read docs' } + )} + + +
+ ); +} diff --git a/x-pack/plugins/observability_onboarding/public/routes/templates/system_logs.tsx b/x-pack/plugins/observability_onboarding/public/routes/templates/system_logs.tsx index 7881914d053d8..7224e27bbc121 100644 --- a/x-pack/plugins/observability_onboarding/public/routes/templates/system_logs.tsx +++ b/x-pack/plugins/observability_onboarding/public/routes/templates/system_logs.tsx @@ -46,7 +46,14 @@ export function SystemLogs({ children }: Props) { - {children} +
+ {children} +