mirror of
https://github.com/navidrome/navidrome.git
synced 2025-05-07 22:01:08 +03:00
Disable public toggle if user is not the playlist's owner
This commit is contained in:
parent
b4e06c416d
commit
b636565c62
@ -20,7 +20,7 @@ const PlaylistFilter = (props) => (
|
|||||||
</Filter>
|
</Filter>
|
||||||
)
|
)
|
||||||
|
|
||||||
const TogglePublicInput = ({ resource, record, source }) => {
|
const TogglePublicInput = ({ permissions, resource, record, source }) => {
|
||||||
const notify = useNotify()
|
const notify = useNotify()
|
||||||
const [togglePublic] = useUpdate(
|
const [togglePublic] = useUpdate(
|
||||||
resource,
|
resource,
|
||||||
@ -43,10 +43,20 @@ const TogglePublicInput = ({ resource, record, source }) => {
|
|||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
}
|
}
|
||||||
|
|
||||||
return <Switch checked={record[source]} onClick={handleClick} />
|
const canChange =
|
||||||
|
permissions === 'admin' ||
|
||||||
|
localStorage.getItem('username') === record['owner']
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Switch
|
||||||
|
checked={record[source]}
|
||||||
|
onClick={handleClick}
|
||||||
|
disabled={!canChange}
|
||||||
|
/>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const PlaylistList = (props) => (
|
const PlaylistList = ({ permissions, ...props }) => (
|
||||||
<List {...props} exporter={false} filters={<PlaylistFilter />}>
|
<List {...props} exporter={false} filters={<PlaylistFilter />}>
|
||||||
<Datagrid rowClick="show" isRowSelectable={(r) => isWritable(r && r.owner)}>
|
<Datagrid rowClick="show" isRowSelectable={(r) => isWritable(r && r.owner)}>
|
||||||
<TextField source="name" />
|
<TextField source="name" />
|
||||||
@ -54,7 +64,7 @@ const PlaylistList = (props) => (
|
|||||||
<NumberField source="songCount" />
|
<NumberField source="songCount" />
|
||||||
<DurationField source="duration" />
|
<DurationField source="duration" />
|
||||||
<DateField source="updatedAt" />
|
<DateField source="updatedAt" />
|
||||||
<TogglePublicInput source="public" />
|
<TogglePublicInput source="public" permissions={permissions} />
|
||||||
<Writable>
|
<Writable>
|
||||||
<EditButton />
|
<EditButton />
|
||||||
</Writable>
|
</Writable>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user