debian-mirror-gitlab/app/assets/javascripts/jira_connect/subscriptions/index.js
2021-10-27 15:23:28 +05:30

52 lines
1.3 KiB
JavaScript

import '../../webpack';
import setConfigs from '@gitlab/ui/dist/config';
import Vue from 'vue';
import GlFeatureFlagsPlugin from '~/vue_shared/gl_feature_flags_plugin';
import Translate from '~/vue_shared/translate';
import JiraConnectApp from './components/app.vue';
import createStore from './store';
import { getLocation, sizeToParent } from './utils';
const store = createStore();
const updateSignInLinks = async () => {
const location = await getLocation();
Array.from(document.querySelectorAll('.js-jira-connect-sign-in')).forEach((el) => {
const updatedLink = `${el.getAttribute('href')}?return_to=${location}`;
el.setAttribute('href', updatedLink);
});
};
export async function initJiraConnect() {
await updateSignInLinks();
const el = document.querySelector('.js-jira-connect-app');
if (!el) {
return null;
}
setConfigs();
Vue.use(Translate);
Vue.use(GlFeatureFlagsPlugin);
const { groupsPath, subscriptions, subscriptionsPath, usersPath } = el.dataset;
sizeToParent();
return new Vue({
el,
store,
provide: {
groupsPath,
subscriptions: JSON.parse(subscriptions),
subscriptionsPath,
usersPath,
},
render(createElement) {
return createElement(JiraConnectApp);
},
});
}
document.addEventListener('DOMContentLoaded', initJiraConnect);