-
Notifications
You must be signed in to change notification settings - Fork 402
feat: [UIE-9181] - DBaaS - Display read-only hostname in connection details tables based on VPC configuration #12976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
3c927b7
fd48bd5
ec4d784
0e0a5ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@linode/api-v4": Changed | ||
| --- | ||
|
|
||
| DatabaseHosts interface primary prop to optional ([#12976](https://github.com/linode/manager/pull/12976)) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@linode/manager": Changed | ||
| --- | ||
|
|
||
| DBaaS Connection details table Read-only Host field renders based on VPC configuration ([#12976](https://github.com/linode/manager/pull/12976)) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,11 @@ | |
| SUMMARY_PRIVATE_HOST_COPY, | ||
| SUMMARY_PRIVATE_HOST_LEGACY_COPY, | ||
| } from '../constants'; | ||
| import { getReadOnlyHost, isLegacyDatabase } from '../utilities'; | ||
| import { | ||
| convertPrivateToPublicHostname, | ||
| getReadOnlyHost, | ||
| isLegacyDatabase, | ||
| } from '../utilities'; | ||
| import { ConnectionDetailsRow } from './ConnectionDetailsRow'; | ||
| import { useStyles } from './DatabaseSummary/DatabaseSummaryConnectionDetails.style'; | ||
|
|
||
|
|
@@ -18,6 +22,8 @@ | |
| database: Database; | ||
| } | ||
|
|
||
| type HostContentMode = 'default' | 'private' | 'public'; | ||
|
|
||
| /** | ||
| * This component is responsible for conditionally rendering the Private Host, Public Host, and Read-only Host rows that get displayed in | ||
| * the Connection Details tables that appear in the Database Summary and Networking tabs */ | ||
|
|
@@ -40,20 +46,15 @@ | |
| }, | ||
| }; | ||
|
|
||
| const isLegacy = isLegacyDatabase(database); | ||
| const isLegacy = isLegacyDatabase(database); // TODO (UIE-8214) POST GA - Remove legacy check and legacy content as it is no longer necessary | ||
|
Check warning on line 49 in packages/manager/src/features/Databases/DatabaseDetail/ConnectionDetailsHostRows.tsx
|
||
| const hasVPC = Boolean(database?.private_network?.vpc_id); | ||
| const hasPublicVPC = hasVPC && database?.private_network?.public_access; | ||
|
|
||
| const getHostContent = ( | ||
| mode: 'default' | 'private' | 'public' = 'default' | ||
| ) => { | ||
| const getHostContent = (mode: HostContentMode = 'default') => { | ||
| let primaryHostName = database.hosts?.primary; | ||
|
|
||
| if (mode === 'public' && primaryHostName) { | ||
| // Remove 'private-' substring at the beginning of the hostname and replace it with 'public-' | ||
| const privateStrIndex = database.hosts.primary.indexOf('-'); | ||
| const baseHostName = database.hosts.primary.slice(privateStrIndex + 1); | ||
| primaryHostName = `public-${baseHostName}`; | ||
| primaryHostName = convertPrivateToPublicHostname(primaryHostName); | ||
| } | ||
|
|
||
| if (primaryHostName) { | ||
|
|
@@ -89,15 +90,22 @@ | |
| ); | ||
| }; | ||
|
|
||
| const getReadOnlyHostContent = () => { | ||
| const getReadOnlyHostContent = (mode: HostContentMode = 'default') => { | ||
| const defaultValue = isLegacy ? '-' : 'N/A'; | ||
| const value = getReadOnlyHost(database) || defaultValue; | ||
| const hasHost = value !== '-' && value !== 'N/A'; | ||
| const hostValue = getReadOnlyHost(database) || defaultValue; | ||
| const hasHost = hostValue !== '-' && hostValue !== 'N/A'; | ||
| const displayedHost = | ||
| mode === 'public' && hasHost | ||
| ? convertPrivateToPublicHostname(hostValue) | ||
| : hostValue; | ||
| return ( | ||
| <> | ||
| {value} | ||
| {value && hasHost && ( | ||
| <CopyTooltip className={classes.inlineCopyToolTip} text={value} /> | ||
| {displayedHost} | ||
| {displayedHost && hasHost && ( | ||
| <CopyTooltip | ||
| className={classes.inlineCopyToolTip} | ||
| text={displayedHost} | ||
| /> | ||
| )} | ||
| {isLegacy && ( | ||
| <TooltipIcon | ||
|
|
@@ -111,13 +119,21 @@ | |
| componentsProps={hostTooltipComponentProps} | ||
| status="info" | ||
| sxTooltipIcon={sxTooltipIcon} | ||
| text={SUMMARY_HOST_TOOLTIP_COPY} | ||
| text={ | ||
| mode === 'private' | ||
| ? SUMMARY_PRIVATE_HOST_COPY | ||
| : SUMMARY_HOST_TOOLTIP_COPY | ||
| } | ||
| /> | ||
| )} | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| const readonlyHostLabel = isLegacy | ||
| ? 'Private Network Host' | ||
| : 'Read-only Host'; | ||
|
|
||
| return ( | ||
| <> | ||
| <ConnectionDetailsRow label={hasVPC ? 'Private Host' : 'Host'}> | ||
|
|
@@ -129,10 +145,15 @@ | |
| </ConnectionDetailsRow> | ||
| )} | ||
| <ConnectionDetailsRow | ||
| label={isLegacy ? 'Private Network Host' : 'Read-only Host'} | ||
| label={hasVPC ? 'Private Read-only Host' : readonlyHostLabel} | ||
| > | ||
| {getReadOnlyHostContent()} | ||
| {getReadOnlyHostContent(hasVPC ? 'private' : 'default')} | ||
| </ConnectionDetailsRow> | ||
| {hasPublicVPC && ( | ||
| <ConnectionDetailsRow label="Public Read-only Host"> | ||
| {getReadOnlyHostContent('public')} | ||
| </ConnectionDetailsRow> | ||
| )} | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main changes for this pull request are here. I made the same type of change that I made to the Host field in my previous PR so that it renders the different variations of the field based on the VPC configuration. |
||
| </> | ||
| ); | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the documentation, the backend doesn't always provide these hostnames. There's existing logic in the UI to add a placeholder for these fields as well, so I've updated the interface here to reflect that.
For
standby, it seems to be excluded from thehostsobject for single node clusters. I'm not sure what scenario excludesprimarybut I assume that's handled the same way. Going to check with the backend to make sure.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked with the backend and the
Hostsobject can be null. Changing this to update thehoststype in theDatabaseInstanceinterface instead