Fix display of database rows when password is not available

closes #4381
This commit is contained in:
DaneEveritt 2022-09-17 11:50:40 -07:00
parent bf2456d0fc
commit e040fd1ebd
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
2 changed files with 7 additions and 10 deletions

View file

@ -15,8 +15,7 @@ export const rawDataToServerDatabase = (data: any): ServerDatabase => ({
username: data.username, username: data.username,
connectionString: `${data.host.address}:${data.host.port}`, connectionString: `${data.host.address}:${data.host.port}`,
allowConnectionsFrom: data.connections_from, allowConnectionsFrom: data.connections_from,
password: password: data.relationships.password?.attributes?.password,
data.relationships && data.relationships.password ? data.relationships.password.attributes.password : undefined,
}); });
export default (uuid: string, includePassword = true): Promise<ServerDatabase[]> => { export default (uuid: string, includePassword = true): Promise<ServerDatabase[]> => {

View file

@ -34,6 +34,10 @@ export default ({ database, className }: Props) => {
const appendDatabase = ServerContext.useStoreActions((actions) => actions.databases.appendDatabase); const appendDatabase = ServerContext.useStoreActions((actions) => actions.databases.appendDatabase);
const removeDatabase = ServerContext.useStoreActions((actions) => actions.databases.removeDatabase); const removeDatabase = ServerContext.useStoreActions((actions) => actions.databases.removeDatabase);
const jdbcConnectionString = `jdbc:mysql://${database.username}${
database.password ? `:${database.password}` : ''
}@${database.connectionString}/${database.name}`;
const schema = object().shape({ const schema = object().shape({
confirm: string() confirm: string()
.required('The database name must be provided.') .required('The database name must be provided.')
@ -122,14 +126,8 @@ export default ({ database, className }: Props) => {
</Can> </Can>
<div css={tw`mt-6`}> <div css={tw`mt-6`}>
<Label>JDBC Connection String</Label> <Label>JDBC Connection String</Label>
<CopyOnClick <CopyOnClick text={jdbcConnectionString}>
text={`jdbc:mysql://${database.username}:${database.password}@${database.connectionString}/${database.name}`} <Input type={'text'} readOnly value={jdbcConnectionString} />
>
<Input
type={'text'}
readOnly
value={`jdbc:mysql://${database.username}:${database.password}@${database.connectionString}/${database.name}`}
/>
</CopyOnClick> </CopyOnClick>
</div> </div>
<div css={tw`mt-6 text-right`}> <div css={tw`mt-6 text-right`}>