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

66 lines
1.8 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 { parseBoolean } from '~/lib/utils/common_utils';
2020-07-28 23:09:34 +05:30
import AlertManagementList from './components/alert_management_list_wrapper.vue';
2020-05-24 23:13:21 +05:30
Vue.use(VueApollo);
export default () => {
const selector = '#js-alert_management';
const domEl = document.querySelector(selector);
2020-07-28 23:09:34 +05:30
const {
projectPath,
enableAlertManagementPath,
emptyAlertSvgPath,
populatingAlertsHelpUrl,
opsgenieMvcTargetUrl,
} = domEl.dataset;
let { alertManagementEnabled, userCanEnableAlertManagement, opsgenieMvcEnabled } = domEl.dataset;
2020-05-24 23:13:21 +05:30
alertManagementEnabled = parseBoolean(alertManagementEnabled);
userCanEnableAlertManagement = parseBoolean(userCanEnableAlertManagement);
2020-07-28 23:09:34 +05:30
opsgenieMvcEnabled = parseBoolean(opsgenieMvcEnabled);
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);
},
},
},
),
});
return new Vue({
el: selector,
apolloProvider,
components: {
AlertManagementList,
},
render(createElement) {
return createElement('alert-management-list', {
props: {
projectPath,
enableAlertManagementPath,
2020-07-28 23:09:34 +05:30
populatingAlertsHelpUrl,
2020-05-24 23:13:21 +05:30
emptyAlertSvgPath,
alertManagementEnabled,
userCanEnableAlertManagement,
2020-07-28 23:09:34 +05:30
opsgenieMvcTargetUrl,
opsgenieMvcEnabled,
2020-05-24 23:13:21 +05:30
},
});
},
});
};