mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Add edit permission check for adding to playlist
This commit is contained in:
parent
850ac3837a
commit
e13f0ba234
1 changed files with 29 additions and 2 deletions
|
@ -149,6 +149,31 @@ function populatePlaylists(editorOptions: PlaylistEditorOptions, panel: DialogEl
|
||||||
recursive: true
|
recursive: true
|
||||||
})
|
})
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
|
return Promise.all((data.Items || []).map(item => {
|
||||||
|
const playlist = {
|
||||||
|
item,
|
||||||
|
permissions: undefined
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!item.Id) return playlist;
|
||||||
|
|
||||||
|
return getPlaylistsApi(api)
|
||||||
|
.getPlaylistUser({
|
||||||
|
playlistId: item.Id,
|
||||||
|
userId: apiClient.getCurrentUserId()
|
||||||
|
})
|
||||||
|
.then(({ data: permissions }) => ({
|
||||||
|
...playlist,
|
||||||
|
permissions
|
||||||
|
}))
|
||||||
|
.catch((err) => {
|
||||||
|
console.warn('[PlaylistEditor] Failed to fetch playlist permissions', err);
|
||||||
|
|
||||||
|
return playlist;
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
})
|
||||||
|
.then(playlists => {
|
||||||
let html = '';
|
let html = '';
|
||||||
|
|
||||||
if ((editorOptions.enableAddToPlayQueue !== false && playbackManager.isPlaying()) || SyncPlay?.Manager.isSyncPlayEnabled()) {
|
if ((editorOptions.enableAddToPlayQueue !== false && playbackManager.isPlaying()) || SyncPlay?.Manager.isSyncPlayEnabled()) {
|
||||||
|
@ -157,8 +182,10 @@ function populatePlaylists(editorOptions: PlaylistEditorOptions, panel: DialogEl
|
||||||
|
|
||||||
html += `<option value="">${globalize.translate('OptionNew')}</option>`;
|
html += `<option value="">${globalize.translate('OptionNew')}</option>`;
|
||||||
|
|
||||||
html += data.Items?.map(i => {
|
html += playlists.map(({ item, permissions }) => {
|
||||||
return `<option value="${i.Id}">${escapeHtml(i.Name)}</option>`;
|
if (!permissions?.CanEdit) return '';
|
||||||
|
|
||||||
|
return `<option value="${item.Id}">${escapeHtml(item.Name)}</option>`;
|
||||||
});
|
});
|
||||||
|
|
||||||
select.innerHTML = html;
|
select.innerHTML = html;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue