|
|
@@ -1,4 +1,4 @@
|
|
|
-import { useCallback } from 'react'
|
|
|
+import { useCallback, useMemo } from 'react'
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
import { Alert, Button, Modal } from 'react-bootstrap'
|
|
|
import Icon from '../../../shared/components/icon'
|
|
|
@@ -6,11 +6,14 @@ import Tooltip from '../../../shared/components/tooltip'
|
|
|
import useAsync from '../../../shared/hooks/use-async'
|
|
|
import { postJSON } from '../../../infrastructure/fetch-json'
|
|
|
import ignoredWords from '../ignored-words'
|
|
|
+import BetaBadge from '../../../shared/components/beta-badge'
|
|
|
|
|
|
type DictionaryModalContentProps = {
|
|
|
handleHide: () => void
|
|
|
}
|
|
|
|
|
|
+const wordsSortFunction = (a, b) => a.localeCompare(b)
|
|
|
+
|
|
|
export default function DictionaryModalContent({
|
|
|
handleHide,
|
|
|
}: DictionaryModalContentProps) {
|
|
|
@@ -32,10 +35,31 @@ export default function DictionaryModalContent({
|
|
|
[runAsync]
|
|
|
)
|
|
|
|
|
|
+ const betaBadgeTooltipProps = useMemo(() => {
|
|
|
+ return {
|
|
|
+ id: 'dictionary-modal-tooltip',
|
|
|
+ placement: 'bottom',
|
|
|
+ className: 'tooltip-wide',
|
|
|
+ text: (
|
|
|
+ <>
|
|
|
+ We are beta testing the dictionary manager.
|
|
|
+ <br />
|
|
|
+ Click to give feedback
|
|
|
+ </>
|
|
|
+ ),
|
|
|
+ }
|
|
|
+ }, [])
|
|
|
+
|
|
|
return (
|
|
|
<>
|
|
|
<Modal.Header closeButton>
|
|
|
- <Modal.Title>{t('edit_dictionary')}</Modal.Title>
|
|
|
+ <Modal.Title>
|
|
|
+ {t('edit_dictionary')}{' '}
|
|
|
+ <BetaBadge
|
|
|
+ tooltip={betaBadgeTooltipProps}
|
|
|
+ url="https://forms.gle/8cLBEW6HU9mDKBPX9"
|
|
|
+ />
|
|
|
+ </Modal.Title>
|
|
|
</Modal.Header>
|
|
|
|
|
|
<Modal.Body>
|
|
|
@@ -44,26 +68,30 @@ export default function DictionaryModalContent({
|
|
|
) : null}
|
|
|
|
|
|
{ignoredWords.learnedWords?.size > 0 ? (
|
|
|
- <ul className="list-unstyled">
|
|
|
- {[...ignoredWords.learnedWords].sort().map(learnedWord => (
|
|
|
- <li key={learnedWord}>
|
|
|
- <Tooltip
|
|
|
- id={`tooltip-remove-learned-word-${learnedWord}`}
|
|
|
- description={t('edit_dictionary_remove')}
|
|
|
- >
|
|
|
- <Button
|
|
|
- className="btn-link action-btn"
|
|
|
- onClick={() => handleRemove(learnedWord)}
|
|
|
+ <ul className="list-unstyled dictionary-entries-list">
|
|
|
+ {[...ignoredWords.learnedWords]
|
|
|
+ .sort(wordsSortFunction)
|
|
|
+ .map(learnedWord => (
|
|
|
+ <li key={learnedWord} className="dictionary-entry">
|
|
|
+ <span className="dictionary-entry-name">{learnedWord}</span>
|
|
|
+ <Tooltip
|
|
|
+ id={`tooltip-remove-learned-word-${learnedWord}`}
|
|
|
+ description={t('edit_dictionary_remove')}
|
|
|
+ overlayProps={{ delay: 0 }}
|
|
|
>
|
|
|
- <Icon
|
|
|
- type="trash-o"
|
|
|
- accessibilityLabel={t('edit_dictionary_remove')}
|
|
|
- />
|
|
|
- </Button>
|
|
|
- </Tooltip>
|
|
|
- {learnedWord}
|
|
|
- </li>
|
|
|
- ))}
|
|
|
+ <Button
|
|
|
+ bsStyle="danger"
|
|
|
+ bsSize="xs"
|
|
|
+ onClick={() => handleRemove(learnedWord)}
|
|
|
+ >
|
|
|
+ <Icon
|
|
|
+ type="trash-o"
|
|
|
+ accessibilityLabel={t('edit_dictionary_remove')}
|
|
|
+ />
|
|
|
+ </Button>
|
|
|
+ </Tooltip>
|
|
|
+ </li>
|
|
|
+ ))}
|
|
|
</ul>
|
|
|
) : (
|
|
|
<i>{t('edit_dictionary_empty')}</i>
|