mirror of
https://github.com/koel/koel
synced 2024-12-23 19:13:06 +00:00
27 lines
1.1 KiB
Vue
27 lines
1.1 KiB
Vue
<template>
|
|
<ContextMenuBase ref="base">
|
|
<li data-testid="playlist-context-menu-create-simple" @click="onItemClicked('new-playlist')">New Playlist…</li>
|
|
<li data-testid="playlist-context-menu-create-smart" @click="onItemClicked('new-smart-playlist')">
|
|
New Smart Playlist…
|
|
</li>
|
|
<li data-testid="playlist-context-menu-create-folder" @click="onItemClicked('new-folder')">New Folder…</li>
|
|
</ContextMenuBase>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { useContextMenu } from '@/composables'
|
|
import { eventBus } from '@/utils'
|
|
import { Events } from '@/config'
|
|
|
|
const { base, ContextMenuBase, open, trigger } = useContextMenu()
|
|
|
|
const actionToEventMap: Record<string, keyof Events> = {
|
|
'new-playlist': 'MODAL_SHOW_CREATE_PLAYLIST_FORM',
|
|
'new-smart-playlist': 'MODAL_SHOW_CREATE_SMART_PLAYLIST_FORM',
|
|
'new-folder': 'MODAL_SHOW_CREATE_PLAYLIST_FOLDER_FORM'
|
|
}
|
|
|
|
const onItemClicked = (key: keyof typeof actionToEventMap) => trigger(() => eventBus.emit(actionToEventMap[key]))
|
|
|
|
eventBus.on('CREATE_NEW_PLAYLIST_CONTEXT_MENU_REQUESTED', async ({ top, left }) => await open(top, left))
|
|
</script>
|