Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
justinkambic committed Jul 15, 2024
1 parent f1fa221 commit d129791
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 55 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* 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 {
EuiButtonEmpty,
EuiFlexGroup,
EuiFlexItem,
EuiIcon,
EuiPageTemplate,
EuiSpacer,
EuiTitle,
useEuiShadow,
useEuiTheme,
} from '@elastic/eui';
import { css } from '@emotion/react';
import { FormattedMessage } from '@kbn/i18n-react';
import React from 'react';
import { useLocation } from 'react-router-dom';
import { Header } from './header';
import backgroundImageUrl from './background.svg';
import { useIconForLogo } from '../../hooks/use_icon_for_logo';

export function HeaderSection() {
const path = useLocation().pathname;
const kubernetesLogo = useIconForLogo('kubernetes');
const theme = useEuiTheme();
const shadow = useEuiShadow('s');
// theme.euiTheme.size.
if (path === '/kubernetes') {
return (
<EuiPageTemplate.Section paddingSize="xl">
<EuiButtonEmpty
iconType="arrowLeft"
flush="left"
href="/observability"
data-test-subj="observabilityOnboardingFlowBackToSelectionButton"
>
<FormattedMessage
id="xpack.observability_onboarding.experimentalOnboardingFlow.button.returnButtonLabel"
defaultMessage="Return"
/>
</EuiButtonEmpty>
<EuiSpacer size="l" />
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<div
css={css`
border-radius: ${theme.euiTheme.border.radius.medium};
${shadow}
`}
>
<EuiIcon
size="xxl"
type={kubernetesLogo}
css={css`
margin: 12px;
width: 56px;
height: 56px;
`}
/>
</div>
</EuiFlexItem>
<EuiFlexItem>
<EuiTitle>
<h1>
<FormattedMessage
id="xpack.observability_onboarding.experimentalOnboardingFlow.header.text"
defaultMessage="Setting up Kubernetes with Elastic Agent"
/>
</h1>
</EuiTitle>
<EuiSpacer size="l" />
<p>
<FormattedMessage
id="xpack.observability_onboarding.experimentalOnboardingFlow.kubernetesDescription"
defaultMessage="This installation is tailored for configuring and collecting metrics and logs by deploying a new Elastic Agent within your host"
/>
</p>
</EuiFlexItem>
</EuiFlexGroup>
</EuiPageTemplate.Section>
);
}
return (
<EuiPageTemplate.Section
paddingSize="xl"
css={css`
& > div {
background-image: url(${backgroundImageUrl});
background-position: right center;
background-repeat: no-repeat;
}
`}
grow={false}
restrictWidth
>
<EuiSpacer size="xl" />
<Header />
</EuiPageTemplate.Section>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ import { Route, Routes } from '@kbn/shared-ux-router';
import { useLocation } from 'react-router-dom-v5-compat';
import { EuiPageTemplate, EuiPanel, EuiSpacer } from '@elastic/eui';
import { css } from '@emotion/react';
import backgroundImageUrl from './header/background.svg';
import { Footer } from './footer/footer';
import { OnboardingFlowForm } from './onboarding_flow_form/onboarding_flow_form';
import { Header } from './header/header';
import { SystemLogsPanel } from './quickstart_flows/system_logs';
import { CustomLogsPanel } from './quickstart_flows/custom_logs';
import { OtelLogsPanel } from './quickstart_flows/otel_logs';
import { AutoDetectPanel } from './quickstart_flows/auto_detect';
import { KubernetesPanel } from './quickstart_flows/kubernetes';
import { BackButton } from './shared/back_button';
import { HeaderSection } from './header/header_section';

const queryClient = new QueryClient();

Expand All @@ -38,21 +37,7 @@ export function ObservabilityOnboardingFlow() {
padding-top: 0px !important;
`}
>
<EuiPageTemplate.Section
paddingSize="xl"
css={css`
& > div {
background-image: url(${backgroundImageUrl});
background-position: right center;
background-repeat: no-repeat;
}
`}
grow={false}
restrictWidth
>
<EuiSpacer size="xl" />
<Header />
</EuiPageTemplate.Section>
<HeaderSection />
<EuiPageTemplate.Section paddingSize="xl" color="subdued" restrictWidth>
<Routes>
<Route path="/auto-detect">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { i18n } from '@kbn/i18n';

import React, { useCallback, useEffect, useRef, useState } from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import type { FunctionComponent } from 'react';
import {
EuiAvatar,
Expand All @@ -31,6 +30,8 @@ import { useCustomMargin } from '../shared/use_custom_margin';
import { Category } from './types';
import { useCustomCardsForCategory } from './use_custom_cards_for_category';
import { useVirtualSearchResults } from './use_virtual_search_results';
import type { SupportedLogo } from '../../hooks/types';
import { useIconForLogo } from '../../hooks/use_icon_for_logo';

interface UseCaseOption {
id: Category;
Expand All @@ -40,19 +41,6 @@ interface UseCaseOption {
showIntegrationsBadge?: boolean;
}

type SupportedLogo =
| 'aws'
| 'azure'
| 'docker'
| 'dotnet'
| 'prometheus'
| 'gcp'
| 'java'
| 'javascript'
| 'kubernetes'
| 'nginx'
| 'opentelemetry';

export const OnboardingFlowForm: FunctionComponent = () => {
const options: UseCaseOption[] = [
{
Expand Down Expand Up @@ -307,30 +295,6 @@ function scrollIntoViewWithOffset(element: HTMLElement, offset = 0) {
});
}

function useIconForLogo(logo?: SupportedLogo): string | undefined {
const {
services: { http },
} = useKibana();
switch (logo) {
case 'aws':
return 'logoAWS';
case 'azure':
return 'logoAzure';
case 'gcp':
return 'logoGCP';
case 'kubernetes':
return 'logoKubernetes';
case 'nginx':
return 'logoNginx';
case 'prometheus':
return 'logoPrometheus';
case 'docker':
return 'logoDocker';
default:
return http?.staticAssets.getPluginAssetHref(`${logo}.svg`);
}
}

function LogoIcon({ logo }: { logo: SupportedLogo }) {
const iconType = useIconForLogo(logo);
if (iconType) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* 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 type SupportedLogo =
| 'aws'
| 'azure'
| 'docker'
| 'dotnet'
| 'prometheus'
| 'gcp'
| 'java'
| 'javascript'
| 'kubernetes'
| 'nginx'
| 'opentelemetry';
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 { useKibana } from '@kbn/kibana-react-plugin/public';
import type { SupportedLogo } from './types';

export function useIconForLogo(logo?: SupportedLogo): string | undefined {
const {
services: { http },
} = useKibana();
switch (logo) {
case 'aws':
return 'logoAWS';
case 'azure':
return 'logoAzure';
case 'gcp':
return 'logoGCP';
case 'kubernetes':
return 'logoKubernetes';
case 'nginx':
return 'logoNginx';
case 'prometheus':
return 'logoPrometheus';
case 'docker':
return 'logoDocker';
default:
return http?.staticAssets.getPluginAssetHref(`${logo}.svg`);
}
}

0 comments on commit d129791

Please sign in to comment.