2020-06-24 05:08:32 -04:00
|
|
|
// This application is being moved, please do not touch this files
|
|
|
|
// Please see https://gitlab.com/gitlab-org/gitlab/-/issues/14744#note_364468096 for details
|
|
|
|
|
2020-05-07 08:09:46 -04:00
|
|
|
import $ from 'jquery';
|
|
|
|
import Vue from 'vue';
|
|
|
|
import createRouter from './router';
|
|
|
|
import App from './components/app.vue';
|
|
|
|
import apolloProvider from './graphql';
|
|
|
|
import getDesignListQuery from './graphql/queries/get_design_list.query.graphql';
|
|
|
|
import { DESIGNS_ROUTE_NAME, ROOT_ROUTE_NAME } from './router/constants';
|
|
|
|
|
|
|
|
export default () => {
|
2020-05-12 05:09:31 -04:00
|
|
|
const el = document.querySelector('.js-design-management');
|
2020-05-07 08:09:46 -04:00
|
|
|
const badge = document.querySelector('.js-designs-count');
|
|
|
|
const { issueIid, projectPath, issuePath } = el.dataset;
|
|
|
|
const router = createRouter(issuePath);
|
|
|
|
|
|
|
|
$('.js-issue-tabs').on('shown.bs.tab', ({ target: { id } }) => {
|
|
|
|
if (id === 'designs' && router.currentRoute.name === ROOT_ROUTE_NAME) {
|
|
|
|
router.push({ name: DESIGNS_ROUTE_NAME });
|
|
|
|
} else if (id === 'discussion') {
|
|
|
|
router.push({ name: ROOT_ROUTE_NAME });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
apolloProvider.clients.defaultClient.cache.writeData({
|
|
|
|
data: {
|
|
|
|
projectPath,
|
|
|
|
issueIid,
|
2020-05-15 02:08:40 -04:00
|
|
|
activeDiscussion: {
|
|
|
|
__typename: 'ActiveDiscussion',
|
|
|
|
id: null,
|
|
|
|
source: null,
|
|
|
|
},
|
2020-05-07 08:09:46 -04:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
apolloProvider.clients.defaultClient
|
|
|
|
.watchQuery({
|
|
|
|
query: getDesignListQuery,
|
|
|
|
variables: {
|
|
|
|
fullPath: projectPath,
|
|
|
|
iid: issueIid,
|
|
|
|
atVersion: null,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.subscribe(({ data }) => {
|
|
|
|
if (badge) {
|
|
|
|
badge.textContent = data.project.issue.designCollection.designs.edges.length;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
|
|
|
router,
|
|
|
|
apolloProvider,
|
|
|
|
render(createElement) {
|
|
|
|
return createElement(App);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|