diff --git a/web/packages/teleport/src/Bots/Add/AddBotsPicker.story.tsx b/web/packages/teleport/src/Bots/Add/AddBotsPicker.story.tsx index e33d02220d4ca..7551ba4035b9a 100644 --- a/web/packages/teleport/src/Bots/Add/AddBotsPicker.story.tsx +++ b/web/packages/teleport/src/Bots/Add/AddBotsPicker.story.tsx @@ -19,6 +19,10 @@ import React from 'react'; import { MemoryRouter } from 'react-router'; +import { ContextProvider } from 'teleport'; + +import { createTeleportContext } from 'teleport/mocks/contexts'; + import { AddBotsPicker } from './AddBotsPicker'; export default { @@ -26,9 +30,13 @@ export default { }; export const Picker = () => { + const ctx = createTeleportContext(); + return ( - + + + ); }; diff --git a/web/packages/teleport/src/Bots/Add/AddBotsPicker.tsx b/web/packages/teleport/src/Bots/Add/AddBotsPicker.tsx index c4c96de9e11ea..75a359ee5a7f1 100644 --- a/web/packages/teleport/src/Bots/Add/AddBotsPicker.tsx +++ b/web/packages/teleport/src/Bots/Add/AddBotsPicker.tsx @@ -45,6 +45,9 @@ import { import { IntegrationTile } from 'teleport/Integrations'; import { FeatureHeader, FeatureHeaderTitle } from 'teleport/components/Layout'; +import useTeleport from 'teleport/useTeleport'; +import { ToolTipNoPermBadge } from 'teleport/components/ToolTipNoPermBadge'; + import { BotFlowType } from '../types'; type BotIntegration = { @@ -136,29 +139,37 @@ const integrations: BotIntegration[] = [ ]; export function AddBotsPicker() { + const ctx = useTeleport(); return ( <> Select Bot Type - + Set up Teleport Machine ID to allow CI/CD workflows and other machines to access resources protected by Teleport. - + ); } -export function BotTiles() { +export function BotTiles({ + hasCreateBotPermission, +}: { + hasCreateBotPermission: boolean; +}) { return ( - + {integrations.map(i => ( {i.guided ? ( - + ) : ( )} @@ -189,12 +200,21 @@ function ExternalLinkTile({ integration }: { integration: BotIntegration }) { ); } -function GuidedTile({ integration }: { integration: BotIntegration }) { +function GuidedTile({ + integration, + hasCreateBotPermission, +}: { + integration: BotIntegration; + hasCreateBotPermission: boolean; +}) { return ( { + if (!hasCreateBotPermission) { + return; + } userEventService.captureIntegrationEnrollEvent({ event: IntegrationEnrollEvent.Started, eventData: { @@ -204,7 +224,16 @@ function GuidedTile({ integration }: { integration: BotIntegration }) { }); }} > - Guided + {hasCreateBotPermission ? ( + Guided + ) : ( + +
+ You don’t have sufficient permissions to create bots. Reach out to + your Teleport administrator to request additional permissions. +
+
+ )}
); diff --git a/web/packages/teleport/src/Integrations/Enroll/IntegrationEnroll.story.tsx b/web/packages/teleport/src/Integrations/Enroll/IntegrationEnroll.story.tsx index 95c3ddb29fd9a..5964e459ff8e4 100644 --- a/web/packages/teleport/src/Integrations/Enroll/IntegrationEnroll.story.tsx +++ b/web/packages/teleport/src/Integrations/Enroll/IntegrationEnroll.story.tsx @@ -19,6 +19,10 @@ import React from 'react'; import { MemoryRouter } from 'react-router'; +import { ContextProvider } from 'teleport'; + +import { createTeleportContext } from 'teleport/mocks/contexts'; + import cfg from 'teleport/config'; import { IntegrationEnroll } from './IntegrationEnroll'; @@ -27,8 +31,14 @@ export default { title: 'Teleport/Integrations/Enroll', }; -export const Picker = () => ( - - - -); +export const Picker = () => { + const ctx = createTeleportContext(); + + return ( + + + + + + ); +}; diff --git a/web/packages/teleport/src/Integrations/Enroll/MachineIDIntegrationSection.tsx b/web/packages/teleport/src/Integrations/Enroll/MachineIDIntegrationSection.tsx index b6868c50168b6..27c63319eecd5 100644 --- a/web/packages/teleport/src/Integrations/Enroll/MachineIDIntegrationSection.tsx +++ b/web/packages/teleport/src/Integrations/Enroll/MachineIDIntegrationSection.tsx @@ -16,107 +16,15 @@ * along with this program. If not, see . */ -import { - AnsibleIcon, - AWSIcon, - AzureIcon, - CircleCIIcon, - GCPIcon, - GitHubIcon, - GitLabIcon, - JenkinsIcon, - KubernetesIcon, - ServersIcon, - SpaceliftIcon, -} from 'design/SVGIcon'; -import { Box, Flex, Link as ExternalLink, Text } from 'design'; import React from 'react'; -import { - IntegrationEnrollEvent, - IntegrationEnrollKind, - userEventService, -} from 'teleport/services/userEvent'; +import { Box, Text } from 'design'; -import { IntegrationTile } from './common'; - -interface Integration { - title: string; - link: string; - icon: JSX.Element; - kind: IntegrationEnrollKind; -} - -const integrations: Integration[] = [ - { - title: 'GitHub Actions', - link: 'https://goteleport.com/docs/machine-id/deployment/github-actions/', - icon: , - kind: IntegrationEnrollKind.MachineIDGitHubActions, - }, - { - title: 'CircleCI', - link: 'https://goteleport.com/docs/machine-id/deployment/circleci/', - icon: , - kind: IntegrationEnrollKind.MachineIDCircleCI, - }, - { - title: 'GitLab CI/CD', - link: 'https://goteleport.com/docs/machine-id/deployment/gitlab/', - icon: , - kind: IntegrationEnrollKind.MachineIDGitLab, - }, - { - title: 'Jenkins', - link: 'https://goteleport.com/docs/machine-id/deployment/jenkins/', - icon: , - kind: IntegrationEnrollKind.MachineIDJenkins, - }, - { - title: 'Ansible', - link: 'https://goteleport.com/docs/machine-id/access-guides/ansible/', - icon: , - kind: IntegrationEnrollKind.MachineIDAnsible, - }, - { - title: 'Spacelift', - link: 'https://goteleport.com/docs/machine-id/deployment/spacelift/', - icon: , - kind: IntegrationEnrollKind.MachineIDSpacelift, - }, - { - title: 'AWS', - link: 'https://goteleport.com/docs/machine-id/deployment/aws/', - icon: , - kind: IntegrationEnrollKind.MachineIDAWS, - }, - { - title: 'GCP', - link: 'https://goteleport.com/docs/machine-id/deployment/gcp/', - icon: , - kind: IntegrationEnrollKind.MachineIDGCP, - }, - { - title: 'Azure', - link: 'https://goteleport.com/docs/machine-id/deployment/azure/', - icon: , - kind: IntegrationEnrollKind.MachineIDAzure, - }, - { - title: 'Kubernetes', - link: 'https://goteleport.com/docs/machine-id/deployment/kubernetes/', - icon: , - kind: IntegrationEnrollKind.MachineIDKubernetes, - }, - { - title: 'Generic', - link: 'https://goteleport.com/docs/machine-id/getting-started/', - icon: , - kind: IntegrationEnrollKind.MachineID, - }, -]; +import { BotTiles } from 'teleport/Bots/Add/AddBotsPicker'; +import useTeleport from 'teleport/useTeleport'; export const MachineIDIntegrationSection = () => { + const ctx = useTeleport(); return ( <> @@ -128,33 +36,7 @@ export const MachineIDIntegrationSection = () => { to access resources protected by Teleport.
- {/* TODO(mcbattirola): replace this section with BotTiles and remove Integrations */} - - {integrations.map(i => { - return ( - { - userEventService.captureIntegrationEnrollEvent({ - event: IntegrationEnrollEvent.Started, - eventData: { - id: crypto.randomUUID(), - kind: i.kind, - }, - }); - }} - > - - {i.icon} - - {i.title} - - ); - })} - + ); };