2020-04-21 11:21:10 -04:00
|
|
|
import Vue from 'vue';
|
2020-04-24 14:09:46 -04:00
|
|
|
import VueApollo from 'vue-apollo';
|
|
|
|
import createDefaultClient from '~/lib/graphql';
|
2020-05-13 14:08:47 -04:00
|
|
|
import { defaultDataIdFromObject } from 'apollo-cache-inmemory';
|
2020-04-27 14:09:41 -04:00
|
|
|
import { parseBoolean } from '~/lib/utils/common_utils';
|
2020-07-10 11:09:07 -04:00
|
|
|
import AlertManagementList from './components/alert_management_list_wrapper.vue';
|
2020-04-21 11:21:10 -04:00
|
|
|
|
2020-04-24 14:09:46 -04:00
|
|
|
Vue.use(VueApollo);
|
|
|
|
|
2020-04-21 11:21:10 -04:00
|
|
|
export default () => {
|
|
|
|
const selector = '#js-alert_management';
|
|
|
|
|
|
|
|
const domEl = document.querySelector(selector);
|
2020-06-17 20:08:35 -04:00
|
|
|
const {
|
|
|
|
projectPath,
|
|
|
|
enableAlertManagementPath,
|
|
|
|
emptyAlertSvgPath,
|
|
|
|
populatingAlertsHelpUrl,
|
2020-07-15 02:09:35 -04:00
|
|
|
opsgenieMvcTargetUrl,
|
2020-06-17 20:08:35 -04:00
|
|
|
} = domEl.dataset;
|
2020-07-15 02:09:35 -04:00
|
|
|
let { alertManagementEnabled, userCanEnableAlertManagement, opsgenieMvcEnabled } = domEl.dataset;
|
2020-04-27 14:09:41 -04:00
|
|
|
|
|
|
|
alertManagementEnabled = parseBoolean(alertManagementEnabled);
|
|
|
|
userCanEnableAlertManagement = parseBoolean(userCanEnableAlertManagement);
|
2020-07-15 02:09:35 -04:00
|
|
|
opsgenieMvcEnabled = parseBoolean(opsgenieMvcEnabled);
|
2020-04-21 11:21:10 -04:00
|
|
|
|
2020-04-24 14:09:46 -04:00
|
|
|
const apolloProvider = new VueApollo({
|
2020-05-13 14:08:47 -04:00
|
|
|
defaultClient: createDefaultClient(
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
cacheConfig: {
|
|
|
|
dataIdFromObject: object => {
|
|
|
|
// eslint-disable-next-line no-underscore-dangle
|
|
|
|
if (object.__typename === 'AlertManagementAlert') {
|
|
|
|
return object.iid;
|
|
|
|
}
|
|
|
|
return defaultDataIdFromObject(object);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
2020-04-24 14:09:46 -04:00
|
|
|
});
|
|
|
|
|
2020-04-21 11:21:10 -04:00
|
|
|
return new Vue({
|
|
|
|
el: selector,
|
2020-04-24 14:09:46 -04:00
|
|
|
apolloProvider,
|
2020-04-21 11:21:10 -04:00
|
|
|
components: {
|
|
|
|
AlertManagementList,
|
|
|
|
},
|
|
|
|
render(createElement) {
|
|
|
|
return createElement('alert-management-list', {
|
|
|
|
props: {
|
2020-04-30 08:09:45 -04:00
|
|
|
projectPath,
|
2020-04-21 11:21:10 -04:00
|
|
|
enableAlertManagementPath,
|
2020-06-17 20:08:35 -04:00
|
|
|
populatingAlertsHelpUrl,
|
2020-04-21 11:21:10 -04:00
|
|
|
emptyAlertSvgPath,
|
2020-04-27 14:09:41 -04:00
|
|
|
alertManagementEnabled,
|
|
|
|
userCanEnableAlertManagement,
|
2020-07-15 02:09:35 -04:00
|
|
|
opsgenieMvcTargetUrl,
|
|
|
|
opsgenieMvcEnabled,
|
2020-04-21 11:21:10 -04:00
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|