summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/concerns/protected_ref_access.rb5
-rw-r--r--app/views/projects/protected_tags/_protected_tag.html.haml4
-rw-r--r--app/views/projects/protected_tags/_protected_tag_create_access_levels.haml8
-rw-r--r--app/views/projects/protected_tags/_update_protected_tag.haml5
-rw-r--r--app/views/projects/services/prometheus/_metrics.html.haml30
-rw-r--r--app/views/projects/services/prometheus/_show.html.haml33
-rw-r--r--app/views/projects/tags/index.html.haml2
-rw-r--r--lib/gitlab/json_logger.rb22
-rw-r--r--locale/gitlab.pot6
-rw-r--r--spec/features/merge_request/user_posts_diff_notes_spec.rb4
-rw-r--r--spec/lib/gitlab/json_logger_spec.rb29
11 files changed, 107 insertions, 41 deletions
diff --git a/app/models/concerns/protected_ref_access.rb b/app/models/concerns/protected_ref_access.rb
index 71b0c3468b9..5ff7b41b82b 100644
--- a/app/models/concerns/protected_ref_access.rb
+++ b/app/models/concerns/protected_ref_access.rb
@@ -17,6 +17,11 @@ module ProtectedRefAccess
scope :master, -> { maintainer } # @deprecated
scope :maintainer, -> { where(access_level: Gitlab::Access::MAINTAINER) }
scope :developer, -> { where(access_level: Gitlab::Access::DEVELOPER) }
+ scope :by_user, -> (user) { where(user_id: user ) }
+ scope :by_group, -> (group) { where(group_id: group ) }
+ scope :for_role, -> { where(user_id: nil, group_id: nil) }
+ scope :for_user, -> { where.not(user_id: nil) }
+ scope :for_group, -> { where.not(group_id: nil) }
validates :access_level, presence: true, if: :role?, inclusion: {
in: ALLOWED_ACCESS_LEVELS
diff --git a/app/views/projects/protected_tags/_protected_tag.html.haml b/app/views/projects/protected_tags/_protected_tag.html.haml
index da1f97c8d6a..e0912bf39c0 100644
--- a/app/views/projects/protected_tags/_protected_tag.html.haml
+++ b/app/views/projects/protected_tags/_protected_tag.html.haml
@@ -1,2 +1,4 @@
= render layout: 'projects/protected_tags/shared/protected_tag', locals: { protected_tag: protected_tag } do
- = render partial: 'projects/protected_tags/update_protected_tag', locals: { protected_tag: protected_tag }
+ %td
+ = render 'projects/protected_tags/protected_tag_create_access_levels', protected_tag: protected_tag, create_access_level: protected_tag.create_access_levels.for_role.first
+ = render_if_exists 'projects/protected_tags/protected_tag_extra_create_access_levels', protected_tag: protected_tag
diff --git a/app/views/projects/protected_tags/_protected_tag_create_access_levels.haml b/app/views/projects/protected_tags/_protected_tag_create_access_levels.haml
new file mode 100644
index 00000000000..1d4e9565156
--- /dev/null
+++ b/app/views/projects/protected_tags/_protected_tag_create_access_levels.haml
@@ -0,0 +1,8 @@
+- protected_tag = local_assigns.fetch(:protected_tag)
+- create_access_level = local_assigns.fetch(:create_access_level)
+- dropdown_label = create_access_level&.humanize || 'Select'
+
+= hidden_field_tag "allowed_to_create_#{protected_tag.id}", create_access_level&.access_level
+= dropdown_tag(dropdown_label,
+ options: { toggle_class: 'js-allowed-to-create', dropdown_class: 'dropdown-menu-selectable capitalize-header js-allowed-to-create-container',
+ data: { field_name: "allowed_to_create_#{protected_tag.id}", access_level_id: create_access_level&.id }})
diff --git a/app/views/projects/protected_tags/_update_protected_tag.haml b/app/views/projects/protected_tags/_update_protected_tag.haml
deleted file mode 100644
index cc80bd04dd0..00000000000
--- a/app/views/projects/protected_tags/_update_protected_tag.haml
+++ /dev/null
@@ -1,5 +0,0 @@
-%td
- = hidden_field_tag "allowed_to_create_#{protected_tag.id}", protected_tag.create_access_levels.first.access_level
- = dropdown_tag( (protected_tag.create_access_levels.first.humanize || 'Select') ,
- options: { toggle_class: 'js-allowed-to-create', dropdown_class: 'dropdown-menu-selectable capitalize-header js-allowed-to-create-container',
- data: { field_name: "allowed_to_create_#{protected_tag.id}", access_level_id: protected_tag.create_access_levels.first.id }})
diff --git a/app/views/projects/services/prometheus/_metrics.html.haml b/app/views/projects/services/prometheus/_metrics.html.haml
new file mode 100644
index 00000000000..98d64fafe86
--- /dev/null
+++ b/app/views/projects/services/prometheus/_metrics.html.haml
@@ -0,0 +1,30 @@
+- project = local_assigns.fetch(:project)
+
+.card.js-panel-monitored-metrics{ data: { active_metrics: active_common_project_prometheus_metrics_path(project, :json), metrics_help_path: help_page_path('user/project/integrations/prometheus_library/metrics') } }
+ .card-header
+ %h3.card-title
+ = s_('PrometheusService|Common metrics')
+ %span.badge.badge-pill.js-monitored-count 0
+ .card-body
+ .loading-metrics.js-loading-metrics
+ %p.prepend-top-10.prepend-left-10
+ = icon('spinner spin', class: 'metrics-load-spinner')
+ = s_('PrometheusService|Finding and configuring metrics...')
+ .empty-metrics.hidden.js-empty-metrics
+ %p.text-tertiary.prepend-top-10.prepend-left-10
+ = s_('PrometheusService|Waiting for your first deployment to an environment to find common metrics')
+ %ul.list-unstyled.metrics-list.hidden.js-metrics-list
+
+.card.hidden.js-panel-missing-env-vars
+ .card-header
+ %h3.card-title
+ = icon('caret-right lg fw', class: 'panel-toggle js-panel-toggle', 'aria-label' => 'Toggle panel')
+ = s_('PrometheusService|Missing environment variable')
+ %span.badge.badge-pill.js-env-var-count 0
+ .card-body.hidden
+ .flash-container
+ .flash-notice
+ .flash-text
+ = s_("PrometheusService|To set up automatic monitoring, add the environment variable %{variable} to exporter's queries." % { variable: "<code>$CI_ENVIRONMENT_SLUG</code>" }).html_safe
+ = link_to s_('PrometheusService|More information'), help_page_path('user/project/integrations/prometheus', anchor: 'metrics-and-labels')
+ %ul.list-unstyled.metrics-list.js-missing-var-metrics-list
diff --git a/app/views/projects/services/prometheus/_show.html.haml b/app/views/projects/services/prometheus/_show.html.haml
index bda597cc02b..9741b783db3 100644
--- a/app/views/projects/services/prometheus/_show.html.haml
+++ b/app/views/projects/services/prometheus/_show.html.haml
@@ -3,35 +3,8 @@
%h4.prepend-top-0
= s_('PrometheusService|Metrics')
%p
- = s_('PrometheusService|Metrics are automatically configured and monitored based on a library of metrics from popular exporters.')
- = link_to s_('PrometheusService|More information'), help_page_path('user/project/integrations/prometheus')
+ = s_('PrometheusService|Common metrics are automatically monitored based on a library of metrics from popular exporters.')
+ = link_to s_('PrometheusService|More information'), help_page_path('user/project/integrations/prometheus_library/metrics'), target: '_blank', rel: "noopener noreferrer"
.col-lg-9
- .card.js-panel-monitored-metrics{ data: { active_metrics: active_common_project_prometheus_metrics_path(@project, :json), metrics_help_path: help_page_path('user/project/integrations/prometheus_library/metrics') } }
- .card-header
- %h3.card-title
- = s_('PrometheusService|Common metrics')
- %span.badge.badge-pill.js-monitored-count 0
- .card-body
- .loading-metrics.js-loading-metrics
- %p.prepend-top-10.prepend-left-10
- = icon('spinner spin', class: 'metrics-load-spinner')
- = s_('PrometheusService|Finding and configuring metrics...')
- .empty-metrics.hidden.js-empty-metrics
- %p.text-tertiary.prepend-top-10.prepend-left-10
- = s_('PrometheusService|Waiting for your first deployment to an environment to find common metrics')
- %ul.list-unstyled.metrics-list.hidden.js-metrics-list
-
- .card.hidden.js-panel-missing-env-vars
- .card-header
- %h3.card-title
- = icon('caret-right lg fw', class: 'panel-toggle js-panel-toggle', 'aria-label' => 'Toggle panel')
- = s_('PrometheusService|Missing environment variable')
- %span.badge.badge-pill.js-env-var-count 0
- .card-body.hidden
- .flash-container
- .flash-notice
- .flash-text
- = s_("PrometheusService|To set up automatic monitoring, add the environment variable %{variable} to exporter's queries." % { variable: "<code>$CI_ENVIRONMENT_SLUG</code>" }).html_safe
- = link_to s_('PrometheusService|More information'), help_page_path('user/project/integrations/prometheus', anchor: 'metrics-and-labels')
- %ul.list-unstyled.metrics-list.js-missing-var-metrics-list
+ = render_if_exists 'projects/services/prometheus/metrics', project: @project
diff --git a/app/views/projects/tags/index.html.haml b/app/views/projects/tags/index.html.haml
index 96ecac815c0..dab95ba09f2 100644
--- a/app/views/projects/tags/index.html.haml
+++ b/app/views/projects/tags/index.html.haml
@@ -26,6 +26,8 @@
= link_to new_project_tag_path(@project), class: 'btn btn-create new-tag-btn' do
= s_('TagsPage|New tag')
+ = render_if_exists 'projects/commits/mirror_status'
+
.tags
- if @tags.any?
%ul.flex-list.content-list
diff --git a/lib/gitlab/json_logger.rb b/lib/gitlab/json_logger.rb
new file mode 100644
index 00000000000..28e258196ca
--- /dev/null
+++ b/lib/gitlab/json_logger.rb
@@ -0,0 +1,22 @@
+module Gitlab
+ class JsonLogger < ::Gitlab::Logger
+ def self.file_name_noext
+ raise NotImplementedError
+ end
+
+ def format_message(severity, timestamp, progname, message)
+ data = {}
+ data[:severity] = severity
+ data[:time] = timestamp.utc.iso8601(3)
+
+ case message
+ when String
+ data[:message] = message
+ when Hash
+ data.merge!(message)
+ end
+
+ data.to_json + "\n"
+ end
+ end
+end
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index bcc27a4f805..53eeb67672f 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -4126,6 +4126,9 @@ msgstr ""
msgid "PrometheusService|Common metrics"
msgstr ""
+msgid "PrometheusService|Common metrics are automatically monitored based on a library of metrics from popular exporters."
+msgstr ""
+
msgid "PrometheusService|Finding and configuring metrics..."
msgstr ""
@@ -4141,9 +4144,6 @@ msgstr ""
msgid "PrometheusService|Metrics"
msgstr ""
-msgid "PrometheusService|Metrics are automatically configured and monitored based on a library of metrics from popular exporters."
-msgstr ""
-
msgid "PrometheusService|Missing environment variable"
msgstr ""
diff --git a/spec/features/merge_request/user_posts_diff_notes_spec.rb b/spec/features/merge_request/user_posts_diff_notes_spec.rb
index 02d19db3828..77261f9375c 100644
--- a/spec/features/merge_request/user_posts_diff_notes_spec.rb
+++ b/spec/features/merge_request/user_posts_diff_notes_spec.rb
@@ -185,11 +185,11 @@ describe 'Merge request > User posts diff notes', :js do
end
describe 'posting a note' do
- xit 'adds as discussion' do
+ it 'adds as discussion' do
expect(page).to have_css('.js-temp-notes-holder', count: 2)
should_allow_commenting(find('[id="6eb14e00385d2fb284765eb1cd8d420d33d63fc9_22_22"]'), asset_form_reset: false)
- expect(page).to have_css('.notes_holder .note', count: 1)
+ expect(page).to have_css('.notes_holder .note.note-discussion', count: 1)
expect(page).to have_css('.js-temp-notes-holder', count: 1)
expect(page).to have_button('Reply...')
end
diff --git a/spec/lib/gitlab/json_logger_spec.rb b/spec/lib/gitlab/json_logger_spec.rb
new file mode 100644
index 00000000000..0a62785f880
--- /dev/null
+++ b/spec/lib/gitlab/json_logger_spec.rb
@@ -0,0 +1,29 @@
+# coding: utf-8
+require 'spec_helper'
+
+describe Gitlab::JsonLogger do
+ subject { described_class.new('/dev/null') }
+
+ let(:now) { Time.now }
+
+ describe '#format_message' do
+ it 'formats strings' do
+ output = subject.format_message('INFO', now, 'test', 'Hello world')
+ data = JSON.parse(output)
+
+ expect(data['severity']).to eq('INFO')
+ expect(data['time']).to eq(now.utc.iso8601(3))
+ expect(data['message']).to eq('Hello world')
+ end
+
+ it 'formats hashes' do
+ output = subject.format_message('INFO', now, 'test', { hello: 1 })
+ data = JSON.parse(output)
+
+ expect(data['severity']).to eq('INFO')
+ expect(data['time']).to eq(now.utc.iso8601(3))
+ expect(data['hello']).to eq(1)
+ expect(data['message']).to be_nil
+ end
+ end
+end