Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

History options menu webhook #1

Open
kjetilkl opened this issue Dec 17, 2020 · 0 comments
Open

History options menu webhook #1

kjetilkl opened this issue Dec 17, 2020 · 0 comments

Comments

@kjetilkl
Copy link
Owner

kjetilkl commented Dec 17, 2020

I have tried to add a custom menu entry to the "history options" menu with a webhook. But although my webhook appears in the menu, nothing happens when I select the menu item.

I notice that in the code for the history options menu, there is a line which seems to be the handler (line 181), but this line is commented out. I believe it has been like this from the very beginning, and I don't know if this is intentional or just an oversight, or if I have completely misunderstood how this webhook is supposed to work.

client/src/mvc/history/options-menu.js

webhooks.each(model => {
    var webhook = model.toJSON();
    if (webhook.activate) {
        webhooks_menu.push({
            html: _l(webhook.config.title),
            // func: function() {},
            anon: true
        });
    }
});

Inspired by the similar "masthead" webhook, I propose to change this line to allow the definition of a function in the webhook config file, which will be run when the user selects the menu item.

client/src/mvc/history/options-menu.js (Alternative 1)

webhooks.each(model => {
    var webhook = model.toJSON();
    if (webhook.activate) {
        webhooks_menu.push({
            html: _l(webhook.config.title),
            func: webhook.config.function && new Function(webhook.config.function)
            anon: true
        });
    }
});

The code above will only try to call the handler function if it is defined in the webhook config file, but the webhook will still be added to the history options menu. The second alternative below will not add the webhook to the menu unless the handler function is defined.

client/src/mvc/history/options-menu.js (Alternative 2)

webhooks.each(model => {
    var webhook = model.toJSON();
    if (webhook.activate && webhook.config.function) {
        webhooks_menu.push({
            html: _l(webhook.config.title),
            func: new Function(webhook.config.function)
            anon: true
        });
    }
});

Here is an example webhook configuration file that just redirects to the Galaxy Community Hub web page.

config/plugins/webhooks/demo/community_hub/config.yml

id: community_hub
type:
  - history-menu
activate: true
title: Galaxy Community Hub

function: >
  window.location.href = "https://galaxyproject.org/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant