Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebDiscover: Fix blocking when db_service exists for a vpc during auto enrollment #45716

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
*/

import React, { useState, useEffect } from 'react';
import { Box, Text, Link as ExternalLink } from 'design';
import { Text } from 'design';
import { FetchStatus } from 'design/DataTable/types';
import useAttempt, { Attempt } from 'shared/hooks/useAttemptNext';
import { getErrMessage } from 'shared/utils/errorType';
import { Alert, OutlineInfo } from 'design/Alert/Alert';
import { Alert } from 'design/Alert/Alert';

import { DbMeta, useDiscover } from 'teleport/Discover/useDiscover';
import {
Expand Down Expand Up @@ -79,8 +79,6 @@ export function AutoEnrollment({
*/
key: string;
}) {
const hasDatabaseServiceForVpc = !!vpc?.ecsServiceDashboardURL;

const ctx = useTeleport();
const clusterId = ctx.storeUser.getClusterId();

Expand All @@ -94,13 +92,6 @@ export function AutoEnrollment({
const [tableData, setTableData] = useState<TableData>();

useEffect(() => {
if (hasDatabaseServiceForVpc) {
// No need to fetch rds's since in place of rds table
// we will render a info banner that a db service
// already exists.
return;
}

if (vpc) {
// Start with empty table data for new vpc's.
fetchRdsDatabases(emptyTableData(), vpc);
Expand Down Expand Up @@ -217,25 +208,10 @@ export function AutoEnrollment({
}

const selectedVpc = !!vpc;
const showTable =
selectedVpc &&
!hasDatabaseServiceForVpc &&
fetchAttempt.status !== 'failed';
const showTable = selectedVpc && fetchAttempt.status !== 'failed';

return (
<>
{hasDatabaseServiceForVpc && (
<OutlineInfo mt={3} width="480px" linkColor="buttons.link.default">
<Box>
There is a database service already deployed for the selected VPC,
visit its{' '}
<ExternalLink target="_blank" href={vpc.ecsServiceDashboardURL}>
dashboard
</ExternalLink>{' '}
to check it out.
</Box>
</OutlineInfo>
)}
{showTable && (
<>
{tableData?.oneOfError && (
Expand All @@ -259,7 +235,7 @@ export function AutoEnrollment({
)}
<ActionButtons
onProceed={handleOnProceed}
disableProceed={disableBtns || !showTable || hasDatabaseServiceForVpc}
disableProceed={disableBtns || !showTable}
/>
{createDiscoveryConfigAttempt.status !== '' && (
<CreatedDiscoveryConfigDialog
Expand Down
Loading