Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | 1972x 1972x 1972x 1972x 1972x 18x 5x 5x 5x 5x | import {Close} from '@mui/icons-material'
import {
Button,
Dialog,
DialogContent,
DialogTitle,
IconButton,
List,
ListItem,
ListItemButton,
Tooltip,
} from '@mui/material'
import {useContext, useState} from 'react'
import {PasswordPrompter, SettingsContext} from './building'
import {loadDictionary} from './storage'
export function CopyDictionary({
setName,
setContent,
}: {
setName: (name: string) => void
setContent: (content: string) => void
}) {
const requestPass = useContext(PasswordPrompter)
const settings = useContext(SettingsContext)
const [menuOpen, setMenuOpen] = useState(false)
const toggleMenu = () => setMenuOpen(!menuOpen)
return (
<>
<Tooltip title="select an existing dictionary to import as a copy">
<Button variant="outlined" onClick={toggleMenu}>
Copy
</Button>
</Tooltip>
{menuOpen && (
<Dialog open={menuOpen} onClose={toggleMenu}>
<DialogTitle>Copy Dictionary</DialogTitle>
<IconButton
aria-label="close export menu"
onClick={toggleMenu}
sx={{
position: 'absolute',
right: 8,
top: 12,
}}
className="close-button"
>
<Close />
</IconButton>
<DialogContent sx={{p: 0}}>
<List sx={{p: 0, pb: 2}}>
{settings.dictionary_names.map(name => (
<ListItem sx={{p: 0}} key={name}>
<ListItemButton
onClick={() =>
loadDictionary(
name,
dict => {
setName(
settings.dictionary_names.includes(name + ' Copy')
? name + ' Copy' + ((Math.random() * 1e4) >> 0)
: name + ' Copy'
)
setContent(JSON.stringify(dict, void 0, 2))
toggleMenu()
},
requestPass,
!!settings.use_db
)
}
>
{name}
</ListItemButton>
</ListItem>
))}
</List>
</DialogContent>
</Dialog>
)}
</>
)
}
|