From 9b4abd9e5a1b5111bc127bfd96041c39ec78e206 Mon Sep 17 00:00:00 2001 From: Caio Cotts Date: Fri, 7 Jun 2024 21:24:11 -0400 Subject: [PATCH] Add Auto-Import toggle switch to playlists list view. --- ui/src/playlist/PlaylistList.js | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) 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 ? ( + + ) : null +} + const PlaylistListBulkActions = (props) => ( <> @@ -107,6 +140,7 @@ const PlaylistList = (props) => { ), comment: , + sync: , }), [isDesktop, isXsmall], )