debian-mirror-gitlab/app/assets/javascripts/jira_connect/index.js

51 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-03-08 18:12:59 +05:30
import setConfigs from '@gitlab/ui/dist/config';
2021-03-11 19:13:27 +05:30
import Vue from 'vue';
2021-04-29 21:17:54 +05:30
import { getLocation, sizeToParent } from '~/jira_connect/utils';
2021-03-08 18:12:59 +05:30
import GlFeatureFlagsPlugin from '~/vue_shared/gl_feature_flags_plugin';
2021-03-11 19:13:27 +05:30
import Translate from '~/vue_shared/translate';
2021-03-08 18:12:59 +05:30
import JiraConnectApp from './components/app.vue';
import createStore from './store';
const store = createStore();
2021-02-22 17:27:13 +05:30
2021-03-11 19:13:27 +05:30
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);
2021-02-22 17:27:13 +05:30
});
2021-03-11 19:13:27 +05:30
};
export async function initJiraConnect() {
await updateSignInLinks();
2021-02-22 17:27:13 +05:30
2021-03-11 19:13:27 +05:30
const el = document.querySelector('.js-jira-connect-app');
2021-03-08 18:12:59 +05:30
if (!el) {
return null;
}
setConfigs();
Vue.use(Translate);
Vue.use(GlFeatureFlagsPlugin);
2021-04-29 21:17:54 +05:30
const { groupsPath, subscriptions, subscriptionsPath, usersPath } = el.dataset;
sizeToParent();
2021-03-08 18:12:59 +05:30
2021-01-29 00:20:46 +05:30
return new Vue({
el,
2021-03-08 18:12:59 +05:30
store,
provide: {
groupsPath,
2021-04-29 21:17:54 +05:30
subscriptions: JSON.parse(subscriptions),
2021-03-11 19:13:27 +05:30
subscriptionsPath,
usersPath,
2021-02-22 17:27:13 +05:30
},
2021-01-29 00:20:46 +05:30
render(createElement) {
2021-03-08 18:12:59 +05:30
return createElement(JiraConnectApp);
2021-01-29 00:20:46 +05:30
},
});
}
document.addEventListener('DOMContentLoaded', initJiraConnect);