Skip to content

Commit

Permalink
Merge pull request #1006 from huboneo/bugfix-duplicate-dbs
Browse files Browse the repository at this point in the history
Only show each database once in :dbs output
  • Loading branch information
huboneo authored Dec 4, 2019
2 parents 30a2baf + aee7737 commit 80fb640
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/browser/modules/Stream/Auth/DbsFrame.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ import { useDbCommand } from 'shared/modules/commands/commandsDuck'
import TextCommand from 'browser/modules/DecoratedText/TextCommand'
import ClickToCode from 'browser/modules/ClickToCode/index'
import { StyledCodeBlockFrame } from 'browser/modules/Main/styled'
import { uniqBy } from 'lodash-es'

export const DbsFrame = props => {
const { frame } = props
const { dbs = [] } = frame
const dbsToShow = uniqBy(dbs, 'name')

return (
<React.Fragment>
Expand All @@ -51,10 +53,10 @@ export const DbsFrame = props => {
</StyledConnectionAside>
<StyledConnectionBodyContainer>
<StyledConnectionBody>
<Render if={Array.isArray(dbs) && dbs.length}>
<Render if={Array.isArray(dbsToShow) && dbsToShow.length}>
Click on one to start using it:
<UnstyledList data-testid='dbs-command-list'>
{dbs.map(db => {
{dbsToShow.map(db => {
return (
<StyledDbsRow key={toKeyString(db.name)}>
<TextCommand command={`${useDbCommand} ${db.name}`} />
Expand All @@ -63,7 +65,7 @@ export const DbsFrame = props => {
})}
</UnstyledList>
</Render>
<Render if={!Array.isArray(dbs) || !dbs.length}>
<Render if={!Array.isArray(dbsToShow) || !dbsToShow.length}>
<div>
Either you don't have permission to list available databases or
the dbms you're connected to don't support multiple databases.
Expand Down

0 comments on commit 80fb640

Please sign in to comment.