diff options
Diffstat (limited to 'app/assets/javascripts/alerts_settings')
4 files changed, 10 insertions, 66 deletions
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 428291f2313..033f48827f1 100644 --- a/app/assets/javascripts/alerts_settings/components/alerts_settings_form.vue +++ b/app/assets/javascripts/alerts_settings/components/alerts_settings_form.vue @@ -16,7 +16,7 @@ import { import * as Sentry from '@sentry/browser'; import { isEqual, isEmpty, omit } from 'lodash'; import ClipboardButton from '~/vue_shared/components/clipboard_button.vue'; -import { PROMO_URL } from 'jh_else_ce/lib/utils/url_utility'; +import { PROMO_URL, DOCS_URL_IN_EE_DIR } from 'jh_else_ce/lib/utils/url_utility'; import { integrationTypes, integrationSteps, @@ -38,6 +38,7 @@ export default { placeholders: { prometheus: targetPrometheusUrlPlaceholder, }, + incidentManagementDocsLink: `${DOCS_URL_IN_EE_DIR}/operations/incident_management/integrations.html#configuration`, JSON_VALIDATE_DELAY, typeSet, integrationSteps, @@ -121,14 +122,12 @@ export default { name: '', token: '', url: '', - apiUrl: '', }, activeTabIndex: this.tabIndex, currentIntegration: null, parsedPayload: [], validationState: { name: true, - apiUrl: true, }, pricingLink: `${PROMO_URL}/pricing`, }; @@ -187,20 +186,14 @@ export default { ); }, isFormDirty() { - const { type, active, name, apiUrl, payloadAlertFields = [], payloadAttributeMappings = [] } = + const { type, active, name, payloadAlertFields = [], payloadAttributeMappings = [] } = this.currentIntegration || {}; - const { - name: formName, - apiUrl: formApiUrl, - active: formActive, - type: formType, - } = this.integrationForm; + const { name: formName, active: formActive, type: formType } = this.integrationForm; const isDirty = type !== formType || active !== formActive || name !== formName || - apiUrl !== formApiUrl || !isEqual(this.parsedPayload, payloadAlertFields) || !isEqual(this.mapping, this.getCleanMapping(payloadAttributeMappings)); @@ -210,25 +203,19 @@ export default { return this.isFormValid && this.isFormDirty; }, dataForSave() { - const { name, apiUrl, active } = this.integrationForm; + const { name, active } = this.integrationForm; const customMappingVariables = { payloadAttributeMappings: this.mapping, payloadExample: this.samplePayload.json || '{}', }; - const variables = this.isHttp - ? { name, active, ...customMappingVariables } - : { apiUrl, active }; + const variables = this.isHttp ? { name, active, ...customMappingVariables } : { active }; return { type: this.integrationForm.type, variables }; }, testAlertModal() { return this.isFormDirty ? testAlertModalId : null; }, - prometheusUrlInvalidFeedback() { - const { blankUrlError, invalidUrlError } = i18n.integrationFormSteps.prometheusFormUrl; - return this.integrationForm.apiUrl?.length ? invalidUrlError : blankUrlError; - }, }, watch: { tabIndex(val) { @@ -246,13 +233,12 @@ export default { type, active, url, - apiUrl, token, payloadExample, payloadAlertFields, payloadAttributeMappings, } = val; - this.integrationForm = { type, name, active, url, apiUrl, token }; + this.integrationForm = { type, name, active, url, token }; if (this.showMappingBuilder) { this.resetPayloadAndMappingConfirmed = false; @@ -270,14 +256,6 @@ export default { validateName() { this.validationState.name = Boolean(this.integrationForm.name?.length); }, - validateApiUrl() { - try { - const parsedUrl = new URL(this.integrationForm.apiUrl); - this.validationState.apiUrl = ['http:', 'https:'].includes(parsedUrl.protocol); - } catch (e) { - this.validationState.apiUrl = false; - } - }, isValidNonEmptyJSON(JSONString) { if (JSONString) { let parsed; @@ -297,14 +275,12 @@ export default { }, triggerValidation() { if (this.isHttp) { - this.validationState.apiUrl = true; this.validateName(); if (!this.validationState.name) { this.$refs.integrationName.$el.scrollIntoView({ behavior: 'smooth', block: 'center' }); } } else if (this.isPrometheus) { this.validationState.name = true; - this.validateApiUrl(); } }, sendTestAlert() { @@ -331,7 +307,6 @@ export default { this.integrationForm.type = integrationTypes.none.value; this.integrationForm.name = ''; this.integrationForm.active = false; - this.integrationForm.apiUrl = ''; this.samplePayload = { json: null, error: null, @@ -489,28 +464,6 @@ export default { class="gl-mt-4 gl-font-weight-normal" /> </gl-form-group> - - <gl-form-group - v-if="isPrometheus" - class="gl-my-4" - :label="$options.i18n.integrationFormSteps.prometheusFormUrl.label" - label-for="api-url" - :invalid-feedback="prometheusUrlInvalidFeedback" - :state="validationState.apiUrl" - > - <gl-form-input - id="api-url" - v-model="integrationForm.apiUrl" - type="text" - :placeholder="$options.placeholders.prometheus" - data-qa-selector="prometheus_url_field" - @input="validateApiUrl" - /> - <span class="gl-text-gray-400"> - {{ $options.i18n.integrationFormSteps.prometheusFormUrl.help }} - </span> - </gl-form-group> - <template v-if="showMappingBuilder"> <gl-form-group data-testid="sample-payload-section" @@ -617,7 +570,7 @@ export default { > <alert-settings-form-help-block :message="viewCredentialsHelpMsg" - link="https://docs.gitlab.com/ee/operations/incident_management/integrations.html#configuration" + :link="$options.incidentManagementDocsLink" /> <gl-form-group id="integration-webhook"> diff --git a/app/assets/javascripts/alerts_settings/constants.js b/app/assets/javascripts/alerts_settings/constants.js index 6d914fe8361..218b09cb1b6 100644 --- a/app/assets/javascripts/alerts_settings/constants.js +++ b/app/assets/javascripts/alerts_settings/constants.js @@ -65,12 +65,6 @@ export const i18n = { proceedWithoutSave: s__('AlertSettings|Send without saving'), cancel: __('Cancel'), }, - prometheusFormUrl: { - label: s__('AlertSettings|Prometheus API base URL'), - help: s__('AlertSettings|URL cannot be blank and must start with http: or https:.'), - blankUrlError: __('URL cannot be blank'), - invalidUrlError: __('URL is invalid'), - }, restKeyInfo: { label: s__( 'AlertSettings|If you reset the authorization key for this project, you must update the key in every enabled alert source.', diff --git a/app/assets/javascripts/alerts_settings/graphql/fragments/integration_item.fragment.graphql b/app/assets/javascripts/alerts_settings/graphql/fragments/integration_item.fragment.graphql index 6d9307959df..2d8430dbede 100644 --- a/app/assets/javascripts/alerts_settings/graphql/fragments/integration_item.fragment.graphql +++ b/app/assets/javascripts/alerts_settings/graphql/fragments/integration_item.fragment.graphql @@ -5,5 +5,4 @@ fragment IntegrationItem on AlertManagementIntegration { name url token - apiUrl } diff --git a/app/assets/javascripts/alerts_settings/graphql/mutations/create_prometheus_integration.mutation.graphql b/app/assets/javascripts/alerts_settings/graphql/mutations/create_prometheus_integration.mutation.graphql index bb22795ddd5..c2acd928c5c 100644 --- a/app/assets/javascripts/alerts_settings/graphql/mutations/create_prometheus_integration.mutation.graphql +++ b/app/assets/javascripts/alerts_settings/graphql/mutations/create_prometheus_integration.mutation.graphql @@ -1,9 +1,7 @@ #import "../fragments/integration_item.fragment.graphql" -mutation createPrometheusIntegration($projectPath: ID!, $apiUrl: String!, $active: Boolean!) { - prometheusIntegrationCreate( - input: { projectPath: $projectPath, apiUrl: $apiUrl, active: $active } - ) { +mutation createPrometheusIntegration($projectPath: ID!, $active: Boolean!) { + prometheusIntegrationCreate(input: { projectPath: $projectPath, active: $active }) { errors integration { ...IntegrationItem |