71 lines
1.9 KiB
JavaScript
71 lines
1.9 KiB
JavaScript
import { defaultDataIdFromObject } from 'apollo-cache-inmemory';
|
|
import Vue from 'vue';
|
|
import VueApollo from 'vue-apollo';
|
|
import createDefaultClient from '~/lib/graphql';
|
|
import { parseBoolean } from '~/lib/utils/common_utils';
|
|
import { PAGE_CONFIG } from '~/vue_shared/alert_details/constants';
|
|
import AlertManagementList from './components/alert_management_list_wrapper.vue';
|
|
|
|
Vue.use(VueApollo);
|
|
|
|
export default () => {
|
|
const selector = '#js-alert_management';
|
|
|
|
const domEl = document.querySelector(selector);
|
|
const {
|
|
projectPath,
|
|
enableAlertManagementPath,
|
|
emptyAlertSvgPath,
|
|
populatingAlertsHelpUrl,
|
|
alertsHelpUrl,
|
|
textQuery,
|
|
assigneeUsernameQuery,
|
|
alertManagementEnabled,
|
|
userCanEnableAlertManagement,
|
|
} = domEl.dataset;
|
|
|
|
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);
|
|
},
|
|
},
|
|
},
|
|
),
|
|
});
|
|
|
|
apolloProvider.clients.defaultClient.cache.writeData({
|
|
data: {
|
|
alertsHelpUrl,
|
|
},
|
|
});
|
|
|
|
return new Vue({
|
|
el: selector,
|
|
components: {
|
|
AlertManagementList,
|
|
},
|
|
provide: {
|
|
projectPath,
|
|
textQuery,
|
|
assigneeUsernameQuery,
|
|
enableAlertManagementPath,
|
|
populatingAlertsHelpUrl,
|
|
emptyAlertSvgPath,
|
|
alertManagementEnabled: parseBoolean(alertManagementEnabled),
|
|
trackAlertStatusUpdateOptions: PAGE_CONFIG.OPERATIONS.TRACK_ALERT_STATUS_UPDATE_OPTIONS,
|
|
userCanEnableAlertManagement: parseBoolean(userCanEnableAlertManagement),
|
|
},
|
|
apolloProvider,
|
|
render(createElement) {
|
|
return createElement('alert-management-list');
|
|
},
|
|
});
|
|
};
|