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

74 lines
1.9 KiB
JavaScript
Raw Normal View History

2020-05-24 23:13:21 +05:30
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import { defaultDataIdFromObject } from 'apollo-cache-inmemory';
2020-10-24 23:57:45 +05:30
import createDefaultClient from '~/lib/graphql';
2020-05-24 23:13:21 +05:30
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,
2020-10-24 23:57:45 +05:30
alertsHelpUrl,
2020-07-28 23:09:34 +05:30
opsgenieMvcTargetUrl,
2021-01-03 14:25:43 +05:30
textQuery,
assigneeUsernameQuery,
alertManagementEnabled,
userCanEnableAlertManagement,
opsgenieMvcEnabled,
2020-07-28 23:09:34 +05:30
} = 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);
},
},
},
),
});
2020-10-24 23:57:45 +05:30
apolloProvider.clients.defaultClient.cache.writeData({
data: {
alertsHelpUrl,
},
});
2020-05-24 23:13:21 +05:30
return new Vue({
el: selector,
2021-01-03 14:25:43 +05:30
provide: {
projectPath,
textQuery,
assigneeUsernameQuery,
enableAlertManagementPath,
populatingAlertsHelpUrl,
emptyAlertSvgPath,
opsgenieMvcTargetUrl,
alertManagementEnabled: parseBoolean(alertManagementEnabled),
userCanEnableAlertManagement: parseBoolean(userCanEnableAlertManagement),
opsgenieMvcEnabled: parseBoolean(opsgenieMvcEnabled),
},
2020-05-24 23:13:21 +05:30
apolloProvider,
components: {
AlertManagementList,
},
render(createElement) {
2021-01-03 14:25:43 +05:30
return createElement('alert-management-list');
2020-05-24 23:13:21 +05:30
},
});
};