1
1
mirror of https://github.com/go-gitea/gitea synced 2024-11-01 15:54:25 +00:00
gitea/web_src/js/features/contextpopup.js
zeripath 6a025d8b4a
Do not show issue context popup on external issues (#17050) (#17054)
Backport #17050

The issues pop-up context cannot work for external issues - therefore do not show
these.

Fix #17047

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-15 17:38:20 +08:00

47 lines
1.1 KiB
JavaScript

import Vue from 'vue';
import ContextPopup from '../components/ContextPopup.vue';
export default function initContextPopups() {
const refIssues = $('.ref-issue');
if (!refIssues.length) return;
refIssues.each(function () {
if ($(this).hasClass('ref-external-issue')) {
return;
}
const [index, _issues, repo, owner] = $(this).attr('href').replace(/[#?].*$/, '').split('/').reverse();
const el = document.createElement('div');
el.className = 'ui custom popup hidden';
el.innerHTML = '<div></div>';
this.parentNode.insertBefore(el, this.nextSibling);
const View = Vue.extend({
render: (createElement) => createElement(ContextPopup),
});
const view = new View();
try {
view.$mount(el.firstChild);
} catch (err) {
console.error(err);
el.textContent = 'ContextPopup failed to load';
}
$(this).popup({
variation: 'wide',
delay: {
show: 250
},
onShow: () => {
view.$emit('load-context-popup', {owner, repo, index}, () => {
$(this).popup('reposition');
});
},
popup: $(el),
});
});
}