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

59 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-04-17 20:07:23 +05:30
import Vue from 'vue';
import Translate from '../vue_shared/translate';
import CycleAnalytics from './components/base.vue';
2021-11-11 11:23:49 +05:30
import { DEFAULT_DAYS_TO_DISPLAY } from './constants';
2021-06-08 01:23:25 +05:30
import createStore from './store';
2021-11-11 11:23:49 +05:30
import { calculateFormattedDayInPast } from './utils';
2021-04-17 20:07:23 +05:30
Vue.use(Translate);
export default () => {
2021-06-08 01:23:25 +05:30
const store = createStore();
2021-04-17 20:07:23 +05:30
const el = document.querySelector('#js-cycle-analytics');
2021-09-30 23:02:18 +05:30
const {
noAccessSvgPath,
noDataSvgPath,
requestPath,
fullPath,
projectId,
2021-11-11 11:23:49 +05:30
groupId,
2021-09-30 23:02:18 +05:30
groupPath,
2021-11-11 11:23:49 +05:30
labelsPath,
milestonesPath,
2021-09-30 23:02:18 +05:30
} = el.dataset;
2021-06-08 01:23:25 +05:30
2021-11-11 11:23:49 +05:30
const { now, past } = calculateFormattedDayInPast(DEFAULT_DAYS_TO_DISPLAY);
2021-06-08 01:23:25 +05:30
store.dispatch('initializeVsa', {
2021-09-30 23:02:18 +05:30
projectId: parseInt(projectId, 10),
2021-10-27 15:23:28 +05:30
endpoints: {
requestPath,
fullPath,
2021-11-11 11:23:49 +05:30
labelsPath,
milestonesPath,
groupId: parseInt(groupId, 10),
groupPath,
2021-10-27 15:23:28 +05:30
},
2021-09-30 23:02:18 +05:30
features: {
2021-10-27 15:23:28 +05:30
cycleAnalyticsForGroups: Boolean(gon?.licensed_features?.cycleAnalyticsForGroups),
2021-09-30 23:02:18 +05:30
},
2021-11-11 11:23:49 +05:30
createdBefore: new Date(now),
createdAfter: new Date(past),
2021-06-08 01:23:25 +05:30
});
2021-04-17 20:07:23 +05:30
// eslint-disable-next-line no-new
new Vue({
el,
name: 'CycleAnalytics',
2021-06-08 01:23:25 +05:30
store,
2021-04-17 20:07:23 +05:30
render: (createElement) =>
createElement(CycleAnalytics, {
props: {
noDataSvgPath,
noAccessSvgPath,
2021-09-04 01:27:46 +05:30
fullPath,
2021-04-17 20:07:23 +05:30
},
}),
});
};