Add flag to disable Scrobble config in the UI

This commit is contained in:
Deluan
2021-06-10 21:04:26 -04:00
committed by Deluan Quintão
parent a4f91b74d2
commit ffa76bba6a
6 changed files with 60 additions and 0 deletions
+1
View File
@@ -19,6 +19,7 @@ const defaultConfig = {
defaultTheme: 'Dark',
enableUserEditing: true,
devEnableShare: true,
devEnableScrobble: true,
}
let config
+3
View File
@@ -5,6 +5,8 @@ import { SelectLanguage } from './SelectLanguage'
import { SelectTheme } from './SelectTheme'
import { SelectDefaultView } from './SelectDefaultView'
import { NotificationsToggle } from './NotificationsToggle'
import { ScrobbleToggle } from './ScrobbleToggle'
import config from '../config'
const useStyles = makeStyles({
root: { marginTop: '1em' },
@@ -22,6 +24,7 @@ const Personal = () => {
<SelectLanguage />
<SelectDefaultView />
<NotificationsToggle />
{config.devEnableScrobble && <ScrobbleToggle />}
</SimpleForm>
</Card>
)
+43
View File
@@ -0,0 +1,43 @@
import { useNotify, useTranslate } from 'react-admin'
import { useDispatch, useSelector } from 'react-redux'
import { setNotificationsState } from '../actions'
import {
FormControl,
FormControlLabel,
LinearProgress,
Switch,
} from '@material-ui/core'
import { useState } from 'react'
import { openInNewTab } from '../utils'
export const ScrobbleToggle = (props) => {
const translate = useTranslate()
const [linked, setLinked] = useState(false)
const toggleScrobble = (event) => {
if (!linked) {
openInNewTab(
'https://www.last.fm/api/auth/?api_key=c2918986bf01b6ba353c0bc1bdd27bea'
)
}
setLinked(!linked)
}
return (
<FormControl>
<FormControlLabel
control={
<Switch
id={'notifications'}
color="primary"
checked={linked}
disabled={linked}
onChange={toggleScrobble}
/>
}
label={<span>{translate('Scrobble to Last.FM')}</span>}
/>
{linked && <LinearProgress />}
</FormControl>
)
}