diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-26 18:10:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-26 18:10:36 +0300 |
commit | 2dd743014e205233b13dfff29fda20243bc1fbc5 (patch) | |
tree | 5e5bcf661236bf02934b06c4dd823d408437a17c /app/assets/javascripts/webhooks | |
parent | 5c5929e77af0809f29531d02bf9f6e0f6f286bcd (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/webhooks')
-rw-r--r-- | app/assets/javascripts/webhooks/components/test_dropdown.vue | 45 |
1 files changed, 8 insertions, 37 deletions
diff --git a/app/assets/javascripts/webhooks/components/test_dropdown.vue b/app/assets/javascripts/webhooks/components/test_dropdown.vue index 78e5dff6f59..90a8a7aa3e6 100644 --- a/app/assets/javascripts/webhooks/components/test_dropdown.vue +++ b/app/assets/javascripts/webhooks/components/test_dropdown.vue @@ -19,45 +19,16 @@ export default { }, }, computed: { - itemsWithAction() { - return this.items.map((item) => ({ - text: item.text, - action: () => this.testHook(item.href), + webhookTriggers() { + return this.items.map(({ text, href }) => ({ + text, + href, + extraAttrs: { + 'data-method': 'post', + }, })); }, }, - methods: { - testHook(href) { - // HACK: Trigger @rails/ujs's data-method handling. - // - // The more obvious approaches of (1) declaratively rendering the - // links using GlDisclosureDropdown's list-item slot and (2) using - // item.extraAttrs to set the data-method attributes on the links - // do not work for reasons laid out in - // https://gitlab.com/gitlab-org/gitlab-ui/-/issues/2134. - // - // Sending the POST with axios also doesn't work, since the - // endpoints return 302 redirects. Since axios uses XMLHTTPRequest, - // it transparently follows redirects, meaning the Location header - // of the first response cannot be inspected/acted upon by JS. We - // could manually trigger a reload afterwards, but that would mean - // a duplicate fetch of the current page: one by the XHR, and one - // by the explicit reload. It would also mean losing the flash - // alert set by the backend, making the feature useless for the - // user. - // - // The ideal fix here would be to refactor the test endpoint to - // return a JSON response, removing the need for a redirect/page - // reload to show the result. - const a = document.createElement('a'); - a.setAttribute('hidden', ''); - a.href = href; - a.dataset.method = 'post'; - document.body.appendChild(a); - a.click(); - a.remove(); - }, - }, i18n: { test: __('Test'), }, @@ -65,5 +36,5 @@ export default { </script> <template> - <gl-disclosure-dropdown :toggle-text="$options.i18n.test" :items="itemsWithAction" :size="size" /> + <gl-disclosure-dropdown :toggle-text="$options.i18n.test" :items="webhookTriggers" :size="size" /> </template> |