Browse Source

fix(EditPlaylist): edit/report/addtoplaylist icons should only show if user is correctly authenticated

Signed-off-by: Jonathan <theflametrooper@gmail.com>
Jonathan 4 years ago
parent
commit
bd49247f02

+ 7 - 1
frontend/src/components/modals/EditPlaylist/components/PlaylistSongItem.vue

@@ -33,6 +33,7 @@
 			<slot name="actions" />
 			<i
 				class="material-icons"
+				v-if="loggedIn"
 				@click="showPlaylistDropdown = !showPlaylistDropdown"
 			>
 				queue
@@ -42,6 +43,8 @@
 </template>
 
 <script>
+import { mapState } from "vuex";
+
 import AddToPlaylistDropdown from "../../../ui/AddToPlaylistDropdown.vue";
 
 export default {
@@ -56,7 +59,10 @@ export default {
 		return {
 			showPlaylistDropdown: false
 		};
-	}
+	},
+	computed: mapState({
+		loggedIn: state => state.user.auth.loggedIn
+	})
 };
 </script>
 

+ 13 - 4
frontend/src/components/modals/EditPlaylist/index.vue

@@ -277,7 +277,10 @@
 											>
 
 											<i
-												v-if="!song.simpleSong"
+												v-if="
+													!song.simpleSong &&
+														userRole === 'admin'
+												"
 												class="material-icons report-icon"
 												@click="
 													reportSongInPlaylist(song)
@@ -285,8 +288,12 @@
 											>
 												flag
 											</i>
+
 											<i
-												v-if="!song.simpleSong"
+												v-if="
+													!song.simpleSong &&
+														userRole === 'admin'
+												"
 												class="material-icons edit-icon"
 												@click="
 													editSongInPlaylist(song)
@@ -382,12 +389,14 @@ export default {
 			playlist: { songs: [] }
 		};
 	},
-
 	computed: {
 		...mapState("user/playlists", {
 			editing: state => state.editing
 		}),
-		...mapState({ userId: state => state.user.auth.userId }),
+		...mapState({
+			userId: state => state.user.auth.userId,
+			userRole: state => state.user.auth.role
+		}),
 		dragOptions() {
 			return {
 				animation: 200,