Add owner_id to playlist
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
import { cloneElement, Children, isValidElement } from 'react'
|
||||
|
||||
export const isWritable = (owner) => {
|
||||
export const isWritable = (ownerId) => {
|
||||
return (
|
||||
localStorage.getItem('username') === owner ||
|
||||
localStorage.getItem('userId') === ownerId ||
|
||||
localStorage.getItem('role') === 'admin'
|
||||
)
|
||||
}
|
||||
|
||||
export const isReadOnly = (owner) => {
|
||||
return !isWritable(owner)
|
||||
export const isReadOnly = (ownerId) => {
|
||||
return !isWritable(ownerId)
|
||||
}
|
||||
|
||||
export const Writable = (props) => {
|
||||
const { record = {}, children } = props
|
||||
if (isWritable(record.owner)) {
|
||||
if (isWritable(record.ownerId)) {
|
||||
return Children.map(children, (child) =>
|
||||
isValidElement(child) ? cloneElement(child, props) : child
|
||||
)
|
||||
@@ -24,4 +24,4 @@ export const Writable = (props) => {
|
||||
export const isSmartPlaylist = (pls) => !!pls.rules
|
||||
|
||||
export const canChangeTracks = (pls) =>
|
||||
isWritable(pls.owner) && !isSmartPlaylist(pls)
|
||||
isWritable(pls.ownerId) && !isSmartPlaylist(pls)
|
||||
|
||||
@@ -22,7 +22,8 @@ export const useSelectedFields = ({
|
||||
useEffect(() => {
|
||||
if (
|
||||
!resourceFields ||
|
||||
Object.keys(resourceFields).length !== Object.keys(columns).length
|
||||
Object.keys(resourceFields).length !== Object.keys(columns).length ||
|
||||
!Object.keys(columns).every((c) => c in resourceFields)
|
||||
) {
|
||||
const obj = {}
|
||||
for (const key of Object.keys(columns)) {
|
||||
|
||||
Reference in New Issue
Block a user