Skip to content

Commit

Permalink
Remove blocking if db_service exists for a vpc
Browse files Browse the repository at this point in the history
Previously intended to determine if user already auto enrolled,
but now that single and auto enrollment sets the same kind of
labels for db_service, there is no distinction and can let
user be blocked incorrectly.
  • Loading branch information
kimlisa committed Aug 22, 2024
1 parent 3e15456 commit bcbc08b
Showing 1 changed file with 4 additions and 28 deletions.
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, Flex, ButtonSecondary } from 'design';
import { Text, Flex, ButtonSecondary } 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 @@ -261,7 +237,7 @@ export function AutoEnrollment({
)}
<ActionButtons
onProceed={handleOnProceed}
disableProceed={disableBtns || !showTable || hasDatabaseServiceForVpc}
disableProceed={disableBtns || !showTable}
/>
{createDiscoveryConfigAttempt.status !== '' && (
<CreatedDiscoveryConfigDialog
Expand Down

0 comments on commit bcbc08b

Please sign in to comment.