mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-02-03 16:59:41 +00:00
Update PluginManager to singleton, update PluginContext, support prompt object in plugin extension
This commit is contained in:
parent
a762e6ca03
commit
50e84fc2d5
14 changed files with 121 additions and 45 deletions
|
|
@ -786,13 +786,35 @@ export default {
|
|||
}
|
||||
},
|
||||
onPluginAction(pluginId, pluginAction) {
|
||||
const plugin = this.pluginExtensions.find((p) => p.id === pluginId)
|
||||
const extension = plugin.extensions.find((ext) => ext.name === pluginAction)
|
||||
|
||||
if (extension.prompt) {
|
||||
const payload = {
|
||||
message: extension.prompt.message,
|
||||
formFields: extension.prompt.formFields || [],
|
||||
callback: (confirmed, promptData) => {
|
||||
if (confirmed) {
|
||||
this.sendPluginAction(pluginId, pluginAction, promptData)
|
||||
}
|
||||
},
|
||||
type: 'yesNo'
|
||||
}
|
||||
this.$store.commit('globals/setConfirmPrompt', payload)
|
||||
} else {
|
||||
this.sendPluginAction(pluginId, pluginAction)
|
||||
}
|
||||
},
|
||||
sendPluginAction(pluginId, pluginAction, promptData = null) {
|
||||
this.$axios
|
||||
.$post(`/api/plugins/${pluginId}/action`, {
|
||||
pluginAction,
|
||||
target: 'item.detail.actions',
|
||||
data: {
|
||||
entityId: this.libraryItemId,
|
||||
entityType: 'libraryItem'
|
||||
entityType: 'libraryItem',
|
||||
userId: this.$store.state.user.user.id,
|
||||
promptData
|
||||
}
|
||||
})
|
||||
.then((data) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue