@@ -15,6 +15,7 @@ import { useContext } from "react";
15
15
import { toast } from "react-toastify" ;
16
16
import NiceModal from "@ebay/nice-modal-react" ;
17
17
import { Link } from "react-router-dom" ;
18
+ import { noop } from "lodash" ;
18
19
import { ToastMsg } from "../../notifications/Notifications" ;
19
20
import GlobalAppContext from "../../utils/GlobalAppContext" ;
20
21
import { getPlaylistId , isPlaylistOwner } from "../utils" ;
@@ -220,16 +221,16 @@ function PlaylistMenu({
220
221
}
221
222
} ;
222
223
const isLoggedIn = Boolean ( currentUser ?. name ) ;
223
- const showSpotifyExportButton =
224
+ const enableSpotifyExport =
224
225
isLoggedIn && spotifyAuth ?. permission ?. includes ( "playlist-modify-public" ) ;
225
- const showAppleMusicExportButton = isLoggedIn && appleAuth ?. music_user_token ;
226
+ const enableAppleMusicExport = isLoggedIn && appleAuth ?. music_user_token ;
226
227
return (
227
228
< ul
228
229
className = "dropdown-menu dropdown-menu-right"
229
230
aria-labelledby = "playlistOptionsDropdown"
230
231
>
231
- < li >
232
- < a onClick = { copyPlaylist } role = "button" href = "#" >
232
+ < li className = { ! isLoggedIn ? "disabled" : "" } >
233
+ < a onClick = { isLoggedIn ? copyPlaylist : noop } role = "button" href = "#" >
233
234
< FontAwesomeIcon icon = { faCopy as IconProp } /> { " " }
234
235
{ playlistID ? "Duplicate" : "Save to my playlists" }
235
236
</ a >
@@ -281,34 +282,32 @@ function PlaylistMenu({
281
282
</ li >
282
283
</ >
283
284
) }
284
- { ( showSpotifyExportButton || showAppleMusicExportButton ) && (
285
- < li role = "separator" className = "divider" />
286
- ) }
287
- { showSpotifyExportButton && (
288
- < li >
289
- < a
290
- id = "exportPlaylistToSpotify"
291
- role = "button"
292
- href = "#"
293
- onClick = { ( ) => handlePlaylistExport ( exportToSpotify ) }
294
- >
295
- < FontAwesomeIcon icon = { faSpotify as IconProp } /> Export to Spotify
296
- </ a >
297
- </ li >
298
- ) }
299
- { showAppleMusicExportButton && (
300
- < li >
301
- < a
302
- id = "exportPlaylistToAppleMusic"
303
- role = "button"
304
- href = "#"
305
- onClick = { ( ) => handlePlaylistExport ( exportToAppleMusic ) }
306
- >
307
- < FontAwesomeIcon icon = { faItunesNote as IconProp } /> Export to Apple
308
- Music
309
- </ a >
310
- </ li >
311
- ) }
285
+ < li role = "separator" className = "divider" />
286
+ < li className = { enableSpotifyExport ? "" : "disabled" } >
287
+ < a
288
+ id = "exportPlaylistToSpotify"
289
+ role = "button"
290
+ href = "#"
291
+ onClick = { ( ) =>
292
+ enableSpotifyExport && handlePlaylistExport ( exportToSpotify )
293
+ }
294
+ >
295
+ < FontAwesomeIcon icon = { faSpotify as IconProp } /> Export to Spotify
296
+ </ a >
297
+ </ li >
298
+ < li className = { enableAppleMusicExport ? "" : "disabled" } >
299
+ < a
300
+ id = "exportPlaylistToAppleMusic"
301
+ role = "button"
302
+ href = "#"
303
+ onClick = { ( ) =>
304
+ enableAppleMusicExport && handlePlaylistExport ( exportToAppleMusic )
305
+ }
306
+ >
307
+ < FontAwesomeIcon icon = { faItunesNote as IconProp } /> Export to Apple
308
+ Music
309
+ </ a >
310
+ </ li >
312
311
< li role = "separator" className = "divider" />
313
312
< li >
314
313
< a
0 commit comments