Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2021-01-20 22:34:23 +0300
committerRobert Speicher <rspeicher@gmail.com>2021-01-20 22:34:23 +0300
commit6438df3a1e0fb944485cebf07976160184697d72 (patch)
tree00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /app/assets/javascripts/alerts_settings
parent42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff)
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'app/assets/javascripts/alerts_settings')
-rw-r--r--app/assets/javascripts/alerts_settings/components/alert_mapping_builder.vue22
-rw-r--r--app/assets/javascripts/alerts_settings/components/alerts_integrations_list.vue4
-rw-r--r--app/assets/javascripts/alerts_settings/components/alerts_settings_form.vue140
-rw-r--r--app/assets/javascripts/alerts_settings/components/alerts_settings_wrapper.vue41
-rw-r--r--app/assets/javascripts/alerts_settings/constants.js10
-rw-r--r--app/assets/javascripts/alerts_settings/graphql.js2
-rw-r--r--app/assets/javascripts/alerts_settings/index.js18
-rw-r--r--app/assets/javascripts/alerts_settings/utils/cache_updates.js4
8 files changed, 37 insertions, 204 deletions
diff --git a/app/assets/javascripts/alerts_settings/components/alert_mapping_builder.vue b/app/assets/javascripts/alerts_settings/components/alert_mapping_builder.vue
index f6474efcc1f..c52e9f5c264 100644
--- a/app/assets/javascripts/alerts_settings/components/alert_mapping_builder.vue
+++ b/app/assets/javascripts/alerts_settings/components/alert_mapping_builder.vue
@@ -40,6 +40,11 @@ export default {
directives: {
GlTooltip,
},
+ inject: {
+ gitlabAlertFields: {
+ default: gitlabFieldsMock,
+ },
+ },
props: {
payloadFields: {
type: Array,
@@ -57,16 +62,11 @@ export default {
gitlabFields: this.gitlabAlertFields,
};
},
- inject: {
- gitlabAlertFields: {
- default: gitlabFieldsMock,
- },
- },
computed: {
mappingData() {
- return this.gitlabFields.map(gitlabField => {
+ return this.gitlabFields.map((gitlabField) => {
const mappingFields = this.payloadFields.filter(({ type }) =>
- type.some(t => gitlabField.compatibleTypes.includes(t)),
+ type.some((t) => gitlabField.compatibleTypes.includes(t)),
);
const foundMapping = this.mapping.find(
@@ -88,26 +88,26 @@ export default {
},
methods: {
setMapping(gitlabKey, mappingKey, valueKey) {
- const fieldIndex = this.gitlabFields.findIndex(field => field.name === gitlabKey);
+ const fieldIndex = this.gitlabFields.findIndex((field) => field.name === gitlabKey);
const updatedField = { ...this.gitlabFields[fieldIndex], ...{ [valueKey]: mappingKey } };
Vue.set(this.gitlabFields, fieldIndex, updatedField);
},
setSearchTerm(search = '', searchFieldKey, gitlabKey) {
- const fieldIndex = this.gitlabFields.findIndex(field => field.name === gitlabKey);
+ const fieldIndex = this.gitlabFields.findIndex((field) => field.name === gitlabKey);
const updatedField = { ...this.gitlabFields[fieldIndex], ...{ [searchFieldKey]: search } };
Vue.set(this.gitlabFields, fieldIndex, updatedField);
},
filterFields(searchTerm = '', fields) {
const search = searchTerm.toLowerCase();
- return fields.filter(field => field.label.toLowerCase().includes(search));
+ return fields.filter((field) => field.label.toLowerCase().includes(search));
},
isSelected(fieldValue, mapping) {
return fieldValue === mapping;
},
selectedValue(name) {
return (
- this.payloadFields.find(item => item.name === name)?.label ||
+ this.payloadFields.find((item) => item.name === name)?.label ||
this.$options.i18n.makeSelection
);
},
diff --git a/app/assets/javascripts/alerts_settings/components/alerts_integrations_list.vue b/app/assets/javascripts/alerts_settings/components/alerts_integrations_list.vue
index cf16750dbf8..6cfb4601192 100644
--- a/app/assets/javascripts/alerts_settings/components/alerts_integrations_list.vue
+++ b/app/assets/javascripts/alerts_settings/components/alerts_integrations_list.vue
@@ -97,8 +97,8 @@ export default {
};
},
mounted() {
- const callback = entries => {
- const isVisible = entries.some(entry => entry.isIntersecting);
+ const callback = (entries) => {
+ const isVisible = entries.some((entry) => entry.isIntersecting);
if (isVisible) {
this.trackPageViews();
diff --git a/app/assets/javascripts/alerts_settings/components/alerts_settings_form.vue b/app/assets/javascripts/alerts_settings/components/alerts_settings_form.vue
index b2be563522a..1ae7f826ce6 100644
--- a/app/assets/javascripts/alerts_settings/components/alerts_settings_form.vue
+++ b/app/assets/javascripts/alerts_settings/components/alerts_settings_form.vue
@@ -18,14 +18,11 @@ import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
import MappingBuilder from './alert_mapping_builder.vue';
import AlertSettingsFormHelpBlock from './alert_settings_form_help_block.vue';
import getCurrentIntegrationQuery from '../graphql/queries/get_current_integration.query.graphql';
-import service from '../services';
import {
- integrationTypesNew,
+ integrationTypes,
JSON_VALIDATE_DELAY,
targetPrometheusUrlPlaceholder,
- targetOpsgenieUrlPlaceholder,
typeSet,
- sectionHash,
} from '../constants';
// Mocks will be removed when integrating with BE is ready
// data format is defined and will be the same as mocked (maybe with some minor changes)
@@ -91,20 +88,13 @@ export const i18n = {
'AlertSettings|Resetting the authorization key for this project will require updating the authorization key in every alert source it is enabled in.',
),
},
- // TODO: Will be removed in 13.7 as part of: https://gitlab.com/gitlab-org/gitlab/-/issues/273657
- opsgenie: {
- label: s__('AlertSettings|2. Add link to your Opsgenie alert list'),
- info: s__(
- 'AlertSettings|Utilizing this option will link the GitLab Alerts navigation item to your existing Opsgenie instance. By selecting this option, you cannot receive alerts from any other source in GitLab; it will effectively be turning Alerts within GitLab off as a feature.',
- ),
- },
},
};
export default {
+ integrationTypes,
placeholders: {
prometheus: targetPrometheusUrlPlaceholder,
- opsgenie: targetOpsgenieUrlPlaceholder,
},
JSON_VALIDATE_DELAY,
typeSet,
@@ -127,6 +117,7 @@ export default {
directives: {
GlModal: GlModalDirective,
},
+ mixins: [glFeatureFlagsMixin()],
inject: {
generic: {
default: {},
@@ -134,12 +125,7 @@ export default {
prometheus: {
default: {},
},
- // TODO: Will be removed in 13.7 as part of: https://gitlab.com/gitlab-org/gitlab/-/issues/273657
- opsgenie: {
- default: {},
- },
},
- mixins: [glFeatureFlagsMixin()],
props: {
loading: {
type: Boolean,
@@ -149,12 +135,6 @@ export default {
type: Boolean,
required: true,
},
- // TODO: Will be removed in 13.7 as part of: https://gitlab.com/gitlab-org/gitlab/-/issues/273657
- canManageOpsgenie: {
- type: Boolean,
- required: false,
- default: false,
- },
},
apollo: {
currentIntegration: {
@@ -163,7 +143,7 @@ export default {
},
data() {
return {
- selectedIntegration: integrationTypesNew[0].value,
+ selectedIntegration: integrationTypes[0].value,
active: false,
formVisible: false,
integrationTestPayload: {
@@ -174,8 +154,6 @@ export default {
customMapping: null,
parsingPayload: false,
currentIntegration: null,
- // TODO: Will be removed in 13.7 as part of: https://gitlab.com/gitlab-org/gitlab/-/issues/273657
- isManagingOpsgenie: false,
};
},
computed: {
@@ -185,32 +163,12 @@ export default {
jsonIsValid() {
return this.integrationTestPayload.error === null;
},
- // TODO: Will be removed in 13.7 as part of: https://gitlab.com/gitlab-org/gitlab/-/issues/273657
- disabledIntegrations() {
- const options = [];
- if (this.opsgenie.active) {
- options.push(typeSet.http, typeSet.prometheus);
- } else if (!this.canManageOpsgenie) {
- options.push(typeSet.opsgenie);
- }
-
- return options;
- },
- options() {
- return integrationTypesNew.map(el => ({
- ...el,
- disabled: this.disabledIntegrations.includes(el.value),
- }));
- },
selectedIntegrationType() {
switch (this.selectedIntegration) {
case typeSet.http:
return this.generic;
case typeSet.prometheus:
return this.prometheus;
- // TODO: Will be removed in 13.7 as part of: https://gitlab.com/gitlab-org/gitlab/-/issues/273657
- case typeSet.opsgenie:
- return this.opsgenie;
default:
return {};
}
@@ -285,49 +243,17 @@ export default {
},
methods: {
integrationTypeSelect() {
- if (this.selectedIntegration === integrationTypesNew[0].value) {
+ if (this.selectedIntegration === integrationTypes[0].value) {
this.formVisible = false;
} else {
this.formVisible = true;
}
-
- // TODO: Will be removed in 13.7 as part of: https://gitlab.com/gitlab-org/gitlab/-/issues/273657
- if (this.canManageOpsgenie && this.selectedIntegration === typeSet.opsgenie) {
- this.isManagingOpsgenie = true;
- this.active = this.opsgenie.active;
- this.integrationForm.apiUrl = this.opsgenie.opsgenieMvcTargetUrl;
- } else {
- // TODO: Will be removed in 13.7 as part of: https://gitlab.com/gitlab-org/gitlab/-/issues/273657
- this.isManagingOpsgenie = false;
- }
- },
- // TODO: Will be removed in 13.7 as part of: https://gitlab.com/gitlab-org/gitlab/-/issues/273657
- submitWithOpsgenie() {
- return service
- .updateGenericActive({
- endpoint: this.opsgenie.formPath,
- params: {
- service: {
- opsgenie_mvc_target_url: this.integrationForm.apiUrl,
- opsgenie_mvc_enabled: this.active,
- },
- },
- })
- .then(() => {
- window.location.hash = sectionHash;
- window.location.reload();
- });
},
submitWithTestPayload() {
this.$emit('set-test-alert-payload', this.testAlertPayload);
this.submit();
},
submit() {
- // TODO: Will be removed in 13.7 as part of: https://gitlab.com/gitlab-org/gitlab/-/issues/273657
- if (this.isManagingOpsgenie) {
- return this.submitWithOpsgenie();
- }
-
const { name, apiUrl } = this.integrationForm;
const variables =
this.selectedIntegration === typeSet.http
@@ -343,7 +269,7 @@ export default {
return this.$emit('create-new-integration', integrationPayload);
},
reset() {
- this.selectedIntegration = integrationTypesNew[0].value;
+ this.selectedIntegration = integrationTypes[0].value;
this.integrationTypeSelect();
if (this.currentIntegration) {
@@ -360,9 +286,6 @@ export default {
error: null,
};
this.active = false;
-
- // TODO: Will be removed in 13.7 as part of: https://gitlab.com/gitlab-org/gitlab/-/issues/273657
- this.isManagingOpsgenie = false;
},
resetAuthKey() {
if (!this.currentIntegration) {
@@ -390,10 +313,10 @@ export default {
// TODO: replace with real BE mutation when ready;
this.parsingPayload = true;
- return new Promise(resolve => {
+ return new Promise((resolve) => {
setTimeout(() => resolve(mockedCustomMapping), 1000);
})
- .then(res => {
+ .then((res) => {
const mapping = { ...res };
delete mapping.storedMapping;
this.customMapping = res;
@@ -408,7 +331,7 @@ export default {
},
getIntegrationMapping() {
// TODO: replace with real BE mutation when ready;
- return Promise.resolve(mockedCustomMapping).then(res => {
+ return Promise.resolve(mockedCustomMapping).then((res) => {
this.customMapping = res;
this.integrationTestPayload.json = res?.samplePayload.body;
});
@@ -428,8 +351,8 @@ export default {
<gl-form-select
v-model="selectedIntegration"
:disabled="isSelectDisabled"
- :class="{ 'gl-bg-gray-100!': isSelectDisabled }"
- :options="options"
+ class="mw-100"
+ :options="$options.integrationTypes"
@change="integrationTypeSelect"
/>
@@ -441,37 +364,7 @@ export default {
</div>
</gl-form-group>
<gl-collapse v-model="formVisible" class="gl-mt-3">
- <!-- TODO: Will be removed in 13.7 as part of: https://gitlab.com/gitlab-org/gitlab/-/issues/273657 -->
- <div v-if="isManagingOpsgenie">
- <gl-form-group
- id="integration-webhook"
- :label="$options.i18n.integrationFormSteps.opsgenie.label"
- label-for="integration-webhook"
- >
- <span class="gl-my-4">
- {{ $options.i18n.integrationFormSteps.opsgenie.info }}
- </span>
-
- <gl-toggle
- v-model="active"
- :is-loading="loading"
- :label="__('Active')"
- class="gl-my-4 gl-font-weight-normal"
- />
-
- <gl-form-input
- id="opsgenie-opsgenieMvcTargetUrl"
- v-model="integrationForm.apiUrl"
- type="text"
- :placeholder="$options.placeholders.opsgenie"
- />
-
- <span class="gl-text-gray-400 gl-my-1">
- {{ $options.i18n.integrationFormSteps.prometheusFormUrl.help }}
- </span>
- </gl-form-group>
- </div>
- <div v-else>
+ <div>
<gl-form-group
id="name-integration"
:label="$options.i18n.integrationFormSteps.step2.label"
@@ -661,9 +554,7 @@ export default {
data-testid="integration-form-submit"
>{{ s__('AlertSettings|Save integration') }}
</gl-button>
- <!-- TODO: Will be removed in 13.7 as part of: https://gitlab.com/gitlab-org/gitlab/-/issues/273657 -->
<gl-button
- v-if="!isManagingOpsgenie"
data-testid="integration-test-and-submit"
:disabled="isSubmitTestPayloadDisabled"
category="secondary"
@@ -672,12 +563,7 @@ export default {
@click="submitWithTestPayload"
>{{ s__('AlertSettings|Save and test payload') }}</gl-button
>
- <gl-button
- type="reset"
- class="js-no-auto-disable"
- :class="{ 'gl-ml-3': isManagingOpsgenie }"
- >{{ __('Cancel') }}</gl-button
- >
+ <gl-button type="reset" class="js-no-auto-disable">{{ __('Cancel') }}</gl-button>
</div>
</gl-collapse>
</gl-form>
diff --git a/app/assets/javascripts/alerts_settings/components/alerts_settings_wrapper.vue b/app/assets/javascripts/alerts_settings/components/alerts_settings_wrapper.vue
index a55e63c3bc0..d0cac066ffa 100644
--- a/app/assets/javascripts/alerts_settings/components/alerts_settings_wrapper.vue
+++ b/app/assets/javascripts/alerts_settings/components/alerts_settings_wrapper.vue
@@ -1,5 +1,4 @@
<script>
-import { GlAlert, GlLink, GlSprintf } from '@gitlab/ui';
import { s__ } from '~/locale';
import { fetchPolicies } from '~/lib/graphql';
import createFlash, { FLASH_TYPES } from '~/flash';
@@ -41,10 +40,6 @@ export default {
),
},
components: {
- // TODO: Will be removed in 13.7 as part of: https://gitlab.com/gitlab-org/gitlab/-/issues/273657
- GlAlert,
- GlLink,
- GlSprintf,
IntegrationsList,
AlertSettingsForm,
},
@@ -55,10 +50,6 @@ export default {
prometheus: {
default: {},
},
- // TODO: Will be removed in 13.7 as part of: https://gitlab.com/gitlab-org/gitlab/-/issues/273657
- opsgenie: {
- default: {},
- },
projectPath: {
default: '',
},
@@ -105,13 +96,6 @@ export default {
canAddIntegration() {
return this.multiIntegrations || this.integrations?.list?.length < 2;
},
- canManageOpsgenie() {
- return (
- this.opsgenie.active ||
- this.integrations?.list?.every(({ active }) => active === false) ||
- this.integrations?.list?.length === 0
- );
- },
},
methods: {
createNewIntegration({ type, variables }) {
@@ -243,7 +227,9 @@ export default {
});
},
editIntegration({ id }) {
- const currentIntegration = this.integrations.list.find(integration => integration.id === id);
+ const currentIntegration = this.integrations.list.find(
+ (integration) => integration.id === id,
+ );
this.$apollo.mutate({
mutation: updateCurrentIntergrationMutation,
variables: {
@@ -317,27 +303,7 @@ export default {
<template>
<div>
- <!-- TODO: Will be removed in 13.7 as part of: https://gitlab.com/gitlab-org/gitlab/-/issues/273657 -->
- <gl-alert v-if="opsgenie.active" :dismissible="false" variant="tip">
- <gl-sprintf
- :message="
- s__(
- 'AlertSettings|We will soon be introducing the ability to create multiple unique HTTP endpoints. When this functionality is live, you will be able to configure an integration with Opsgenie to surface Opsgenie alerts in GitLab. This will replace the current Opsgenie integration which will be deprecated. %{linkStart}More Information%{linkEnd}',
- )
- "
- >
- <template #link="{ content }">
- <gl-link
- class="gl-display-inline-block"
- href="https://gitlab.com/gitlab-org/gitlab/-/issues/273657"
- target="_blank"
- >{{ content }}</gl-link
- >
- </template>
- </gl-sprintf>
- </gl-alert>
<integrations-list
- v-else
:integrations="integrations.list"
:loading="loading"
@edit-integration="editIntegration"
@@ -346,7 +312,6 @@ export default {
<alert-settings-form
:loading="isUpdating"
:can-add-integration="canAddIntegration"
- :can-manage-opsgenie="canManageOpsgenie"
@create-new-integration="createNewIntegration"
@update-integration="updateIntegration"
@reset-token="resetToken"
diff --git a/app/assets/javascripts/alerts_settings/constants.js b/app/assets/javascripts/alerts_settings/constants.js
index e30dc2ad553..ecd7c921b2f 100644
--- a/app/assets/javascripts/alerts_settings/constants.js
+++ b/app/assets/javascripts/alerts_settings/constants.js
@@ -40,22 +40,15 @@ export const i18n = {
integration: s__('AlertSettings|Integration'),
};
-// TODO: Delete as part of old form removal in 13.6
export const integrationTypes = [
+ { value: '', text: s__('AlertSettings|Select integration type') },
{ value: 'HTTP', text: s__('AlertSettings|HTTP Endpoint') },
{ value: 'PROMETHEUS', text: s__('AlertSettings|External Prometheus') },
- { value: 'OPSGENIE', text: s__('AlertSettings|Opsgenie') },
-];
-
-export const integrationTypesNew = [
- { value: '', text: s__('AlertSettings|Select integration type') },
- ...integrationTypes,
];
export const typeSet = {
http: 'HTTP',
prometheus: 'PROMETHEUS',
- opsgenie: 'OPSGENIE',
};
export const integrationToDeleteDefault = { id: null, name: '' };
@@ -63,7 +56,6 @@ export const integrationToDeleteDefault = { id: null, name: '' };
export const JSON_VALIDATE_DELAY = 250;
export const targetPrometheusUrlPlaceholder = 'http://prometheus.example.com/';
-export const targetOpsgenieUrlPlaceholder = 'https://app.opsgenie.com/alert/list/';
export const sectionHash = 'js-alert-management-settings';
diff --git a/app/assets/javascripts/alerts_settings/graphql.js b/app/assets/javascripts/alerts_settings/graphql.js
index 02c2def87fa..3dbfa69a8e9 100644
--- a/app/assets/javascripts/alerts_settings/graphql.js
+++ b/app/assets/javascripts/alerts_settings/graphql.js
@@ -14,7 +14,7 @@ const resolvers = {
{ cache },
) => {
const sourceData = cache.readQuery({ query: getCurrentIntegrationQuery });
- const data = produce(sourceData, draftData => {
+ const data = produce(sourceData, (draftData) => {
if (id === null) {
// eslint-disable-next-line no-param-reassign
draftData.currentIntegration = null;
diff --git a/app/assets/javascripts/alerts_settings/index.js b/app/assets/javascripts/alerts_settings/index.js
index 41b19a675c5..85858956987 100644
--- a/app/assets/javascripts/alerts_settings/index.js
+++ b/app/assets/javascripts/alerts_settings/index.js
@@ -11,7 +11,7 @@ apolloProvider.clients.defaultClient.cache.writeData({
});
Vue.use(GlToast);
-export default el => {
+export default (el) => {
if (!el) {
return null;
}
@@ -29,16 +29,15 @@ export default el => {
formPath,
authorizationKey,
url,
- opsgenieMvcAvailable,
- opsgenieMvcFormPath,
- opsgenieMvcEnabled,
- opsgenieMvcTargetUrl,
projectPath,
multiIntegrations,
} = el.dataset;
return new Vue({
el,
+ components: {
+ AlertSettingsWrapper,
+ },
provide: {
prometheus: {
active: parseBoolean(prometheusActivated),
@@ -56,19 +55,10 @@ export default el => {
token: authorizationKey,
url,
},
- opsgenie: {
- formPath: opsgenieMvcFormPath,
- active: parseBoolean(opsgenieMvcEnabled),
- opsgenieMvcTargetUrl,
- opsgenieMvcIsAvailable: parseBoolean(opsgenieMvcAvailable),
- },
projectPath,
multiIntegrations: parseBoolean(multiIntegrations),
},
apolloProvider,
- components: {
- AlertSettingsWrapper,
- },
render(createElement) {
return createElement('alert-settings-wrapper');
},
diff --git a/app/assets/javascripts/alerts_settings/utils/cache_updates.js b/app/assets/javascripts/alerts_settings/utils/cache_updates.js
index 18054b29fe9..758f3eb6dd4 100644
--- a/app/assets/javascripts/alerts_settings/utils/cache_updates.js
+++ b/app/assets/javascripts/alerts_settings/utils/cache_updates.js
@@ -14,7 +14,7 @@ const deleteIntegrationFromStore = (store, query, { httpIntegrationDestroy }, va
variables,
});
- const data = produce(sourceData, draftData => {
+ const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.project.alertManagementIntegrations.nodes = draftData.project.alertManagementIntegrations.nodes.filter(
({ id }) => id !== integration.id,
@@ -45,7 +45,7 @@ const addIntegrationToStore = (
variables,
});
- const data = produce(sourceData, draftData => {
+ const data = produce(sourceData, (draftData) => {
// eslint-disable-next-line no-param-reassign
draftData.project.alertManagementIntegrations.nodes = [
integration,