hiding locked dbs

This commit is contained in:
mrfry
2021-02-22 12:14:32 +01:00
parent 2ae8d7ffb2
commit 20fb611ee3
3 changed files with 40 additions and 19 deletions
+14 -5
View File
@@ -1,21 +1,30 @@
import React from 'react'
export default function DbSelector(props) {
const { qdbs, onChange } = props
const { selectedDb, qdbs, onChange, hideLockedDbs } = props
const selectedIndex =
qdbs && selectedDb
? qdbs.findIndex((qdb) => {
return qdb.name === selectedDb.name
})
: -1
return (
<>
<select
style={{ margin: '10px 0px' }}
defaultValue={-1}
defaultValue={selectedIndex}
value={selectedIndex}
onChange={(event) => {
onChange(qdbs[event.target.value])
}}
>
<option disabled value={-1}>
{' -- Válassz egy kérdés adatbázist -- '}
</option>
<option value={-1}>{' -- Válassz egy kérdés adatbázist -- '}</option>
{qdbs.map((qdb, i) => {
if (hideLockedDbs && qdb.locked) {
return null
}
return (
<option value={i} key={qdb.name}>
{qdb.name}