Skip to content

Commit

Permalink
Handle more database states
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarDamkjaer committed Sep 12, 2023
1 parent 1b37e03 commit cdc3b4b
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/browser/modules/DBMSInfo/DatabaseSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const EMPTY_OPTION = 'Select db to use'

const HOUSE_EMOJI = '\u{1F3E0}'
const HOUR_GLASS_EMOJI = '\u{231B}'
const RED_EXCLAIMATION_EMOJI = '\u{2757}'
const NBSP_CHAR = '\u{00A0}'

type DatabaseSelectorProps = {
Expand Down Expand Up @@ -79,6 +80,15 @@ export const DatabaseSelector = ({
a.name.localeCompare(b.name)
)

const unavailableStatuses = [
'unknown',
'starting',
'stopping',
'store copying',
'offline'
]
const errorStatuses = ['dirty', 'quarantined']

return (
<DrawerSection>
<DrawerSubHeader>Use database</DrawerSubHeader>
Expand All @@ -96,13 +106,20 @@ export const DatabaseSelector = ({
<option
key={dbOrAlias.name}
value={dbOrAlias.name}
disabled={dbOrAlias.status === 'unknown'}
disabled={
unavailableStatuses.includes(dbOrAlias.status) ||
errorStatuses.includes(dbOrAlias.status)
}
title={`status: ${dbOrAlias.status}`}
>
{dbOrAlias.name}
{dbOrAlias === homeDb ? NBSP_CHAR + HOUSE_EMOJI : ''}
{dbOrAlias.status === 'unknown'
{unavailableStatuses.includes(dbOrAlias.status)
? NBSP_CHAR + HOUR_GLASS_EMOJI
: ''}
{errorStatuses.includes(dbOrAlias.status)
? NBSP_CHAR + RED_EXCLAIMATION_EMOJI
: ''}
</option>
))}
</Select>
Expand Down

0 comments on commit cdc3b4b

Please sign in to comment.