Skip to content

Commit 7892a28

Browse files
committed
Update masthead webhook loading
1 parent 31d0f63 commit 7892a28

File tree

5 files changed

+44
-47
lines changed

5 files changed

+44
-47
lines changed

client/src/components/Common/Webhook.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<script setup lang="ts">
2+
import { onMounted, ref } from "vue";
3+
24
import { appendScriptStyle } from "@/utils/utils";
35
import { loadWebhooks, pickWebhook } from "@/utils/webhooks";
4-
import { onMounted, ref } from "vue";
56
67
interface Props {
78
type: string;

client/src/components/Masthead/Masthead.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { setupMockConfig } from "tests/jest/mockConfig";
99

1010
import { useUserStore } from "@/stores/userStore";
1111

12-
import { loadWebhookMenuItems } from "./_webhooks";
12+
import { loadMastheadWebhooks } from "./_webhooks";
1313

1414
import Masthead from "./Masthead.vue";
1515

@@ -38,7 +38,7 @@ describe("Masthead.vue", () => {
3838
});
3939
}
4040

41-
loadWebhookMenuItems.mockImplementation(stubLoadWebhooks);
41+
loadMastheadWebhooks.mockImplementation(stubLoadWebhooks);
4242

4343
beforeEach(async () => {
4444
localVue = getLocalVue();

client/src/components/Masthead/Masthead.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { useRouter } from "vue-router/composables";
99
import { useConfig } from "@/composables/config";
1010
import { useUserStore } from "@/stores/userStore";
1111
12-
import { loadWebhookMenuItems } from "./_webhooks";
12+
import { loadMastheadWebhooks } from "./_webhooks";
1313
import MastheadDropdown from "./MastheadDropdown";
1414
import MastheadItem from "./MastheadItem";
1515
import QuotaMeter from "./QuotaMeter";
@@ -72,7 +72,7 @@ function onWindowToggle() {
7272
}
7373
7474
onMounted(() => {
75-
loadWebhookMenuItems(extensionTabs.value);
75+
loadMastheadWebhooks(extensionTabs.value);
7676
});
7777
</script>
7878

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
1-
import Utils from "utils/utils";
2-
import Webhooks from "utils/webhooks";
1+
import { appendScriptStyle } from "utils/utils";
2+
import { loadWebhooks } from "utils/webhooks";
33

4-
export function loadWebhookMenuItems(items) {
5-
Webhooks.load({
6-
type: "masthead",
7-
callback: function (webhooks) {
8-
webhooks.forEach((webhook) => {
9-
if (webhook.activate) {
10-
const obj = {
11-
id: webhook.id,
12-
icon: webhook.config.icon,
13-
url: webhook.config.url,
14-
tooltip: webhook.config.tooltip,
15-
/*jslint evil: true */
16-
onclick: webhook.config.function && new Function(webhook.config.function),
17-
target: "_parent",
18-
};
19-
items.push(obj);
20-
// Append masthead script and styles to Galaxy main
21-
Utils.appendScriptStyle(webhook);
22-
}
23-
});
24-
},
4+
export async function loadMastheadWebhooks(items) {
5+
const webhooks = loadWebhooks("masthead");
6+
webhooks.forEach((webhook) => {
7+
if (webhook.activate) {
8+
const obj = {
9+
id: webhook.id,
10+
icon: webhook.config.icon,
11+
url: webhook.config.url,
12+
tooltip: webhook.config.tooltip,
13+
/*jslint evil: true */
14+
onclick: webhook.config.function && new Function(webhook.config.function),
15+
target: "_parent",
16+
};
17+
items.push(obj);
18+
// Append masthead script and styles to Galaxy main
19+
appendScriptStyle(webhook);
20+
}
2521
});
2622
}

client/src/components/Tool/Buttons/ToolOptionsButton.vue

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { faCaretDown, faDownload, faExternalLinkAlt, faLink } from "@fortawesome
55
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
66
import ToolSourceMenuItem from "components/Tool/ToolSourceMenuItem";
77
import { storeToRefs } from "pinia";
8-
import Webhooks from "utils/webhooks";
8+
import { loadWebhooks } from "utils/webhooks";
99
import { computed, ref } from "vue";
1010
1111
import { useUserStore } from "@/stores/userStore";
@@ -37,24 +37,6 @@ const props = defineProps({
3737
3838
const webhookDetails = ref([]);
3939
40-
Webhooks.load({
41-
type: "tool-menu",
42-
callback: (webhooks) => {
43-
webhooks.forEach((webhook) => {
44-
if (webhook.activate && webhook.config.function) {
45-
webhookDetails.value.push({
46-
icon: `fa ${webhook.config.icon}`,
47-
title: webhook.config.title,
48-
onclick: () => {
49-
const func = new Function("options", webhook.config.function);
50-
func(props.options);
51-
},
52-
});
53-
}
54-
});
55-
},
56-
});
57-
5840
const showDownload = computed(() => currentUser.value?.is_admin);
5941
const showLink = computed(() => Boolean(props.sharableUrl));
6042
@@ -73,6 +55,24 @@ function onDownload() {
7355
function onLink() {
7456
openLink(props.sharableUrl);
7557
}
58+
59+
async function loadToolMenuWebhooks() {
60+
const webhooks = await loadWebhooks("tool-menu");
61+
webhooks.forEach((webhook) => {
62+
if (webhook.activate && webhook.config.function) {
63+
webhookDetails.value.push({
64+
icon: `fa ${webhook.config.icon}`,
65+
title: webhook.config.title,
66+
onclick: () => {
67+
const func = new Function("options", webhook.config.function);
68+
func(props.options);
69+
},
70+
});
71+
}
72+
});
73+
}
74+
75+
loadToolMenuWebhooks();
7676
</script>
7777
7878
<template>

0 commit comments

Comments
 (0)