Add links to documentation on how to contribute with themes and translations

This commit is contained in:
Deluan
2020-04-27 20:43:41 -04:00
parent 320fe11a66
commit e871c7daee
+36
View File
@@ -10,6 +10,7 @@ import {
useLocale, useLocale,
} from 'react-admin' } from 'react-admin'
import { makeStyles } from '@material-ui/core/styles' import { makeStyles } from '@material-ui/core/styles'
import HelpOutlineIcon from '@material-ui/icons/HelpOutline'
import { changeTheme } from './actions' import { changeTheme } from './actions'
import themes from '../themes' import themes from '../themes'
import i18n from '../i18n' import i18n from '../i18n'
@@ -18,6 +19,20 @@ const useStyles = makeStyles({
root: { marginTop: '1em' }, root: { marginTop: '1em' },
}) })
const helpKey = '_help'
function openInNewTab(url) {
const win = window.open(url, '_blank')
win.focus()
}
const HelpMsg = ({ caption }) => (
<>
<HelpOutlineIcon />
&nbsp;&nbsp; {caption}
</>
)
const SelectLanguage = (props) => { const SelectLanguage = (props) => {
const translate = useTranslate() const translate = useTranslate()
const locale = useLocale() const locale = useLocale()
@@ -25,6 +40,10 @@ const SelectLanguage = (props) => {
const langChoices = Object.keys(i18n).map((key) => { const langChoices = Object.keys(i18n).map((key) => {
return { id: key, name: i18n[key].languageName } return { id: key, name: i18n[key].languageName }
}) })
langChoices.push({
id: helpKey,
name: <HelpMsg caption={'Help to translate'} />,
})
return ( return (
<SelectInput <SelectInput
{...props} {...props}
@@ -33,6 +52,12 @@ const SelectLanguage = (props) => {
defaultValue={locale} defaultValue={locale}
choices={langChoices} choices={langChoices}
onChange={(event) => { onChange={(event) => {
if (event.target.value === helpKey) {
openInNewTab(
'https://www.navidrome.org/docs/developers/translations/'
)
return
}
setLocale(event.target.value) setLocale(event.target.value)
localStorage.setItem('locale', event.target.value) localStorage.setItem('locale', event.target.value)
}} }}
@@ -47,6 +72,10 @@ const SelectTheme = (props) => {
const themeChoices = Object.keys(themes).map((key) => { const themeChoices = Object.keys(themes).map((key) => {
return { id: key, name: themes[key].themeName } return { id: key, name: themes[key].themeName }
}) })
themeChoices.push({
id: helpKey,
name: <HelpMsg caption={'Create your own'} />,
})
return ( return (
<SelectInput <SelectInput
{...props} {...props}
@@ -55,11 +84,18 @@ const SelectTheme = (props) => {
defaultValue={currentTheme} defaultValue={currentTheme}
choices={themeChoices} choices={themeChoices}
onChange={(event) => { onChange={(event) => {
if (event.target.value === helpKey) {
openInNewTab(
'https://www.navidrome.org/docs/developers/creating-themes/'
)
return
}
dispatch(changeTheme(event.target.value)) dispatch(changeTheme(event.target.value))
}} }}
/> />
) )
} }
const Personal = () => { const Personal = () => {
const translate = useTranslate() const translate = useTranslate()
const classes = useStyles() const classes = useStyles()