Skip to content
Snippets Groups Projects
Commit 2a040e26 authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent a53d2c37
No related branches found
No related tags found
No related merge requests found
Showing
with 169 additions and 47 deletions
Loading
Loading
@@ -349,6 +349,8 @@ RSpec/HaveGitlabHttpStatus:
- 'ee/spec/requests/{groups,projects,repositories}/**/*'
- 'spec/requests/api/*/**/*.rb'
- 'ee/spec/requests/api/*/**/*.rb'
- 'spec/requests/api/[a-f]*.rb'
- 'ee/spec/requests/api/[a-f]*.rb'
 
Style/MultilineWhenThen:
Enabled: false
Loading
Loading
<script>
import _ from 'underscore';
import { throttle } from 'lodash';
import { mapActions, mapState, mapGetters } from 'vuex';
import { GlLoadingIcon } from '@gitlab/ui';
import LoadingButton from '~/vue_shared/components/loading_button.vue';
Loading
Loading
@@ -67,7 +67,7 @@ export default {
this.setFilter(target.value);
},
 
throttledFetchRepos: _.throttle(function fetch() {
throttledFetchRepos: throttle(function fetch() {
eventHub.$off('importAll');
this.fetchRepos();
}, reposFetchThrottleDelay),
Loading
Loading
Loading
Loading
@@ -1808,11 +1808,7 @@ export default class Notes {
$editingNote.removeClass('is-editing fade-in-full').addClass('being-posted fade-in-half');
$editingNote
.find('.note-headline-meta a')
.html(
`<i class="fa fa-spinner fa-spin" aria-label="${__(
'Comment is being updated',
)}" aria-hidden="true"></i>`,
);
.html('<span class="spinner align-text-bottom"></span>');
 
// Make request to update comment on server
axios
Loading
Loading
@@ -1825,7 +1821,7 @@ export default class Notes {
// Submission failed, revert back to original note
$noteBodyText.html(escape(cachedNoteBodyText));
$editingNote.removeClass('being-posted fade-in');
$editingNote.find('.fa.fa-spinner').remove();
$editingNote.find('.spinner').remove();
 
// Show Flash message about failure
this.updateNoteError();
Loading
Loading
Loading
Loading
@@ -6,6 +6,7 @@ module Projects
RESERVED_ANNOTATIONS = %w(gitlab_incident_markdown title).freeze
GENERIC_ALERT_SUMMARY_ANNOTATIONS = %w(monitoring_tool service hosts).freeze
MARKDOWN_LINE_BREAK = " \n".freeze
INCIDENT_LABEL_NAME = IncidentManagement::CreateIssueService::INCIDENT_LABEL[:title].freeze
 
def full_title
[environment_name, alert_title].compact.join(': ')
Loading
Loading
@@ -31,6 +32,18 @@ module Projects
end
end
 
def show_performance_dashboard_link?
gitlab_alert.present?
end
def show_incident_issues_link?
project.incident_management_setting&.create_issue?
end
def incident_issues_link
project_issues_url(project, label_name: INCIDENT_LABEL_NAME)
end
def starts_at
super&.rfc3339
end
Loading
Loading
# frozen_string_literal: true
module IncidentManagement
module Settings
def incident_management_setting
strong_memoize(:incident_management_setting) do
project.incident_management_setting ||
project.build_incident_management_setting
end
end
def process_issues?
incident_management_setting.create_issue?
end
end
end
Loading
Loading
@@ -36,6 +36,8 @@ module Issues
execute_hooks(issue, 'close')
invalidate_cache_counts(issue, users: issue.assignees)
issue.update_project_counter_caches
store_first_mentioned_in_commit_at(issue, closed_via) if closed_via.is_a?(MergeRequest)
end
 
issue
Loading
Loading
@@ -46,5 +48,17 @@ module Issues
def create_note(issue, current_commit)
SystemNoteService.change_status(issue, issue.project, current_user, issue.state, current_commit)
end
def store_first_mentioned_in_commit_at(issue, merge_request)
return unless Feature.enabled?(:store_first_mentioned_in_commit_on_issue_close, issue.project)
metrics = issue.metrics
return if metrics.nil? || metrics.first_mentioned_in_commit_at
first_commit_timestamp = merge_request.commits(limit: 1).first&.date
return unless first_commit_timestamp
metrics.update!(first_mentioned_in_commit_at: first_commit_timestamp)
end
end
end
Loading
Loading
@@ -4,12 +4,14 @@ module Projects
module Alerting
class NotifyService < BaseService
include Gitlab::Utils::StrongMemoize
include IncidentManagement::Settings
 
def execute(token)
return forbidden unless alerts_service_activated?
return unauthorized unless valid_token?(token)
 
process_incident_issues
process_incident_issues if process_issues?
send_alert_email if send_email?
 
ServiceResponse.success
rescue Gitlab::Alerting::NotificationPayloadParser::BadPayloadError
Loading
Loading
@@ -20,11 +22,21 @@ module Projects
 
delegate :alerts_service, :alerts_service_activated?, to: :project
 
def send_email?
incident_management_setting.send_email?
end
def process_incident_issues
IncidentManagement::ProcessAlertWorker
.perform_async(project.id, parsed_payload)
end
 
def send_alert_email
notification_service
.async
.prometheus_alerts_fired(project, [parsed_payload])
end
def parsed_payload
Gitlab::Alerting::NotificationPayloadParser.call(params.to_h)
end
Loading
Loading
Loading
Loading
@@ -4,11 +4,11 @@
 
= render_dashboard_gold_trial(current_user)
 
.page-title-holder.d-flex.align-items-center
.page-title-holder.d-flex.align-items-start.flex-column.flex-sm-row.align-items-sm-center
%h1.page-title= _('Merge Requests')
 
- if current_user
.page-title-controls
.page-title-controls.ml-0.mb-3.ml-sm-auto.mb-sm-0
= render 'shared/new_project_item_select', path: 'merge_requests/new', label: "New merge request", with_feature_enabled: 'merge_requests', type: :merge_requests
 
.top-area
Loading
Loading
---
title: Send alert emails for generic incident alerts
merge_request: 24414
author:
type: added
---
title: Prevent "Select project to create merge request" button from overflowing out
of the viewport on mobile
merge_request: 25195
author:
type: fixed
---
title: Migrated from .fa-spinner to .spinner in 'app/assets/javascripts/notes.js
merge_request: 24916
author: Raihan Kabir (gitlab/rk4bir)
type: changed
Loading
Loading
@@ -424,16 +424,10 @@ Take the following migration as an example:
 
```ruby
class DefaultRequestAccessGroups < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
 
def up
change_column_default :namespaces, :request_access_enabled, true
end
def down
change_column_default :namespaces, :request_access_enabled, false
def change
change_column_default(:namespaces, :request_access_enabled, from: false, to: true)
end
end
```
Loading
Loading
# frozen_string_literal: true
 
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# See https://docs.gitlab.com/ee/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
 
class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
Loading
Loading
# frozen_string_literal: true
 
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# See https://docs.gitlab.com/ee/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
 
class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
Loading
Loading
# frozen_string_literal: true
 
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# See https://docs.gitlab.com/ee/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
 
class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
Loading
Loading
Loading
Loading
@@ -1674,6 +1674,9 @@ msgstr ""
msgid "Amount of time (in hours) that users are allowed to skip forced configuration of two-factor authentication"
msgstr ""
 
msgid "An alert has been triggered in %{project_path}."
msgstr ""
msgid "An application called %{link_to_client} is requesting access to your GitLab account."
msgstr ""
 
Loading
Loading
@@ -12164,6 +12167,9 @@ msgstr ""
msgid "Metric was successfully updated."
msgstr ""
 
msgid "Metric:"
msgstr ""
msgid "MetricChart|Please select a metric"
msgstr ""
 
Loading
Loading
@@ -21508,6 +21514,9 @@ msgstr ""
msgid "View group labels"
msgstr ""
 
msgid "View incident issues."
msgstr ""
msgid "View issue"
msgstr ""
 
Loading
Loading
@@ -21532,6 +21541,9 @@ msgstr ""
msgid "View open merge request"
msgstr ""
 
msgid "View performance dashboard."
msgstr ""
msgid "View project"
msgstr ""
 
Loading
Loading
@@ -21550,6 +21562,9 @@ msgstr ""
msgid "View the latest successful deployment to this environment"
msgstr ""
 
msgid "View the performance dashboard at"
msgstr ""
msgid "Viewing commit"
msgstr ""
 
Loading
Loading
import _ from 'underscore';
import { escape } from 'lodash';
import { shallowMount, createLocalVue } from '@vue/test-utils';
import createStore from '~/notes/stores';
import issueNote from '~/notes/components/noteable_note.vue';
Loading
Loading
@@ -98,7 +98,7 @@ describe('issue_note', () => {
 
setTimeout(() => {
expect(alertSpy).not.toHaveBeenCalled();
expect(wrapper.vm.note.note_html).toEqual(_.escape(noteBody));
expect(wrapper.vm.note.note_html).toEqual(escape(noteBody));
done();
}, 0);
});
Loading
Loading
Loading
Loading
@@ -17,6 +17,12 @@ describe Gitlab::Alerting::Alert do
end
end
 
shared_context 'full query' do
before do
payload['generatorURL'] = 'http://localhost:9090/graph?g0.expr=vector%281%29'
end
end
shared_examples 'invalid alert' do
it 'is invalid' do
expect(alert).not_to be_valid
Loading
Loading
@@ -180,10 +186,7 @@ describe Gitlab::Alerting::Alert do
 
context 'with gitlab alert' do
include_context 'gitlab alert'
before do
payload['generatorURL'] = 'http://localhost:9090/graph?g0.expr=vector%281%29'
end
include_context 'full query'
 
it { is_expected.to eq(gitlab_alert.full_query) }
end
Loading
Loading
Loading
Loading
@@ -9,6 +9,15 @@ describe Projects::Prometheus::AlertPresenter do
let(:payload) { {} }
let(:alert) { create(:alerting_alert, project: project, payload: payload) }
 
shared_context 'gitlab alert' do
let(:gitlab_alert) { create(:prometheus_alert, project: project) }
let(:metric_id) { gitlab_alert.prometheus_metric_id }
let(:alert) do
create(:alerting_alert, project: project, metric_id: metric_id)
end
end
describe '#project_full_path' do
subject { presenter.project_full_path }
 
Loading
Loading
@@ -145,13 +154,35 @@ describe Projects::Prometheus::AlertPresenter do
end
end
 
context 'with gitlab alert' do
let(:gitlab_alert) { create(:prometheus_alert, project: project) }
let(:metric_id) { gitlab_alert.prometheus_metric_id }
describe '#show_performance_dashboard_link?' do
subject { presenter.show_performance_dashboard_link? }
 
let(:alert) do
create(:alerting_alert, project: project, metric_id: metric_id)
it { is_expected.to be_falsey }
context 'with gitlab alert' do
include_context 'gitlab alert'
it { is_expected.to eq(true) }
end
end
describe '#show_incident_issues_link?' do
subject { presenter.show_incident_issues_link? }
it { is_expected.to be_falsey }
context 'create issue setting enabled' do
before do
create(:project_incident_management_setting, project: project, create_issue: true)
project.reload
end
it { is_expected.to eq(true) }
end
end
context 'with gitlab alert' do
include_context 'gitlab alert'
 
describe '#full_title' do
let(:query_title) do
Loading
Loading
@@ -189,6 +220,17 @@ describe Projects::Prometheus::AlertPresenter do
 
it { is_expected.to eq(expected_link) }
end
describe '#incident_issues_link' do
let(:expected_link) do
Gitlab::Routing.url_helpers
.project_issues_url(project, label_name: described_class::INCIDENT_LABEL_NAME)
end
subject { presenter.incident_issues_link }
it { is_expected.to eq(expected_link) }
end
end
 
context 'without gitlab alert' do
Loading
Loading
Loading
Loading
@@ -37,7 +37,7 @@ describe API::AccessRequests do
user = public_send(type)
get api("/#{source_type.pluralize}/#{source.id}/access_requests", user)
 
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
Loading
Loading
@@ -47,7 +47,7 @@ describe API::AccessRequests do
it 'returns access requesters' do
get api("/#{source_type.pluralize}/#{source.id}/access_requests", maintainer)
 
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(1)
Loading
Loading
@@ -70,7 +70,7 @@ describe API::AccessRequests do
user = public_send(type)
post api("/#{source_type.pluralize}/#{source.id}/access_requests", user)
 
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end.not_to change { source.requesters.count }
end
end
Loading
Loading
@@ -82,7 +82,7 @@ describe API::AccessRequests do
expect do
post api("/#{source_type.pluralize}/#{source.id}/access_requests", access_requester)
 
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end.not_to change { source.requesters.count }
end
end
Loading
Loading
@@ -97,7 +97,7 @@ describe API::AccessRequests do
expect do
post api("/#{source_type.pluralize}/#{source.id}/access_requests", stranger)
 
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end.not_to change { source.requesters.count }
end
end
Loading
Loading
@@ -106,7 +106,7 @@ describe API::AccessRequests do
expect do
post api("/#{source_type.pluralize}/#{source.id}/access_requests", stranger)
 
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
end.to change { source.requesters.count }.by(1)
 
# User attributes
Loading
Loading
@@ -137,7 +137,7 @@ describe API::AccessRequests do
user = public_send(type)
put api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}/approve", user)
 
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
Loading
Loading
@@ -149,7 +149,7 @@ describe API::AccessRequests do
put api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}/approve", maintainer),
params: { access_level: Member::MAINTAINER }
 
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
end.to change { source.members.count }.by(1)
# User attributes
expect(json_response['id']).to eq(access_requester.id)
Loading
Loading
@@ -168,7 +168,7 @@ describe API::AccessRequests do
expect do
put api("/#{source_type.pluralize}/#{source.id}/access_requests/#{stranger.id}/approve", maintainer)
 
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end.not_to change { source.members.count }
end
end
Loading
Loading
@@ -189,7 +189,7 @@ describe API::AccessRequests do
user = public_send(type)
delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}", user)
 
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
Loading
Loading
@@ -200,7 +200,7 @@ describe API::AccessRequests do
expect do
delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}", access_requester)
 
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end.to change { source.requesters.count }.by(-1)
end
end
Loading
Loading
@@ -210,7 +210,7 @@ describe API::AccessRequests do
expect do
delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}", maintainer)
 
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end.to change { source.requesters.count }.by(-1)
end
 
Loading
Loading
@@ -219,7 +219,7 @@ describe API::AccessRequests do
expect do
delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{developer.id}", maintainer)
 
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end.not_to change { source.requesters.count }
end
end
Loading
Loading
@@ -229,7 +229,7 @@ describe API::AccessRequests do
expect do
delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{stranger.id}", maintainer)
 
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end.not_to change { source.requesters.count }
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment