From c3116f0169db7580afd339312298bb7640a3962b Mon Sep 17 00:00:00 2001 From: Lisa Kim Date: Fri, 9 Aug 2024 08:51:48 -0700 Subject: [PATCH] Address CRs --- .../CreateDatabase/CreateDatabaseDialog.tsx | 109 +++++++++--------- .../DeployService/AutoDeploy/AutoDeploy.tsx | 7 +- .../src/services/integrations/types.ts | 1 - 3 files changed, 57 insertions(+), 60 deletions(-) diff --git a/web/packages/teleport/src/Discover/Database/CreateDatabase/CreateDatabaseDialog.tsx b/web/packages/teleport/src/Discover/Database/CreateDatabase/CreateDatabaseDialog.tsx index 40670573b31da..3eea195d8c083 100644 --- a/web/packages/teleport/src/Discover/Database/CreateDatabase/CreateDatabaseDialog.tsx +++ b/web/packages/teleport/src/Discover/Database/CreateDatabase/CreateDatabaseDialog.tsx @@ -32,10 +32,7 @@ import Dialog, { DialogContent } from 'design/DialogConfirmation'; import { Timeout } from 'teleport/Discover/Shared/Timeout'; import { TextIcon } from 'teleport/Discover/Shared'; -import { - dbWithoutDbServerExistsErrorMsg as dbExistsWithoutDbServerErrorMsg, - timeoutErrorMsg, -} from './const'; +import { dbWithoutDbServerExistsErrorMsg, timeoutErrorMsg } from './const'; import type { Attempt } from 'shared/hooks/useAttemptNext'; @@ -60,46 +57,47 @@ export function CreateDatabaseDialog({ onOverwrite, onTimeout, }: CreateDatabaseDialogProps) { - /** - * Most likely cause of timeout is when we found a matching db_service - * but no db_server heartbeats. Most likely cause is because db_service - * has been stopped but is not removed from teleport yet (there is some - * minutes delay on expiry) - */ - const skipOnTimeout = - attempt.status === 'failed' && attempt.statusText === timeoutErrorMsg; - let content: JSX.Element; - if (attempt.status === 'failed' && !skipOnTimeout) { - // Only allow overwriting if the database error - // states that it's a existing database without a db_server. - const canOverwriteDb = attempt.statusText.includes( - dbExistsWithoutDbServerErrorMsg - ); + if (attempt.status === 'failed') { + /** + * Most likely cause of timeout is when we found a matching db_service + * but no db_server heartbeats. Most likely cause is because db_service + * has been stopped but is not removed from teleport yet (there is some + * minutes delay on expiry) + */ + if (attempt.statusText === timeoutErrorMsg) { + content = ; + } else { + // Only allow overwriting if the database error + // states that it's a existing database without a db_server. + const canOverwriteDb = attempt.statusText.includes( + dbWithoutDbServerExistsErrorMsg + ); - // TODO(bl-nero): Migrate this to alert boxes. - content = ( - <> - - - {attempt.statusText} - - - - Retry - - {canOverwriteDb && ( - - Overwrite - - )} - - Close - - - - ); - } else if (attempt.status === 'processing') { + // TODO(bl-nero): Migrate this to alert boxes. + content = ( + <> + + + {attempt.statusText} + + + + Retry + + {canOverwriteDb && ( + + Overwrite + + )} + + Close + + + + ); + } + } else if (attempt.status === 'processing' || attempt.status === '') { content = ( <> @@ -121,19 +119,8 @@ export function CreateDatabaseDialog({ ); - } else { - // success - content = ( - <> - - - Database "{dbName}" successfully registered - - - Next - - - ); + } else if (attempt.status === 'success') { + content = ; } return ( @@ -150,3 +137,15 @@ export function CreateDatabaseDialog({ ); } + +const SuccessContent = ({ dbName, onClick }) => ( + <> + + + Database "{dbName}" successfully registered + + + Next + + +); diff --git a/web/packages/teleport/src/Discover/Database/DeployService/AutoDeploy/AutoDeploy.tsx b/web/packages/teleport/src/Discover/Database/DeployService/AutoDeploy/AutoDeploy.tsx index 5251f9248f808..3006b0233c948 100644 --- a/web/packages/teleport/src/Discover/Database/DeployService/AutoDeploy/AutoDeploy.tsx +++ b/web/packages/teleport/src/Discover/Database/DeployService/AutoDeploy/AutoDeploy.tsx @@ -110,6 +110,9 @@ export function AutoDeploy({ toggleDeployMethod }: DeployServiceProp) { } function handleDeploy(validator) { + setSvcDeployedAwsUrl(''); + setDeployFinished(false); + if (!validator.validate()) { return; } @@ -125,8 +128,6 @@ export function AutoDeploy({ toggleDeployMethod }: DeployServiceProp) { if (wantAutoDiscover) { setAttempt({ status: 'processing' }); - setSvcDeployedAwsUrl(''); - setDeployFinished(false); integrationService .deployDatabaseServices(integrationName, { @@ -153,8 +154,6 @@ export function AutoDeploy({ toggleDeployMethod }: DeployServiceProp) { }); } else { setAttempt({ status: 'processing' }); - setSvcDeployedAwsUrl(''); - setDeployFinished(false); integrationService .deployAwsOidcService(integrationName, { deploymentMode: 'database-service', diff --git a/web/packages/teleport/src/services/integrations/types.ts b/web/packages/teleport/src/services/integrations/types.ts index bbd6e30ba8801..80dd390f5ec9a 100644 --- a/web/packages/teleport/src/services/integrations/types.ts +++ b/web/packages/teleport/src/services/integrations/types.ts @@ -325,7 +325,6 @@ export type AwsOidcDeployServiceRequest = { region: Regions; subnetIds: string[]; taskRoleArn: string; - databaseAgentMatcherLabels?: Label[]; securityGroups?: string[]; vpcId: string; accountId: string;