diff --git a/libs/domains/clusters/feature/src/lib/cluster-add/cluster-add.spec.tsx b/libs/domains/clusters/feature/src/lib/cluster-add/cluster-add.spec.tsx index 190b3c5b685..da5b2a454e6 100644 --- a/libs/domains/clusters/feature/src/lib/cluster-add/cluster-add.spec.tsx +++ b/libs/domains/clusters/feature/src/lib/cluster-add/cluster-add.spec.tsx @@ -19,6 +19,11 @@ jest.mock('posthog-js', () => ({ default: { capture: jest.fn() }, })) jest.mock('posthog-js/react', () => ({ useFeatureFlagEnabled: () => false })) +const mockShowPylonForm = jest.fn() +jest.mock('@qovery/shared/util-hooks', () => ({ + ...jest.requireActual('@qovery/shared/util-hooks'), + useSupportChat: () => ({ showPylonForm: mockShowPylonForm }), +})) jest.mock('../hooks/use-cluster-creation-restriction/use-cluster-creation-restriction', () => ({ useClusterCreationRestriction: () => ({ isClusterCreationRestricted: false }), })) @@ -43,6 +48,14 @@ describe('ClusterAdd', () => { expect(await screen.findByText('Creation flow')).toBeInTheDocument() } + it('asks for EKS Anywhere access when it is not enabled', async () => { + const { userEvent } = renderWithProviders() + + await userEvent.click(screen.getByRole('button', { name: /Amazon Web Services EKS Anywhere\s*Request access/ })) + + expect(mockShowPylonForm).toHaveBeenCalledWith('request-access-eks-anywhere') + }) + it('lets the creation flow be dismissed before the cluster is created', async () => { const { userEvent } = renderWithProviders() diff --git a/libs/domains/clusters/feature/src/lib/cluster-add/cluster-add.tsx b/libs/domains/clusters/feature/src/lib/cluster-add/cluster-add.tsx index ac2c7a983cd..d043f577350 100644 --- a/libs/domains/clusters/feature/src/lib/cluster-add/cluster-add.tsx +++ b/libs/domains/clusters/feature/src/lib/cluster-add/cluster-add.tsx @@ -21,6 +21,7 @@ type ProviderCardProps = { title: string icon: string | ReactElement disabled?: boolean + actionLabel?: string analytics: { selectedCloudProvider: string; selectedInstallationType: string } } & ({ slug: string } | { onClick: () => void }) @@ -32,7 +33,7 @@ function ProviderIcon({ icon, title }: { icon: string | ReactElement; title: str ) } -function ProviderCard({ title, icon, disabled = false, analytics, ...props }: ProviderCardProps) { +function ProviderCard({ title, icon, disabled = false, actionLabel, analytics, ...props }: ProviderCardProps) { const { organizationId = '' } = useParams({ strict: false }) const className = twMerge( 'flex h-[52px] items-center gap-2 rounded-md border border-neutral bg-surface-neutral px-4 text-left text-sm font-medium text-neutral transition-colors', @@ -42,7 +43,11 @@ function ProviderCard({ title, icon, disabled = false, analytics, ...props }: Pr <> {title} - + {actionLabel ? ( + {actionLabel} + ) : ( + + )} ) const capture = () => posthog.capture('select-cluster', analytics) @@ -165,6 +170,7 @@ export function ClusterAdd() { } + actionLabel="Request access" onClick={() => showPylonForm('request-access-eks-anywhere')} analytics={{ selectedCloudProvider: 'AWS', selectedInstallationType: 'partially-managed' }} /> diff --git a/libs/domains/clusters/feature/src/lib/cluster-profile/cluster-profile-sidebar.tsx b/libs/domains/clusters/feature/src/lib/cluster-profile/cluster-profile-sidebar.tsx index 5ac6b0d25fd..72f10878696 100644 --- a/libs/domains/clusters/feature/src/lib/cluster-profile/cluster-profile-sidebar.tsx +++ b/libs/domains/clusters/feature/src/lib/cluster-profile/cluster-profile-sidebar.tsx @@ -164,7 +164,7 @@ export function ClusterProfileSidebar({ const showEmptyState = !isLoading && !isError && layers.length === 0 return ( -