debian-mirror-gitlab/app/assets/javascripts/alerts_settings/index.js

68 lines
1.7 KiB
JavaScript
Raw Normal View History

2021-01-29 00:20:46 +05:30
import { GlToast } from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import Vue from 'vue';
2021-09-04 01:27:46 +05:30
import IncidentsSettingsService from '~/incidents_settings/incidents_settings_service';
2020-07-28 23:09:34 +05:30
import { parseBoolean } from '~/lib/utils/common_utils';
2021-01-29 00:20:46 +05:30
import AlertSettingsWrapper from './components/alerts_settings_wrapper.vue';
import apolloProvider from './graphql';
2021-04-29 21:17:54 +05:30
import getCurrentIntegrationQuery from './graphql/queries/get_current_integration.query.graphql';
2021-01-29 00:20:46 +05:30
2021-04-29 21:17:54 +05:30
apolloProvider.clients.defaultClient.cache.writeQuery({
query: getCurrentIntegrationQuery,
2021-01-29 00:20:46 +05:30
data: {
currentIntegration: null,
},
});
2021-04-29 21:17:54 +05:30
2021-01-29 00:20:46 +05:30
Vue.use(GlToast);
2020-07-28 23:09:34 +05:30
2021-03-08 18:12:59 +05:30
export default (el) => {
2020-07-28 23:09:34 +05:30
if (!el) {
return null;
}
2021-09-04 01:27:46 +05:30
const {
alertsUsageUrl,
projectPath,
multiIntegrations,
alertFields,
templates,
createIssue,
issueTemplateKey,
sendEmail,
autoCloseIncident,
pagerdutyResetKeyPath,
operationsSettingsEndpoint,
} = el.dataset;
2020-07-28 23:09:34 +05:30
2021-09-04 01:27:46 +05:30
const service = new IncidentsSettingsService(operationsSettingsEndpoint, pagerdutyResetKeyPath);
2020-07-28 23:09:34 +05:30
return new Vue({
el,
2021-03-08 18:12:59 +05:30
components: {
AlertSettingsWrapper,
},
2020-10-24 23:57:45 +05:30
provide: {
2021-09-04 01:27:46 +05:30
service,
alertSettings: {
templates: JSON.parse(templates),
createIssue: parseBoolean(createIssue),
issueTemplateKey,
sendEmail: parseBoolean(sendEmail),
autoCloseIncident: parseBoolean(autoCloseIncident),
pagerdutyResetKeyPath,
operationsSettingsEndpoint,
},
2021-04-29 21:17:54 +05:30
alertsUsageUrl,
2021-01-29 00:20:46 +05:30
projectPath,
multiIntegrations: parseBoolean(multiIntegrations),
2020-10-24 23:57:45 +05:30
},
2021-01-29 00:20:46 +05:30
apolloProvider,
2020-07-28 23:09:34 +05:30
render(createElement) {
2021-03-11 19:13:27 +05:30
return createElement('alert-settings-wrapper', {
props: {
2021-04-17 20:07:23 +05:30
alertFields: parseBoolean(multiIntegrations) ? JSON.parse(alertFields) : null,
2021-03-11 19:13:27 +05:30
},
});
2020-07-28 23:09:34 +05:30
},
});
};