From 85903ae3ec29793cedd198fa082e2822209da27a Mon Sep 17 00:00:00 2001 From: Dave Sudia Date: Fri, 17 Jan 2025 16:07:02 -0700 Subject: [PATCH] abstracts discover overview content determination --- .../src/Discover/Shared/Overview/Overview.tsx | 47 ++++++------------- .../src/Discover/Shared/Overview/content.tsx | 22 +++++++++ .../src/Discover/Shared/Overview/types.ts | 11 +++++ 3 files changed, 48 insertions(+), 32 deletions(-) create mode 100644 web/packages/teleport/src/Discover/Shared/Overview/content.tsx create mode 100644 web/packages/teleport/src/Discover/Shared/Overview/types.ts diff --git a/web/packages/teleport/src/Discover/Shared/Overview/Overview.tsx b/web/packages/teleport/src/Discover/Shared/Overview/Overview.tsx index 001b2dd516fc1..bf6ed3ba1a69b 100644 --- a/web/packages/teleport/src/Discover/Shared/Overview/Overview.tsx +++ b/web/packages/teleport/src/Discover/Shared/Overview/Overview.tsx @@ -16,47 +16,30 @@ * along with this program. If not, see . */ -import { - ActionButtons, - Header, - HeaderSubtitle, -} from 'teleport/Discover/Shared'; +import { Subtitle1 } from 'design'; + +import { ActionButtons, Header } from 'teleport/Discover/Shared'; +import { Overview as IOverview } from 'teleport/Discover/Shared/Overview/types'; import { useDiscover } from 'teleport/Discover/useDiscover'; +import { content } from './content'; + export function Overview() { - const { prevStep, nextStep, isUpdateFlow } = useDiscover(); + const { prevStep, nextStep, resourceSpec, isUpdateFlow } = useDiscover(); + + if (!(resourceSpec.id in content)) { + //todo handle error + } - const pageItems = { - kubernetes: { - overview: [ - `This guide uses Helm to install the Teleport agent into a cluster, - and by default turns on auto-discovery of all apps in the cluster.`, - ], - prerequisites: [ - 'Egress from your Kubernetes cluster to Teleport.', - 'Helm installed on your local machine.', - 'Kubernetes API access to install the Helm chart.', - ], - }, - }; + let overview: IOverview = content[resourceSpec.id]; return ( <>
Overview
- + {overview.OverviewContent()}
Prerequisites
- - Make sure you have these ready before continuing. - - + Make sure you have these ready before continuing. + {overview.PrerequisiteContent()} ( +
    +
  • + This guide uses Helm to install the Teleport agent into a cluster, and + by default turns on auto-discovery of all apps in the cluster. +
  • +
+ ), + PrerequisiteContent: () => ( +
    +
  • Egress from your Kubernetes cluster to Teleport.
  • +
  • Helm installed on your local machine.
  • +
  • Kubernetes API access to install the Helm chart.
  • +
+ ), + }, +}; diff --git a/web/packages/teleport/src/Discover/Shared/Overview/types.ts b/web/packages/teleport/src/Discover/Shared/Overview/types.ts new file mode 100644 index 0000000000000..320ef43072edc --- /dev/null +++ b/web/packages/teleport/src/Discover/Shared/Overview/types.ts @@ -0,0 +1,11 @@ +import { ReactElement } from 'react'; + +export interface Prerequisite { + content: string; + details?: string[]; +} + +export interface Overview { + OverviewContent: () => ReactElement; + PrerequisiteContent: () => ReactElement; +}