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