From 1063cd719c0e25df43bf5d2c0ea8e22f112ed225 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 29 Oct 2020 00:08:36 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- GITALY_SERVER_VERSION | 2 +- .../components/alerts_integrations_list.vue | 4 +- .../components/alerts_settings_form_new.vue | 119 ++++ ..._form.vue => alerts_settings_form_old.vue} | 320 +++++----- .../components/alerts_settings_wrapper.vue | 48 ++ .../javascripts/alerts_settings/constants.js | 12 +- .../javascripts/alerts_settings/index.js | 19 +- .../groups/components/group_item.vue | 8 +- .../settings/operations_controller.rb | 4 + .../alert_management/integrations_resolver.rb | 29 + .../alert_management/http_integration_type.rb | 22 + .../alert_management/integration_type.rb | 58 ++ .../alert_management/integration_type_enum.rb | 13 + .../prometheus_integration_type.rb | 38 ++ app/graphql/types/project_type.rb | 6 + .../alert_management/http_integration.rb | 5 +- .../http_integration_policy.rb | 7 + app/policies/prometheus_service_policy.rb | 5 + ...273148-fj-disallow-some-project-routes.yml | 5 + .../development/http_integrations_list.yml | 7 + .../graphql/reference/gitlab_schema.graphql | 192 ++++++ doc/api/graphql/reference/gitlab_schema.json | 562 ++++++++++++++++++ doc/api/graphql/reference/index.md | 37 ++ .../documentation/restful_api_styleguide.md | 18 +- doc/development/integrations/secure.md | 5 + doc/operations/metrics/index.md | 2 +- doc/user/application_security/dast/index.md | 33 - locale/gitlab.pot | 23 +- public/robots.txt | 13 + spec/fast_spec_helper.rb | 6 + .../user_views_alerts_settings_spec.rb | 64 ++ .../alert_settings_form_spec.js.snap | 50 -- .../alerts_settings_form_new_spec.js.snap | 20 + .../alerts_settings_form_old_spec.js.snap | 47 ++ .../alerts_integrations_list_spec.js | 4 +- .../alerts_settings_form_new_spec.js | 59 ++ .../alerts_settings_form_old_spec.js} | 49 +- .../alerts_settings_wrapper_spec.js | 48 ++ spec/frontend/alerts_settings/util.js | 28 + .../integrations_resolver_spec.rb | 42 ++ .../http_integration_type_spec.rb | 9 + .../integration_type_enum_spec.rb | 22 + .../alert_management/integration_type_spec.rb | 21 + .../prometheus_integration_type_spec.rb | 60 ++ spec/graphql/types/project_type_spec.rb | 3 +- .../http_integration_policy_spec.rb | 23 + .../prometheus_service_policy_spec.rb | 23 + .../alert_management/integrations_spec.rb | 83 +++ spec/requests/robots_txt_spec.rb | 15 +- 49 files changed, 1962 insertions(+), 330 deletions(-) create mode 100644 app/assets/javascripts/alerts_settings/components/alerts_settings_form_new.vue rename app/assets/javascripts/alerts_settings/components/{alerts_settings_form.vue => alerts_settings_form_old.vue} (58%) create mode 100644 app/assets/javascripts/alerts_settings/components/alerts_settings_wrapper.vue create mode 100644 app/graphql/resolvers/alert_management/integrations_resolver.rb create mode 100644 app/graphql/types/alert_management/http_integration_type.rb create mode 100644 app/graphql/types/alert_management/integration_type.rb create mode 100644 app/graphql/types/alert_management/integration_type_enum.rb create mode 100644 app/graphql/types/alert_management/prometheus_integration_type.rb create mode 100644 app/policies/alert_management/http_integration_policy.rb create mode 100644 app/policies/prometheus_service_policy.rb create mode 100644 changelogs/unreleased/273148-fj-disallow-some-project-routes.yml create mode 100644 config/feature_flags/development/http_integrations_list.yml create mode 100644 spec/features/alerts_settings/user_views_alerts_settings_spec.rb delete mode 100644 spec/frontend/alert_settings/__snapshots__/alert_settings_form_spec.js.snap create mode 100644 spec/frontend/alerts_settings/__snapshots__/alerts_settings_form_new_spec.js.snap create mode 100644 spec/frontend/alerts_settings/__snapshots__/alerts_settings_form_old_spec.js.snap rename spec/frontend/{alert_settings => alerts_settings}/alerts_integrations_list_spec.js (93%) create mode 100644 spec/frontend/alerts_settings/alerts_settings_form_new_spec.js rename spec/frontend/{alert_settings/alert_settings_form_spec.js => alerts_settings/alerts_settings_form_old_spec.js} (81%) create mode 100644 spec/frontend/alerts_settings/alerts_settings_wrapper_spec.js create mode 100644 spec/frontend/alerts_settings/util.js create mode 100644 spec/graphql/resolvers/alert_management/integrations_resolver_spec.rb create mode 100644 spec/graphql/types/alert_management/http_integration_type_spec.rb create mode 100644 spec/graphql/types/alert_management/integration_type_enum_spec.rb create mode 100644 spec/graphql/types/alert_management/integration_type_spec.rb create mode 100644 spec/graphql/types/alert_management/prometheus_integration_type_spec.rb create mode 100644 spec/policies/alert_management/http_integration_policy_spec.rb create mode 100644 spec/policies/prometheus_service_policy_spec.rb create mode 100644 spec/requests/api/graphql/project/alert_management/integrations_spec.rb diff --git a/GITALY_SERVER_VERSION b/GITALY_SERVER_VERSION index f372807af9b..ad120a28f84 100644 --- a/GITALY_SERVER_VERSION +++ b/GITALY_SERVER_VERSION @@ -1 +1 @@ -dfdc9b7725eb710dab8ae9970e98cc5118e65c49 +092d4e489d7de1dcc38d57a4c667e85df8b8377f 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 217442e6131..d377f0f2654 100644 --- a/app/assets/javascripts/alerts_settings/components/alerts_integrations_list.vue +++ b/app/assets/javascripts/alerts_settings/components/alerts_integrations_list.vue @@ -2,7 +2,7 @@ import { GlTable, GlIcon, GlTooltipDirective } from '@gitlab/ui'; import { s__, __ } from '~/locale'; import Tracking from '~/tracking'; -import { trackAlertIntergrationsViewsOptions } from '../constants'; +import { trackAlertIntegrationsViewsOptions } from '../constants'; export const i18n = { title: s__('AlertsIntegrations|Current integrations'), @@ -64,7 +64,7 @@ export default { }, methods: { trackPageViews() { - const { category, action } = trackAlertIntergrationsViewsOptions; + const { category, action } = trackAlertIntegrationsViewsOptions; Tracking.event(category, action); }, }, diff --git a/app/assets/javascripts/alerts_settings/components/alerts_settings_form_new.vue b/app/assets/javascripts/alerts_settings/components/alerts_settings_form_new.vue new file mode 100644 index 00000000000..3fd158e1d8e --- /dev/null +++ b/app/assets/javascripts/alerts_settings/components/alerts_settings_form_new.vue @@ -0,0 +1,119 @@ + + + diff --git a/app/assets/javascripts/alerts_settings/components/alerts_settings_form.vue b/app/assets/javascripts/alerts_settings/components/alerts_settings_form_old.vue similarity index 58% rename from app/assets/javascripts/alerts_settings/components/alerts_settings_form.vue rename to app/assets/javascripts/alerts_settings/components/alerts_settings_form_old.vue index f885afae378..ab6d5526154 100644 --- a/app/assets/javascripts/alerts_settings/components/alerts_settings_form.vue +++ b/app/assets/javascripts/alerts_settings/components/alerts_settings_form_old.vue @@ -14,16 +14,14 @@ import { GlFormSelect, } from '@gitlab/ui'; import { debounce } from 'lodash'; -import { s__ } from '~/locale'; import { doesHashExistInUrl } from '~/lib/utils/url_utility'; import ClipboardButton from '~/vue_shared/components/clipboard_button.vue'; import ToggleButton from '~/vue_shared/components/toggle_button.vue'; -import IntegrationsList from './alerts_integrations_list.vue'; import csrf from '~/lib/utils/csrf'; import service from '../services'; import { i18n, - serviceOptions, + integrationTypes, JSON_VALIDATE_DELAY, targetPrometheusUrlPlaceholder, targetOpsgenieUrlPlaceholder, @@ -50,7 +48,6 @@ export default { GlSprintf, ClipboardButton, ToggleButton, - IntegrationsList, }, directives: { 'gl-modal': GlModalDirective, @@ -59,8 +56,8 @@ export default { data() { return { loading: false, - selectedEndpoint: serviceOptions[0].value, - options: serviceOptions, + selectedIntegration: integrationTypes[1].value, + options: integrationTypes, active: false, authKey: '', targetUrl: '', @@ -91,13 +88,13 @@ export default { ]; }, isPrometheus() { - return this.selectedEndpoint === 'prometheus'; + return this.selectedIntegration === 'prometheus'; }, isOpsgenie() { - return this.selectedEndpoint === 'opsgenie'; + return this.selectedIntegration === 'opsgenie'; }, - selectedService() { - switch (this.selectedEndpoint) { + selectedIntegrationType() { + switch (this.selectedIntegration) { case 'generic': { return { url: this.generic.url, @@ -152,27 +149,13 @@ export default { ? this.$options.targetOpsgenieUrlPlaceholder : this.$options.targetPrometheusUrlPlaceholder; }, - integrations() { - return [ - { - name: s__('AlertSettings|HTTP endpoint'), - type: s__('AlertsIntegrations|HTTP endpoint'), - activated: this.generic.activated, - }, - { - name: s__('AlertSettings|External Prometheus'), - type: s__('AlertsIntegrations|Prometheus'), - activated: this.prometheus.activated, - }, - ]; - }, }, watch: { 'testAlert.json': debounce(function debouncedJsonValidate() { this.validateJson(); }, JSON_VALIDATE_DELAY), targetUrl(oldVal, newVal) { - if (newVal && oldVal !== this.selectedService.targetUrl) { + if (newVal && oldVal !== this.selectedIntegrationType.targetUrl) { this.canSaveForm = true; } }, @@ -187,8 +170,8 @@ export default { } else if (this.opsgenie.activated) { this.setOpsgenieAsDefault(); } - this.active = this.selectedService.activated; - this.authKey = this.selectedService.authKey ?? ''; + this.active = this.selectedIntegrationType.activated; + this.authKey = this.selectedIntegrationType.authKey ?? ''; }, methods: { createUserErrorMessage(errors = {}) { @@ -205,9 +188,9 @@ export default { } return { ...el, disabled: false }; }); - this.selectedEndpoint = this.options.find(({ value }) => value === 'opsgenie').value; + this.selectedIntegration = this.options.find(({ value }) => value === 'opsgenie').value; if (this.targetUrl === null) { - this.targetUrl = this.selectedService.targetUrl; + this.targetUrl = this.selectedIntegrationType.targetUrl; } }, removeOpsGenieOption() { @@ -220,8 +203,8 @@ export default { }, resetFormValues() { this.testAlert.json = null; - this.targetUrl = this.selectedService.targetUrl; - this.active = this.selectedService.activated; + this.targetUrl = this.selectedIntegrationType.targetUrl; + this.active = this.selectedIntegrationType.activated; }, dismissFeedback() { this.serverError = null; @@ -261,7 +244,7 @@ export default { this.loading = true; return service .updateGenericActive({ - endpoint: this[this.selectedEndpoint].formPath, + endpoint: this[this.selectedIntegration].formPath, params: this.isOpsgenie ? { service: { opsgenie_mvc_target_url: this.targetUrl, opsgenie_mvc_enabled: value } } : { service: { active: value } }, @@ -331,9 +314,9 @@ export default { this.validateJson(); return service .updateTestAlert({ - endpoint: this.selectedService.url, + endpoint: this.selectedIntegrationType.url, data: this.testAlert.json, - authKey: this.selectedService.authKey, + authKey: this.selectedIntegrationType.authKey, }) .then(() => { this.setFeedback({ @@ -358,11 +341,11 @@ export default { onReset() { this.testAlert.json = null; this.dismissFeedback(); - this.targetUrl = this.selectedService.targetUrl; + this.targetUrl = this.selectedIntegrationType.targetUrl; if (this.canSaveForm) { this.canSaveForm = false; - this.active = this.selectedService.activated; + this.active = this.selectedIntegrationType.activated; } }, }, @@ -370,153 +353,144 @@ export default { diff --git a/app/assets/javascripts/alerts_settings/components/alerts_settings_wrapper.vue b/app/assets/javascripts/alerts_settings/components/alerts_settings_wrapper.vue new file mode 100644 index 00000000000..1edb8f1c921 --- /dev/null +++ b/app/assets/javascripts/alerts_settings/components/alerts_settings_wrapper.vue @@ -0,0 +1,48 @@ + + + diff --git a/app/assets/javascripts/alerts_settings/constants.js b/app/assets/javascripts/alerts_settings/constants.js index 4220dbde0c7..74e39534eb5 100644 --- a/app/assets/javascripts/alerts_settings/constants.js +++ b/app/assets/javascripts/alerts_settings/constants.js @@ -17,11 +17,10 @@ export const i18n = { changesSaved: s__('AlertSettings|Your integration was successfully updated.'), prometheusInfo: s__('AlertSettings|Add URL and auth key to your Prometheus config file'), integrationsInfo: s__( - 'AlertSettings|Learn more about our improvements for %{linkStart}integrations%{linkEnd}', + 'AlertSettings|Learn more about our our upcoming %{linkStart}integrations%{linkEnd}', ), resetKey: s__('AlertSettings|Reset key'), copyToClipboard: s__('AlertSettings|Copy'), - integrationsLabel: s__('AlertSettings|Add new integrations'), apiBaseUrlLabel: s__('AlertSettings|API URL'), authKeyLabel: s__('AlertSettings|Authorization key'), urlLabel: s__('AlertSettings|Webhook URL'), @@ -40,7 +39,8 @@ export const i18n = { integration: s__('AlertSettings|Integration'), }; -export const serviceOptions = [ +export const integrationTypes = [ + { value: '', text: s__('AlertSettings|Select integration type') }, { value: 'generic', text: s__('AlertSettings|HTTP Endpoint') }, { value: 'prometheus', text: s__('AlertSettings|External Prometheus') }, { value: 'opsgenie', text: s__('AlertSettings|Opsgenie') }, @@ -56,9 +56,9 @@ export const sectionHash = 'js-alert-management-settings'; /* eslint-disable @gitlab/require-i18n-strings */ /** - * Tracks snowplow event when user views alerts intergration list + * Tracks snowplow event when user views alerts integration list */ -export const trackAlertIntergrationsViewsOptions = { - category: 'Alert Intergrations', +export const trackAlertIntegrationsViewsOptions = { + category: 'Alert Integrations', action: 'view_alert_integrations_list', }; diff --git a/app/assets/javascripts/alerts_settings/index.js b/app/assets/javascripts/alerts_settings/index.js index 8d1d342d229..80f06a094b7 100644 --- a/app/assets/javascripts/alerts_settings/index.js +++ b/app/assets/javascripts/alerts_settings/index.js @@ -1,6 +1,6 @@ import Vue from 'vue'; import { parseBoolean } from '~/lib/utils/common_utils'; -import AlertSettingsForm from './components/alerts_settings_form.vue'; +import AlertSettingsWrapper from './components/alerts_settings_wrapper.vue'; export default el => { if (!el) { @@ -26,16 +26,11 @@ export default el => { opsgenieMvcTargetUrl, } = el.dataset; - const genericActivated = parseBoolean(activatedStr); - const prometheusIsActivated = parseBoolean(prometheusActivated); - const opsgenieMvcActivated = parseBoolean(opsgenieMvcEnabled); - const opsgenieMvcIsAvailable = parseBoolean(opsgenieMvcAvailable); - return new Vue({ el, provide: { prometheus: { - activated: prometheusIsActivated, + activated: parseBoolean(prometheusActivated), prometheusUrl, authorizationKey: prometheusAuthorizationKey, prometheusFormPath, @@ -45,23 +40,23 @@ export default el => { generic: { alertsSetupUrl, alertsUsageUrl, - activated: genericActivated, + activated: parseBoolean(activatedStr), formPath, authorizationKey, url, }, opsgenie: { formPath: opsgenieMvcFormPath, - activated: opsgenieMvcActivated, + activated: parseBoolean(opsgenieMvcEnabled), opsgenieMvcTargetUrl, - opsgenieMvcIsAvailable, + opsgenieMvcIsAvailable: parseBoolean(opsgenieMvcAvailable), }, }, components: { - AlertSettingsForm, + AlertSettingsWrapper, }, render(createElement) { - return createElement('alert-settings-form'); + return createElement('alert-settings-wrapper'); }, }); }; diff --git a/app/assets/javascripts/groups/components/group_item.vue b/app/assets/javascripts/groups/components/group_item.vue index 44349b33386..6e99b6ad4fa 100644 --- a/app/assets/javascripts/groups/components/group_item.vue +++ b/app/assets/javascripts/groups/components/group_item.vue @@ -1,8 +1,7 @@