debian-mirror-gitlab/app/assets/javascripts/alert_management/details.js

48 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-05-24 23:13:21 +05:30
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import createDefaultClient from '~/lib/graphql';
import { defaultDataIdFromObject } from 'apollo-cache-inmemory';
import AlertDetails from './components/alert_details.vue';
Vue.use(VueApollo);
export default selector => {
const domEl = document.querySelector(selector);
2020-06-23 00:09:42 +05:30
const { alertId, projectPath, projectIssuesPath } = domEl.dataset;
2020-05-24 23:13:21 +05:30
const apolloProvider = new VueApollo({
defaultClient: createDefaultClient(
{},
{
cacheConfig: {
dataIdFromObject: object => {
// eslint-disable-next-line no-underscore-dangle
if (object.__typename === 'AlertManagementAlert') {
return object.iid;
}
return defaultDataIdFromObject(object);
},
},
},
),
});
// eslint-disable-next-line no-new
new Vue({
el: selector,
apolloProvider,
components: {
AlertDetails,
},
render(createElement) {
return createElement('alert-details', {
props: {
alertId,
projectPath,
2020-06-23 00:09:42 +05:30
projectIssuesPath,
2020-05-24 23:13:21 +05:30
},
});
},
});
};