Skip to content

Commit

Permalink
fix [UIE-8007] DBaaS Summary tab display correct user and readonly host
Browse files Browse the repository at this point in the history
  • Loading branch information
corya-akamai committed Sep 23, 2024
1 parent 3a82669 commit e7f11d0
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 15 deletions.
5 changes: 5 additions & 0 deletions packages/api-v4/.changeset/pr-10989-fixed-1727118907870.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/api-v4": Fixed
---

standby field returned by the API ([#10989](https://github.com/linode/manager/pull/10989))
3 changes: 2 additions & 1 deletion packages/api-v4/src/databases/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export interface DatabaseCredentials {

interface DatabaseHosts {
primary: string;
secondary: string;
secondary?: string;
standby?: string;
}

export interface SSLFields {
Expand Down
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-10989-fixed-1727118993352.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Fixed
---

Summary tab display of username and read-only host ([#10989](https://github.com/linode/manager/pull/10989))
30 changes: 22 additions & 8 deletions packages/manager/src/factories/databases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,17 @@ export const databaseInstanceFactory = Factory.Sync.makeFactory<DatabaseInstance
),
created: '2021-12-09T17:15:12',
engine: Factory.each((i) => ['mysql', 'postgresql'][i % 2] as Engine),
hosts: {
primary: 'db-mysql-primary-0.b.linodeb.net',
secondary: 'db-mysql-secondary-0.b.linodeb.net',
},
hosts: Factory.each((i) =>
adb10(i)
? {
primary: 'db-mysql-primary-0.b.linodeb.net',
secondary: 'db-mysql-secondary-0.b.linodeb.net',
}
: {
primary: 'db-mysql-primary-0.b.linodeb.net',
standby: 'db-mysql-secondary-0.b.linodeb.net',
}
),
id: Factory.each((i) => i),
instance_uri: '',
label: Factory.each((i) => `example.com-database-${i}`),
Expand Down Expand Up @@ -213,10 +220,17 @@ export const databaseFactory = Factory.Sync.makeFactory<Database>({
created: '2021-12-09T17:15:12',
encrypted: false,
engine: 'mysql',
hosts: {
primary: 'db-mysql-primary-0.b.linodeb.net',
secondary: 'db-mysql-secondary-0.b.linodeb.net',
},
hosts: Factory.each((i) =>
adb10(i)
? {
primary: 'db-mysql-primary-0.b.linodeb.net',
secondary: 'db-mysql-secondary-0.b.linodeb.net',
}
: {
primary: 'db-mysql-primary-0.b.linodeb.net',
standby: 'db-mysql-secondary-0.b.linodeb.net',
}
),
id: Factory.each((i) => i),
label: Factory.each((i) => `database-${i}`),
members: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ export const DatabaseSummaryConnectionDetails = (props: Props) => {
refetch: getDatabaseCredentials,
} = useDatabaseCredentialsQuery(database.engine, database.id);

const username =
database.platform === 'rdbms-default'
? 'akmadmin'
: database.engine === 'postgresql'
? 'linpostgres'
: DB_ROOT_USERNAME;

const password =
showCredentials && credentials ? credentials?.password : '••••••••••';

Expand Down Expand Up @@ -191,7 +198,7 @@ export const DatabaseSummaryConnectionDetails = (props: Props) => {

const disableShowBtn = ['failed', 'provisioning'].includes(database.status);
const disableDownloadCACertificateBtn = database.status === 'provisioning';
// const connectionDetailsCopy = `username = ${credentials?.username}\npassword = ${credentials?.password}\nhost = ${database.host}\nport = ${database.port}\ssl = ${ssl}`;
const readOnlyHost = database?.hosts?.standby || database?.hosts?.secondary;

const credentialsBtn = (handleClick: () => void, btnText: string) => {
return (
Expand Down Expand Up @@ -235,8 +242,7 @@ export const DatabaseSummaryConnectionDetails = (props: Props) => {
</Typography>
<Box className={classes.connectionDetailsCtn} data-qa-connection-details>
<Typography>
<span>username</span> ={' '}
{database.engine === 'postgresql' ? 'linpostgres' : DB_ROOT_USERNAME}
<span>username</span> = {username}
</Typography>
<Box display="flex">
<Typography>
Expand Down Expand Up @@ -356,19 +362,19 @@ export const DatabaseSummaryConnectionDetails = (props: Props) => {
</>
)}
</Box>
{database.hosts.secondary ? (
{readOnlyHost ? (
<Box alignItems="center" display="flex" flexDirection="row">
<Typography>
{database.platform === 'rdbms-default' ? (
<span>read-only host</span>
) : (
<span>private network host</span>
)}
= {database.hosts.secondary}
= {readOnlyHost}
</Typography>
<CopyTooltip
className={classes.inlineCopyToolTip}
text={database.hosts.secondary}
text={readOnlyHost}
/>
<TooltipIcon
status="help"
Expand Down

0 comments on commit e7f11d0

Please sign in to comment.