Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat(studio): polish PrivateLink connection UI (#49164)

Danny White4760c1af77ee
diff --git a/apps/studio/components/interfaces/Settings/Integrations/AWSPrivateLink/AWSPrivateLink.utils.test.ts b/apps/studio/components/interfaces/Settings/Integrations/AWSPrivateLink/AWSPrivateLink.utils.test.ts
index 5e184b8399e..753f200f5f5 100644
--- a/apps/studio/components/interfaces/Settings/Integrations/AWSPrivateLink/AWSPrivateLink.utils.test.ts
+++ b/apps/studio/components/interfaces/Settings/Integrations/AWSPrivateLink/AWSPrivateLink.utils.test.ts
@@ -60,14 +60,16 @@ describe('getConnectionsAttentionCopy', () => {
const copy = getConnectionsAttentionCopy({ waitingCount: 1, expiredCount: 0 })
expect(copy?.type).toBe('warning')
expect(copy?.title).toBe('Waiting for the AWS account owner')
- expect(copy?.showAcceptLink).toBe(true)
+ expect(copy?.description).toBe('Accept the resource share in AWS within 12 hours.')
+ expect(copy?.shouldShowAcceptLink).toBe(true)
})
it('uses destructive copy when only expired', () => {
const copy = getConnectionsAttentionCopy({ waitingCount: 0, expiredCount: 2 })
expect(copy?.type).toBe('destructive')
expect(copy?.title).toBe('Connection requests expired')
- expect(copy?.showAcceptLink).toBe(false)
+ expect(copy?.description).toBe('AWS can no longer accept these shares.')
+ expect(copy?.shouldShowAcceptLink).toBe(false)
})
it('counts statuses from a list', () => {
diff --git a/apps/studio/components/interfaces/Settings/Integrations/AWSPrivateLink/AWSPrivateLink.utils.ts b/apps/studio/components/interfaces/Settings/Integrations/AWSPrivateLink/AWSPrivateLink.utils.ts
index 8820e95f287..74fe7930ab9 100644
--- a/apps/studio/components/interfaces/Settings/Integrations/AWSPrivateLink/AWSPrivateLink.utils.ts
+++ b/apps/studio/components/interfaces/Settings/Integrations/AWSPrivateLink/AWSPrivateLink.utils.ts
@@ -73,7 +73,7 @@ export function getConnectionsAttentionCopy(attention: ConnectionsAttention): {
type: 'warning' | 'destructive'
title: string
description: string
- showAcceptLink: boolean
+ shouldShowAcceptLink: boolean
} | null {
const { waitingCount, expiredCount } = attention
if (waitingCount === 0 && expiredCount === 0) return null
@@ -82,8 +82,8 @@ export function getConnectionsAttentionCopy(attention: ConnectionsAttention): {
return {
type: 'destructive',
title: expiredCount === 1 ? 'A connection request expired' : 'Connection requests expired',
- description: 'Add a new connection to try again. AWS can no longer accept this share.',
- showAcceptLink: false,
+ description: `AWS can no longer accept ${expiredCount === 1 ? 'this share' : 'these shares'}.`,
+ shouldShowAcceptLink: false,
}
}
@@ -91,9 +91,8 @@ export function getConnectionsAttentionCopy(attention: ConnectionsAttention): {
return {
type: 'warning',
title: 'Some connections need attention',
- description:
- 'Accept waiting resource shares in AWS within 12 hours. Expired requests need a new connection.',
- showAcceptLink: true,
+ description: `Accept the waiting resource share${waitingCount === 1 ? '' : 's'} in AWS within 12 hours.`,
+ shouldShowAcceptLink: true,
}
}
@@ -101,7 +100,7 @@ export function getConnectionsAttentionCopy(attention: ConnectionsAttention): {
type: 'warning',
title:
waitingCount === 1 ? 'Waiting for the AWS account owner' : 'Waiting for AWS account owners',
- description: 'Accept the resource share in AWS within 12 hours.',
- showAcceptLink: true,
+ description: `Accept the resource share${waitingCount === 1 ? '' : 's'} in AWS within 12 hours.`,
+ shouldShowAcceptLink: true,
}
}
diff --git a/apps/studio/components/interfaces/Settings/Integrations/AWSPrivateLink/AWSPrivateLinkAttentionAdmonition.tsx b/apps/studio/components/interfaces/Settings/Integrations/AWSPrivateLink/AWSPrivateLinkAttentionAdmonition.tsx
index 70e00e5c023..f2d4258d9fc 100644
--- a/apps/studio/components/interfaces/Settings/Integrations/AWSPrivateLink/AWSPrivateLinkAttentionAdmonition.tsx
+++ b/apps/studio/components/interfaces/Settings/Integrations/AWSPrivateLink/AWSPrivateLinkAttentionAdmonition.tsx
@@ -25,7 +25,7 @@ export function AWSPrivateLinkAttentionAdmonition({
description={copy.description}
className={className}
actions={
- copy.showAcceptLink && (
+ copy.shouldShowAcceptLink && (
<Button variant="default" className="w-min" icon={<SquareArrowOutUpRight />} asChild>
<Link
target="_blank"
diff --git a/apps/studio/components/interfaces/Settings/Integrations/AWSPrivateLink/AWSPrivateLinkForm.tsx b/apps/studio/components/interfaces/Settings/Integrations/AWSPrivateLink/AWSPrivateLinkForm.tsx
index 97f1b0a2828..e08aed73315 100644
--- a/apps/studio/components/interfaces/Settings/Integrations/AWSPrivateLink/AWSPrivateLinkForm.tsx
+++ b/apps/studio/components/interfaces/Settings/Integrations/AWSPrivateLink/AWSPrivateLinkForm.tsx
@@ -206,11 +206,16 @@ export const AWSPrivateLinkForm = ({
control={form.control}
name="accountName"
render={({ field }) => (
- <FormItemLayout label="Description" labelOptional="Optional">
+ <FormItemLayout
+ label="Name"
+ labelOptional="Optional"
+ description="Shown on the connections list. Defaults to the AWS account ID if left blank."
+ >
<FormControl>
<Input
{...field}
readOnly={!isNew}
+ placeholder="Production VPC"
onFocus={(e) => {
if (!isNew) e.target.blur()
}}
diff --git a/apps/studio/components/interfaces/Settings/Integrations/AWSPrivateLink/AWSPrivateLinkSection.tsx b/apps/studio/components/interfaces/Settings/Integrations/AWSPrivateLink/AWSPrivateLinkSection.tsx
index 3688e994d54..0b70fb07b5a 100644
--- a/apps/studio/components/interfaces/Settings/Integrations/AWSPrivateLink/AWSPrivateLinkSection.tsx
+++ b/apps/studio/components/interfaces/Settings/Integrations/AWSPrivateLink/AWSPrivateLinkSection.tsx
@@ -25,6 +25,7 @@ import {
} from 'ui-patterns/PageSection'
import { IntegrationSectionIcon } from '../IntegrationsSettings'
+import { getConnectionTitle } from './AWSPrivateLink.utils'
import { AWSPrivateLinkAccountItem } from './AWSPrivateLinkAccountItem'
import { AWSPrivateLinkAttentionAdmonition } from './AWSPrivateLinkAttentionAdmonition'
import { AWSPrivateLinkForm } from './AWSPrivateLinkForm'
@@ -46,7 +47,7 @@ export const AWSPrivateLinkSection = () => {
const [showForm, setShowForm] = useState(false)
const [showDeleteModal, setShowDeleteModal] = useState(false)
- const { mutate: deleteAccount, isPending: isDeleting } = useAWSAccountDeleteMutation({
+ const { mutateAsync: deleteAccount, isPending: isDeleting } = useAWSAccountDeleteMutation({
onSuccess: () => {
toast.success('Connection will be deleted shortly')
setShowDeleteModal(false)
@@ -68,25 +69,34 @@ export const AWSPrivateLinkSection = () => {
setShowForm(true)
}
- const onConfirmDelete = () => {
- if (selectedAccount && project) {
- deleteAccount({
- projectRef: project.ref,
- awsAccountId: selectedAccount.aws_account_id,
- databaseIdentifier:
- selectedAccount.database_type === 'READ_REPLICA'
- ? selectedAccount.database_identifier
- : undefined,
- })
- }
+ const onConfirmDelete = async () => {
+ if (!selectedAccount || !project) return
+
+ await deleteAccount({
+ projectRef: project.ref,
+ awsAccountId: selectedAccount.aws_account_id,
+ databaseIdentifier:
+ selectedAccount.database_type === 'READ_REPLICA'
+ ? selectedAccount.database_identifier
+ : undefined,
+ })
+ }
+
+ let deleteDatabaseCopy = 'the primary database'
+ if (selectedAccount?.database_type === 'READ_REPLICA') {
+ deleteDatabaseCopy = selectedAccount.database_identifier
+ ? `the read replica (ID: ${formatDatabaseID(selectedAccount.database_identifier)})`
+ : 'the read replica (ID: Unknown identifier)'
}
- const deleteDatabaseCopy =
- selectedAccount?.database_type === 'READ_REPLICA'
- ? selectedAccount.database_identifier
- ? `the read replica (ID: ${formatDatabaseID(selectedAccount.database_identifier)})`
- : 'a read replica'
- : 'the primary database'
+ const deleteConnectionTitle = selectedAccount
+ ? getConnectionTitle({
+ account_name: selectedAccount.account_name,
+ aws_account_id: selectedAccount.aws_account_id,
+ })
+ : ''
+ const showDeleteConnectionId =
+ !!selectedAccount && deleteConnectionTitle === selectedAccount.aws_account_id
return (
<>
@@ -161,8 +171,12 @@ export const AWSPrivateLinkSection = () => {
<AlertDialogTitle>Delete connection</AlertDialogTitle>
<AlertDialogDescription>
This removes the PrivateLink connection for{' '}
- <code className="text-code-inline">{selectedAccount?.aws_account_id}</code> on{' '}
- {deleteDatabaseCopy}. Applications using this private path will lose access.
+ {showDeleteConnectionId ? (
+ <code className="text-code-inline">{deleteConnectionTitle}</code>
+ ) : (
+ deleteConnectionTitle
+ )}{' '}
+ on {deleteDatabaseCopy}. Applications using this private path will lose access.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>