Skip to content

Commit

Permalink
Web: Add github integration tile and github related types and endpoin…
Browse files Browse the repository at this point in the history
…ts (#51539) (#51958)

* Add new types, endpoints and fix Integration types

* Refactor how integration and plugins are being sorted as tiles

* Fix typo

* Fix open source integration typing and create conditional typing

* Address CRs
  • Loading branch information
kimlisa authored Feb 20, 2025
1 parent 6b6fd4c commit 8278065
Show file tree
Hide file tree
Showing 26 changed files with 609 additions and 255 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { FeaturesContextProvider } from 'teleport/FeaturesContext';
import { createTeleportContext } from 'teleport/mocks/contexts';
import {
AwsRdsDatabase,
Integration,
IntegrationAwsOidc,
IntegrationKind,
integrationService,
IntegrationStatusCode,
Expand Down Expand Up @@ -69,7 +69,7 @@ const mockAwsRdsDb: AwsRdsDatabase = {
subnets: ['subnet1', 'subnet2'],
};

const mocKIntegration: Integration = {
const mockIntegration: IntegrationAwsOidc = {
kind: IntegrationKind.AwsOidc,
name: integrationName,
resourceType: 'integration',
Expand Down Expand Up @@ -214,7 +214,7 @@ function getMockedContexts() {
agentMeta: {
resourceName: 'db1',
awsRegion: region,
awsIntegration: mocKIntegration,
awsIntegration: mockIntegration,
selectedAwsRdsDb: mockAwsRdsDb,
agentMatcherLabels: mockDbLabels,
} as DbMeta,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import {
} from 'teleport/Discover/yamlTemplates';
import { App } from 'teleport/services/apps';
import {
Integration,
IntegrationAwsOidc,
IntegrationKind,
integrationService,
} from 'teleport/services/integrations';
Expand All @@ -59,7 +59,7 @@ import {
} from '../../Shared';
import { DiscoverUrlLocationState, useDiscover } from '../../useDiscover';

type Option = BaseOption<Integration>;
type Option = BaseOption<IntegrationAwsOidc>;

export function AwsAccount() {
const {
Expand Down Expand Up @@ -328,7 +328,7 @@ export function AwsAccount() {
);
}

function makeAwsIntegrationOption(integration: Integration): Option {
function makeAwsIntegrationOption(integration: IntegrationAwsOidc): Option {
return {
value: integration,
label: integration.name,
Expand All @@ -339,7 +339,7 @@ async function fetchAwsIntegrationsWithApps(
clusterId: string,
isAddingAwsApp: boolean
): Promise<{
awsIntegrations: Integration[];
awsIntegrations: IntegrationAwsOidc[];
apps: App[];
}> {
const integrationPage = await integrationService.fetchIntegrations();
Expand Down
6 changes: 3 additions & 3 deletions web/packages/teleport/src/Discover/useDiscover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { DiscoveryConfig } from 'teleport/services/discovery';
import type {
AwsRdsDatabase,
Ec2InstanceConnectEndpoint,
Integration,
IntegrationAwsOidc,
Regions,
} from 'teleport/services/integrations';
import type { Kube } from 'teleport/services/kube';
Expand Down Expand Up @@ -123,7 +123,7 @@ export type DiscoverUrlLocationState = {
currentStep: number;
};
// integration is the created aws-oidc integration
integration: Integration;
integration: IntegrationAwsOidc;
};

const discoverContext = React.createContext<DiscoverContextState>(null);
Expand Down Expand Up @@ -512,7 +512,7 @@ type BaseMeta = {
* awsIntegration is set to the selected AWS integration.
* This field is set when a user wants to enroll AWS resources.
*/
awsIntegration?: Integration;
awsIntegration?: IntegrationAwsOidc;
/**
* awsRegion is set to the selected AWS region.
* This field is set when a user wants to enroll AWS resources.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { fireEvent, render, screen, waitFor } from 'design/utils/testing';

import cfg from 'teleport/config';
import {
Integration,
IntegrationAwsOidc,
IntegrationKind,
integrationService,
IntegrationStatusCode,
Expand Down Expand Up @@ -251,12 +251,13 @@ test('edit submit called with proper fields', async () => {
await userEvent.click(screen.getByRole('button', { name: /save/i }));
await waitFor(() => expect(mockEditFn).toHaveBeenCalledTimes(1));

expect(mockEditFn).toHaveBeenCalledWith(integration, {
expect(mockEditFn).toHaveBeenCalledWith({
kind: IntegrationKind.AwsOidc,
roleArn: 'arn:aws:iam::123456789011:role/other',
});
});

const integration: Integration = {
const integration: IntegrationAwsOidc = {
resourceType: 'integration',
kind: IntegrationKind.AwsOidc,
name: 'some-integration-name',
Expand All @@ -277,7 +278,7 @@ function ComponentWithEditOperation() {
return (
<EditAwsOidcIntegrationDialog
close={() => null}
edit={(integration, req) => integrationOps.edit(integration, req).then()}
edit={req => integrationOps.edit(req).then()}
integration={integration}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ import { useAsync } from 'shared/hooks/useAsync';
import cfg from 'teleport/config';
import {
AwsOidcPolicyPreset,
Integration,
IntegrationAwsOidc,
IntegrationKind,
} from 'teleport/services/integrations';
import { splitAwsIamArn } from 'teleport/services/integrations/aws';

Expand All @@ -54,14 +55,14 @@ import { EditableIntegrationFields } from './Operations/useIntegrationOperation'

type Props = {
close(): void;
edit(integration: Integration, req: EditableIntegrationFields): Promise<void>;
integration: Integration;
edit(req: EditableIntegrationFields): Promise<void>;
integration: IntegrationAwsOidc;
};

export function EditAwsOidcIntegrationDialog(props: Props) {
const { close, edit, integration } = props;
const [updateAttempt, runUpdate] = useAsync(async () => {
await edit(integration, { roleArn });
await edit({ kind: IntegrationKind.AwsOidc, roleArn });
});

const [roleArn, setRoleArn] = useState(integration.spec.roleArn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ import { CircleCheck } from 'design/Icon';

import cfg from 'teleport/config';
import { DiscoverUrlLocationState } from 'teleport/Discover/useDiscover';
import { Integration } from 'teleport/services/integrations';
import { IntegrationAwsOidc } from 'teleport/services/integrations';

export function FinishDialog({ integration }: { integration: Integration }) {
export function FinishDialog({
integration,
}: {
integration: IntegrationAwsOidc;
}) {
const location = useLocation<DiscoverUrlLocationState>();
return (
<Dialog
Expand Down Expand Up @@ -62,7 +66,7 @@ function FooterButton({
integration,
}: {
location: Location<any>;
integration: Integration;
integration: IntegrationAwsOidc;
}): React.ReactElement {
if (location.state?.discover) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { DiscoverUrlLocationState } from 'teleport/Discover/useDiscover';
import { ApiError } from 'teleport/services/api/parseError';
import {
AwsOidcPolicyPreset,
Integration,
IntegrationAwsOidc,
IntegrationCreateRequest,
IntegrationKind,
integrationService,
Expand Down Expand Up @@ -59,7 +59,8 @@ export function useAwsOidcIntegration() {
}
);
const [scriptUrl, setScriptUrl] = useState('');
const [createdIntegration, setCreatedIntegration] = useState<Integration>();
const [createdIntegration, setCreatedIntegration] =
useState<IntegrationAwsOidc>();
const { clusterId } = useStickyClusterId();

const location = useLocation<DiscoverUrlLocationState>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import cfg from 'teleport/config';

import { NoCodeIntegrationDescription } from './common';
import { getRoutesToEnrollIntegrations } from './IntegrationRoute';
import { IntegrationTiles } from './IntegrationTiles';
import { IntegrationTiles } from './IntegrationTiles/IntegrationTiles';
import { MachineIDIntegrationSection } from './MachineIDIntegrationSection';

export function IntegrationEnroll() {
Expand Down
128 changes: 0 additions & 128 deletions web/packages/teleport/src/Integrations/Enroll/IntegrationTiles.tsx

This file was deleted.

Loading

0 comments on commit 8278065

Please sign in to comment.