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:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-12 06:07:34 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-12 06:07:34 +0300
commit2ccde70b80730fd52f75797e7d711748fb5b769b (patch)
treebb5b1c2dfa4f99381eabcb0f7783e55d9fad073d
parent2e3cbf7d89815e2915f77677388c49b48f8d20c3 (diff)
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--changelogs/unreleased/nicolasdular-add-broadcast-target-to-api.yml5
-rw-r--r--doc/api/broadcast_messages.md12
-rw-r--r--lib/api/broadcast_messages.rb20
-rw-r--r--lib/api/entities.rb2
-rw-r--r--lib/gitlab/usage_data.rb1
-rw-r--r--spec/lib/gitlab/usage_data_spec.rb3
-rw-r--r--spec/requests/api/broadcast_messages_spec.rb22
7 files changed, 49 insertions, 16 deletions
diff --git a/changelogs/unreleased/nicolasdular-add-broadcast-target-to-api.yml b/changelogs/unreleased/nicolasdular-add-broadcast-target-to-api.yml
new file mode 100644
index 00000000000..209ac388a32
--- /dev/null
+++ b/changelogs/unreleased/nicolasdular-add-broadcast-target-to-api.yml
@@ -0,0 +1,5 @@
+---
+title: Add target_path to broadcast message API
+merge_request: 21430
+author:
+type: added
diff --git a/doc/api/broadcast_messages.md b/doc/api/broadcast_messages.md
index 357d9916ade..ce68eec87ff 100644
--- a/doc/api/broadcast_messages.md
+++ b/doc/api/broadcast_messages.md
@@ -34,7 +34,8 @@ Example response:
"color":"#E75E40",
"font":"#FFFFFF",
"id":1,
- "active": false
+ "active": false,
+ "target_path": "*/welcome"
}
]
```
@@ -69,7 +70,8 @@ Example response:
"color":"#cecece",
"font":"#FFFFFF",
"id":1,
- "active":false
+ "active":false,
+ "target_path": "*/welcome"
}
```
@@ -107,7 +109,8 @@ Example response:
"color":"#cecece",
"font":"#FFFFFF",
"id":1,
- "active": true
+ "active": true,
+ "target_path": "*/welcome"
}
```
@@ -146,7 +149,8 @@ Example response:
"color":"#000",
"font":"#FFFFFF",
"id":1,
- "active": true
+ "active": true,
+ "target_path": "*/welcome"
}
```
diff --git a/lib/api/broadcast_messages.rb b/lib/api/broadcast_messages.rb
index 19148758fc5..994e12445b7 100644
--- a/lib/api/broadcast_messages.rb
+++ b/lib/api/broadcast_messages.rb
@@ -32,11 +32,12 @@ module API
success Entities::BroadcastMessage
end
params do
- requires :message, type: String, desc: 'Message to display'
+ requires :message, type: String, desc: 'Message to display'
optional :starts_at, type: DateTime, desc: 'Starting time', default: -> { Time.zone.now }
- optional :ends_at, type: DateTime, desc: 'Ending time', default: -> { 1.hour.from_now }
- optional :color, type: String, desc: 'Background color'
- optional :font, type: String, desc: 'Foreground color'
+ optional :ends_at, type: DateTime, desc: 'Ending time', default: -> { 1.hour.from_now }
+ optional :color, type: String, desc: 'Background color'
+ optional :font, type: String, desc: 'Foreground color'
+ optional :target_path, type: String, desc: 'Target path'
end
post do
message = BroadcastMessage.create(declared_params(include_missing: false))
@@ -66,12 +67,13 @@ module API
success Entities::BroadcastMessage
end
params do
- requires :id, type: Integer, desc: 'Broadcast message ID'
- optional :message, type: String, desc: 'Message to display'
+ requires :id, type: Integer, desc: 'Broadcast message ID'
+ optional :message, type: String, desc: 'Message to display'
optional :starts_at, type: DateTime, desc: 'Starting time'
- optional :ends_at, type: DateTime, desc: 'Ending time'
- optional :color, type: String, desc: 'Background color'
- optional :font, type: String, desc: 'Foreground color'
+ optional :ends_at, type: DateTime, desc: 'Ending time'
+ optional :color, type: String, desc: 'Background color'
+ optional :font, type: String, desc: 'Foreground color'
+ optional :target_path, type: String, desc: 'Target path'
end
put ':id' do
message = find_message
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index f89070ea1cb..8a60127ff59 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -1217,7 +1217,7 @@ module API
end
class BroadcastMessage < Grape::Entity
- expose :message, :starts_at, :ends_at, :color, :font
+ expose :message, :starts_at, :ends_at, :color, :font, :target_path
end
class ApplicationStatistics < Grape::Entity
diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb
index 7268e11ff23..ec2243345e1 100644
--- a/lib/gitlab/usage_data.rb
+++ b/lib/gitlab/usage_data.rb
@@ -82,6 +82,7 @@ module Gitlab
grafana_integrated_projects: count(GrafanaIntegration.enabled),
groups: count(Group),
issues: count(Issue),
+ issues_created_from_gitlab_error_tracking_ui: count(SentryIssue),
issues_with_associated_zoom_link: count(ZoomMeeting.added_to_issue),
issues_using_zoom_quick_actions: count(ZoomMeeting.select(:issue_id).distinct),
issues_with_embedded_grafana_charts_approx: ::Gitlab::GrafanaEmbedUsageData.issue_count,
diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb
index 7a5d6f5ad5a..6ab23b00d5c 100644
--- a/spec/lib/gitlab/usage_data_spec.rb
+++ b/spec/lib/gitlab/usage_data_spec.rb
@@ -27,6 +27,7 @@ describe Gitlab::UsageData do
create_list(:zoom_meeting, 2, project: projects[0], issue: projects[0].issues[1], issue_status: :removed)
create(:zoom_meeting, project: projects[0], issue: projects[0].issues[2], issue_status: :added)
create_list(:zoom_meeting, 2, project: projects[0], issue: projects[0].issues[2], issue_status: :removed)
+ create(:sentry_issue, issue: projects[0].issues[0])
# Enabled clusters
gcp_cluster = create(:cluster_provider_gcp, :created).cluster
@@ -152,6 +153,7 @@ describe Gitlab::UsageData do
grafana_integrated_projects
groups
issues
+ issues_created_from_gitlab_error_tracking_ui
issues_with_associated_zoom_link
issues_using_zoom_quick_actions
issues_with_embedded_grafana_charts_approx
@@ -212,6 +214,7 @@ describe Gitlab::UsageData do
expect(count_data[:projects_mattermost_active]).to eq(1)
expect(count_data[:projects_with_repositories_enabled]).to eq(3)
expect(count_data[:projects_with_error_tracking_enabled]).to eq(1)
+ expect(count_data[:issues_created_from_gitlab_error_tracking_ui]).to eq(1)
expect(count_data[:issues_with_associated_zoom_link]).to eq(2)
expect(count_data[:issues_using_zoom_quick_actions]).to eq(3)
expect(count_data[:issues_with_embedded_grafana_charts_approx]).to eq(2)
diff --git a/spec/requests/api/broadcast_messages_spec.rb b/spec/requests/api/broadcast_messages_spec.rb
index 541acb29857..9dc639a25a2 100644
--- a/spec/requests/api/broadcast_messages_spec.rb
+++ b/spec/requests/api/broadcast_messages_spec.rb
@@ -29,7 +29,7 @@ describe API::BroadcastMessages do
expect(response).to include_pagination_headers
expect(json_response).to be_kind_of(Array)
expect(json_response.first.keys)
- .to match_array(%w(id message starts_at ends_at color font active))
+ .to match_array(%w(id message starts_at ends_at color font active target_path))
end
end
@@ -52,7 +52,7 @@ describe API::BroadcastMessages do
expect(response).to have_gitlab_http_status(200)
expect(json_response['id']).to eq message.id
expect(json_response.keys)
- .to match_array(%w(id message starts_at ends_at color font active))
+ .to match_array(%w(id message starts_at ends_at color font active target_path))
end
end
@@ -100,6 +100,15 @@ describe API::BroadcastMessages do
expect(json_response['color']).to eq attrs[:color]
expect(json_response['font']).to eq attrs[:font]
end
+
+ it 'accepts a target path' do
+ attrs = attributes_for(:broadcast_message, target_path: "*/welcome")
+
+ post api('/broadcast_messages', admin), params: attrs
+
+ expect(response).to have_gitlab_http_status(201)
+ expect(json_response['target_path']).to eq attrs[:target_path]
+ end
end
end
@@ -150,6 +159,15 @@ describe API::BroadcastMessages do
expect(response).to have_gitlab_http_status(200)
expect { message.reload }.to change { message.message }.to('new message')
end
+
+ it 'accepts a new target_path' do
+ attrs = { target_path: '*/welcome' }
+
+ put api("/broadcast_messages/#{message.id}", admin), params: attrs
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(json_response['target_path']).to eq attrs[:target_path]
+ end
end
end