From b64a39d6979b16d36643d255922f5fb6289337b7 Mon Sep 17 00:00:00 2001 From: corya-akamai <136115382+corya-akamai@users.noreply.github.com> Date: Tue, 22 Oct 2024 13:59:00 -0400 Subject: [PATCH] feat: [UIE-8196] - DBaaS create encourage users to add IP allow_list (#11124) --- ...r-11124-upcoming-features-1729198459249.md | 5 + .../MultipleIPInput/MultipleIPInput.test.tsx | 40 ++++- .../MultipleIPInput/MultipleIPInput.tsx | 5 + .../DatabaseCreate/DatabaseCreate.tsx | 49 +----- .../DatabaseCreateAccessControls.test.tsx | 107 +++++++++++++ .../DatabaseCreateAccessControls.tsx | 144 ++++++++++++++++++ 6 files changed, 308 insertions(+), 42 deletions(-) create mode 100644 packages/manager/.changeset/pr-11124-upcoming-features-1729198459249.md create mode 100644 packages/manager/src/features/Databases/DatabaseCreate/DatabaseCreateAccessControls.test.tsx create mode 100644 packages/manager/src/features/Databases/DatabaseCreate/DatabaseCreateAccessControls.tsx diff --git a/packages/manager/.changeset/pr-11124-upcoming-features-1729198459249.md b/packages/manager/.changeset/pr-11124-upcoming-features-1729198459249.md new file mode 100644 index 00000000000..1435345c4bb --- /dev/null +++ b/packages/manager/.changeset/pr-11124-upcoming-features-1729198459249.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Upcoming Features +--- + +DBaaS encourage setting access controls during create ([#11124](https://github.com/linode/manager/pull/11124)) diff --git a/packages/manager/src/components/MultipleIPInput/MultipleIPInput.test.tsx b/packages/manager/src/components/MultipleIPInput/MultipleIPInput.test.tsx index 16c22a2f991..06c123078b4 100644 --- a/packages/manager/src/components/MultipleIPInput/MultipleIPInput.test.tsx +++ b/packages/manager/src/components/MultipleIPInput/MultipleIPInput.test.tsx @@ -2,7 +2,6 @@ import { fireEvent } from '@testing-library/react'; import * as React from 'react'; import { renderWithTheme } from 'src/utilities/testHelpers'; - import { MultipleIPInput } from './MultipleIPInput'; const baseProps = { @@ -52,4 +51,43 @@ describe('MultipleIPInput', () => { { address: 'ip3' }, ]); }); + + it('should enable all actions by default', async () => { + const props = { + ...baseProps, + ips: [{ address: 'ip1' }, { address: 'ip2' }], + }; + const { getByTestId, getByLabelText, getByText } = renderWithTheme( + + ); + const ip0 = getByLabelText('domain-transfer-ip-0'); + const ip1 = getByLabelText('domain-transfer-ip-1'); + const closeButton = getByTestId('delete-ip-1').closest('button'); + const addButton = getByText('Add an IP').closest('button'); + + expect(ip0).toBeEnabled(); + expect(ip1).toBeEnabled(); + expect(closeButton).toBeEnabled(); + expect(addButton).toBeEnabled(); + }); + + it('should disable all actions', async () => { + const props = { + ...baseProps, + disabled: true, + ips: [{ address: 'ip1' }, { address: 'ip2' }], + }; + const { getByTestId, getByLabelText, getByText } = renderWithTheme( + + ); + const ip0 = getByLabelText('domain-transfer-ip-0'); + const ip1 = getByLabelText('domain-transfer-ip-1'); + const closeButton = getByTestId('delete-ip-1').closest('button'); + const addButton = getByText('Add an IP').closest('button'); + + expect(ip0).toBeDisabled(); + expect(ip1).toBeDisabled(); + expect(closeButton).toBeDisabled(); + expect(addButton).toBeDisabled(); + }); }); diff --git a/packages/manager/src/components/MultipleIPInput/MultipleIPInput.tsx b/packages/manager/src/components/MultipleIPInput/MultipleIPInput.tsx index 6d241a3b2df..1d60931b8a1 100644 --- a/packages/manager/src/components/MultipleIPInput/MultipleIPInput.tsx +++ b/packages/manager/src/components/MultipleIPInput/MultipleIPInput.tsx @@ -60,6 +60,7 @@ const useStyles = makeStyles()((theme: Theme) => ({ interface Props { buttonText?: string; className?: string; + disabled?: boolean; error?: string; forDatabaseAccessControls?: boolean; forVPCIPv4Ranges?: boolean; @@ -78,6 +79,7 @@ export const MultipleIPInput = React.memo((props: Props) => { const { buttonText, className, + disabled, error, forDatabaseAccessControls, forVPCIPv4Ranges, @@ -137,6 +139,7 @@ export const MultipleIPInput = React.memo((props: Props) => { buttonType="secondary" className={classes.addIP} compactX + disabled={disabled} onClick={addNewInput} > {buttonText ?? 'Add an IP'} @@ -184,6 +187,7 @@ export const MultipleIPInput = React.memo((props: Props) => { ) => @@ -206,6 +210,7 @@ export const MultipleIPInput = React.memo((props: Props) => { {(idx > 0 || forDatabaseAccessControls || forVPCIPv4Ranges) && (