Skip to content

🎧 Your Personal Streaming Service

Add Auto-Import toggle switch to playlists list view.

Caio Cotts9b4abd9e5a1b
diff --git a/ui/src/playlist/PlaylistList.js b/ui/src/playlist/PlaylistList.js
index 71a8c75db..4b026fb64 100644
--- a/ui/src/playlist/PlaylistList.js
+++ b/ui/src/playlist/PlaylistList.js
@@ -82,6 +82,39 @@ const TogglePublicInput = ({ resource, source }) => {
)
}
+const ToggleAutoImport = ({ resource, source }) => {
+ const record = useRecordContext()
+ console.log(record)
+ const notify = useNotify()
+ const [ToggleAutoImport] = useUpdate(
+ resource,
+ record.id,
+ {
+ ...record,
+ sync: !record.sync,
+ },
+ {
+ undoable: false,
+ onFailure: (error) => {
+ console.log(error)
+ notify('ra.page.error', 'warning')
+ },
+ },
+ )
+ const handleClick = (e) => {
+ ToggleAutoImport()
+ e.stopPropagation()
+ }
+
+ return record.path ? (
+ <Switch
+ checked={record[source]}
+ onClick={handleClick}
+ disabled={!isWritable(record.ownerId)}
+ />
+ ) : null
+}
+
const PlaylistListBulkActions = (props) => (
<>
<ChangePublicStatusButton public={true} {...props} />
@@ -107,6 +140,7 @@ const PlaylistList = (props) => {
<TogglePublicInput source="public" sortByOrder={'DESC'} />
),
comment: <TextField source="comment" />,
+ sync: <ToggleAutoImport source="sync" sortByOrder={'DESC'} />,
}),
[isDesktop, isXsmall],
)