UIE-9379: Implementing Add Pool functionality for PgBouncer#13276
Conversation
3595b01 to
eceb323
Compare
...src/features/Databases/DatabaseDetail/DatabaseNetworking/DatabaseConnectionPoolAddDrawer.tsx
Outdated
Show resolved
Hide resolved
...src/features/Databases/DatabaseDetail/DatabaseNetworking/DatabaseConnectionPoolAddDrawer.tsx
Outdated
Show resolved
Hide resolved
| border: `1px solid ${theme.tokens.component.Select.Error.Border}`, | ||
| } | ||
| : undefined; | ||
| }; |
There was a problem hiding this comment.
The drawer is currently using the CDS Select and Linode MUI TextField since the numeric spinner isn't available in the cds-web-components yet. This is to give the cds Select component the same error border color that gets used with the Linode components in their error state.
There was a problem hiding this comment.
It looks like we can also provide an error class to select, so I'm going to look into whether that gives the same border color. If so, we may be able to remove this and leverage that instead.
There was a problem hiding this comment.
After testing it out, it looks like providing className="error" to the Select component doesn't provide the error class to the component and, as a result, it won't display the error styles for that class from the component. I also tried wrapping it in a div with the error class name, but that didn't work either.
Is there a specific way this class needs to be applied to Select? Otherwise we may need to keep this as a workaround for now.
There was a problem hiding this comment.
I'm not sure since it's a CDS Select and it's different from how our UI Select component works. Maybe the CDS team would know
There was a problem hiding this comment.
@smans-akamai, your approach also seems fine.
I wasn't able to reproduce an error state for these selects since there are no empty options, but I was playing around with cds-web-components and also just adding a new select there:
you can add your className but you also need to use styled :
const StyledSelect = styled(Select)`
&.your-class {
...
}
`;
<StyledSelect
{...field}
className="your-class"
data-testid="database-name-select"
...
/>
There was a problem hiding this comment.
@aaleksee-akamai Thanks, I'll look into this other approach. In the meantime, you can reproduce the error state in this pull request with the following steps:
- Uncomment the mock error response for the connection-pools POST request
- Go to the
Networkingtab of anactivePostgreSQL Database Clusterhttp://localhost:3000/databases/postgresql/1/networking - Select the
Add Poolbutton in theManage PgBouncer Connection Poolssection to open theAdd a New Connection Pooldrawer - Make a valid selection in the fields and select
Add Pool - Select submit and see that the POST returns an error response
- Verify that the backend errors are displayed below their respective fields.
I've included the steps in the description.
There was a problem hiding this comment.
Switched to the MUI select for now while we troubleshoot this issue. Here's my latest comment related to this.
| // }, | ||
| // { status: 400 } | ||
| // ); | ||
| return HttpResponse.json(connectionPool); |
There was a problem hiding this comment.
You can uncomment the lines above to mock the error response for the fields to see the inline errors.
...src/features/Databases/DatabaseDetail/DatabaseNetworking/DatabaseConnectionPoolAddDrawer.tsx
Outdated
Show resolved
Hide resolved
...src/features/Databases/DatabaseDetail/DatabaseNetworking/DatabaseConnectionPoolAddDrawer.tsx
Outdated
Show resolved
Hide resolved
...src/features/Databases/DatabaseDetail/DatabaseNetworking/DatabaseConnectionPoolAddDrawer.tsx
Outdated
Show resolved
Hide resolved
...src/features/Databases/DatabaseDetail/DatabaseNetworking/DatabaseAddConnectionPoolDrawer.tsx
Show resolved
Hide resolved
...src/features/Databases/DatabaseDetail/DatabaseNetworking/DatabaseConnectionPoolAddDrawer.tsx
Outdated
Show resolved
Hide resolved
...src/features/Databases/DatabaseDetail/DatabaseNetworking/DatabaseConnectionPoolAddDrawer.tsx
Outdated
Show resolved
Hide resolved
...manager/src/features/Databases/DatabaseDetail/DatabaseNetworking/DatabaseConnectionPools.tsx
Outdated
Show resolved
Hide resolved
...src/features/Databases/DatabaseDetail/DatabaseNetworking/DatabaseConnectionPoolAddDrawer.tsx
Outdated
Show resolved
Hide resolved
...src/features/Databases/DatabaseDetail/DatabaseNetworking/DatabaseConnectionPoolAddDrawer.tsx
Outdated
Show resolved
Hide resolved
...src/features/Databases/DatabaseDetail/DatabaseNetworking/DatabaseConnectionPoolAddDrawer.tsx
Outdated
Show resolved
Hide resolved
...manager/src/features/Databases/DatabaseDetail/DatabaseNetworking/DatabaseConnectionPools.tsx
Outdated
Show resolved
Hide resolved
...manager/src/features/Databases/DatabaseDetail/DatabaseNetworking/DatabaseConnectionPools.tsx
Outdated
Show resolved
Hide resolved
dwiley-akamai
left a comment
There was a problem hiding this comment.
Verification steps ✅
| /** Shared ErrorText component that displays formatted error messages below form field components that don't have the errorText property */ | ||
| const SharedErrorText = (errorMessage: string | undefined) => | ||
| errorMessage && ( | ||
| <FormHelperText | ||
| error | ||
| role="alert" | ||
| sx={{ marginTop: theme.spacingFunction(4) }} | ||
| > | ||
| {errorMessage} | ||
| </FormHelperText> | ||
| ); | ||
|
|
||
| /** Utility function to generate error styles for form field components that can't set them by default */ | ||
| const makeErrorStyles = (errorMessage: string | undefined) => { | ||
| return errorMessage | ||
| ? { | ||
| border: `1px solid ${theme.tokens.component.Select.Error.Border}`, | ||
| } | ||
| : undefined; | ||
| }; |
There was a problem hiding this comment.
Could consider moving these to the databases utilities file, especially if they may be used elsewhere for the feature
There was a problem hiding this comment.
I've removed these for now as they aren't necessary any more. Here's the related comment on the changes I made.
| return `${poolMode.charAt(0).toUpperCase()}${poolMode.slice(1)}`; | ||
| }} | ||
| /> | ||
| {SharedErrorText(fieldState.error?.message)} |
There was a problem hiding this comment.
that seems ok but just curious - why you don't use rules there?
There was a problem hiding this comment.
For validating the fields in this form, we're using schema validation with Yup rather than through the rules property of the Controller. This moves the main validation logic from the component to a central file (ie. the database.schema.ts). It makes it easier for us to reuse validation we need to. There are other benefits too, but this is generally the approach we use in the DBaaS UI.
...src/features/Databases/DatabaseDetail/DatabaseNetworking/DatabaseAddConnectionPoolDrawer.tsx
Outdated
Show resolved
Hide resolved
6ee00ae to
e49ae24
Compare
|
@bnussman-akamai @hana-akamai @aaleksee-akamai @dwiley-akamai We've created the ticket UIE-10056, to look into this issue separately. I've also removed the workaround functions that were created for this. Once that component gets pull back in, I plan to revisit whether we still need those helper functions. I've also included the verification steps for showing the error state in the description. |
bnussman-akamai
left a comment
There was a problem hiding this comment.
Drawer looks good!
Also confirmed field errors worked using the provided mock.
| resources. | ||
| </Typography> | ||
| <form onSubmit={handleSubmit(onSubmit)}> | ||
| <Box mt={2.5}> |
There was a problem hiding this comment.
Nit: Can we look into using a <Stack spacing={2.5}> .... </Stack> to handle spacing rather than many Boxes?
...src/features/Databases/DatabaseDetail/DatabaseNetworking/DatabaseAddConnectionPoolDrawer.tsx
Outdated
Show resolved
Hide resolved
...src/features/Databases/DatabaseDetail/DatabaseNetworking/DatabaseAddConnectionPoolDrawer.tsx
Outdated
Show resolved
Hide resolved
Cloud Manager UI test results🔺 1 failing test on test run #15 ↗︎
Details
TroubleshootingUse this command to re-run the failing tests: pnpm cy:run -s "cypress/e2e/core/linodes/clone-linode.spec.ts" |
|||||||||||||||||
…3276) * UIE-9379: Implementing Add Pool functionality for PgBouncer * Adding fix to schema for null value validation issue and cleanup * starting on initial validation * Adding error mocking for calls in serverHandlers * Adding backend error handling for add pool drawer fields * Initial cleanup and adjusting validation based on discussions * Creating initial test file * Adding unit tests and updating markup for add pool drawer * additional cleanup * Added changesets * Applying initial feedback * Applying secondary feedback * Applying smaller changes in feedback with text update * Switching to Linode UI Select and cleanup * Applying additional feedback
…3276) * UIE-9379: Implementing Add Pool functionality for PgBouncer * Adding fix to schema for null value validation issue and cleanup * starting on initial validation * Adding error mocking for calls in serverHandlers * Adding backend error handling for add pool drawer fields * Initial cleanup and adjusting validation based on discussions * Creating initial test file * Adding unit tests and updating markup for add pool drawer * additional cleanup * Added changesets * Applying initial feedback * Applying secondary feedback * Applying smaller changes in feedback with text update * Switching to Linode UI Select and cleanup * Applying additional feedback

Description 📝
This pull request is to implement the Add Pool functionality for PgBouncer. This will allow users to create new connection pools via a new drawer. Those connection pools will then be added to the connection pools table in the Networking tab.
Changes 🔄
List any change(s) relevant to the reviewer.
Add Poolbutton in the Database DetailsNetworkingtabManage PgBouncer Connection Poolssection to open an add connection pool drawer.Scope 🚢
Upon production release, changes in this PR will be visible to:
Preview 📷
How to test 🧪
Prerequisites
(How to setup test environment)
Add Poolbutton gets enabled for postgresql database clusters, modify the mock database response by setting thedatabasestatus property in makeMockDatabase toactive.Verification steps
(How to verify changes)
General
Networkingtab of anactivePostgreSQL Database Clusterhttp://localhost:3000/databases/postgresql/1/networkingAdd Poolbutton in theManage PgBouncer Connection Poolssection to open theAdd a New Connection PooldrawerAdd PoolBackend Errors Displaying Below Fields
Networkingtab of anactivePostgreSQL Database Clusterhttp://localhost:3000/databases/postgresql/1/networkingAdd Poolbutton in theManage PgBouncer Connection Poolssection to open theAdd a New Connection PooldrawerAdd PoolAuthor Checklists
As an Author, to speed up the review process, I considered 🤔
👀 Doing a self review
❔ Our contribution guidelines
🤏 Splitting feature into small PRs
➕ Adding a changeset
🧪 Providing/improving test coverage
🔐 Removing all sensitive information from the code and PR description
🚩 Using a feature flag to protect the release
👣 Providing comprehensive reproduction steps
📑 Providing or updating our documentation
🕛 Scheduling a pair reviewing session
📱 Providing mobile support
♿ Providing accessibility support
As an Author, before moving this PR from Draft to Open, I confirmed ✅