Skip to content

Commit 824d976

Browse files
committed
Disable playlist export buttons instead of hiding them
I think for now it is nicer to keep the same UI when not logged in but disable the buttons if missing appropriate credentials. Maybe we will revisit this when we have more music services in there so as not to overload the menu with a bunch of options the user can't click on.
1 parent b0e39c1 commit 824d976

File tree

1 file changed

+31
-32
lines changed

1 file changed

+31
-32
lines changed

Diff for: frontend/js/src/playlists/components/PlaylistMenu.tsx

+31-32
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { useContext } from "react";
1515
import { toast } from "react-toastify";
1616
import NiceModal from "@ebay/nice-modal-react";
1717
import { Link } from "react-router-dom";
18+
import { noop } from "lodash";
1819
import { ToastMsg } from "../../notifications/Notifications";
1920
import GlobalAppContext from "../../utils/GlobalAppContext";
2021
import { getPlaylistId, isPlaylistOwner } from "../utils";
@@ -220,16 +221,16 @@ function PlaylistMenu({
220221
}
221222
};
222223
const isLoggedIn = Boolean(currentUser?.name);
223-
const showSpotifyExportButton =
224+
const enableSpotifyExport =
224225
isLoggedIn && spotifyAuth?.permission?.includes("playlist-modify-public");
225-
const showAppleMusicExportButton = isLoggedIn && appleAuth?.music_user_token;
226+
const enableAppleMusicExport = isLoggedIn && appleAuth?.music_user_token;
226227
return (
227228
<ul
228229
className="dropdown-menu dropdown-menu-right"
229230
aria-labelledby="playlistOptionsDropdown"
230231
>
231-
<li>
232-
<a onClick={copyPlaylist} role="button" href="#">
232+
<li className={!isLoggedIn ? "disabled" : ""}>
233+
<a onClick={isLoggedIn ? copyPlaylist : noop} role="button" href="#">
233234
<FontAwesomeIcon icon={faCopy as IconProp} />{" "}
234235
{playlistID ? "Duplicate" : "Save to my playlists"}
235236
</a>
@@ -281,34 +282,32 @@ function PlaylistMenu({
281282
</li>
282283
</>
283284
)}
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>
312311
<li role="separator" className="divider" />
313312
<li>
314313
<a

0 commit comments

Comments
 (0)