Commit afde2d0b authored by Gabriel Mazetto's avatar Gabriel Mazetto

Merge branch '235766-deep-links-for-selected-value-stream' into 'master'

Add deep links for selected value stream

Closes #235766

See merge request gitlab-org/gitlab!43105
parents 07e89322 3112b106
...@@ -10,6 +10,7 @@ class Groups::Analytics::CycleAnalyticsController < Groups::Analytics::Applicati ...@@ -10,6 +10,7 @@ class Groups::Analytics::CycleAnalyticsController < Groups::Analytics::Applicati
before_action :load_group, only: :show before_action :load_group, only: :show
before_action :load_project, only: :show before_action :load_project, only: :show
before_action :load_value_stream, only: :show
before_action :request_params, only: :show before_action :request_params, only: :show
before_action do before_action do
...@@ -28,6 +29,12 @@ class Groups::Analytics::CycleAnalyticsController < Groups::Analytics::Applicati ...@@ -28,6 +29,12 @@ class Groups::Analytics::CycleAnalyticsController < Groups::Analytics::Applicati
override :all_cycle_analytics_params override :all_cycle_analytics_params
def all_cycle_analytics_params def all_cycle_analytics_params
super.merge({ group: @group }) super.merge({ group: @group, value_stream: @value_stream })
end
def load_value_stream
return unless @group && params[:value_stream_id]
@value_stream = @group.value_streams.find(params[:value_stream_id])
end end
end end
...@@ -34,6 +34,7 @@ module Gitlab ...@@ -34,6 +34,7 @@ module Gitlab
attribute :created_before, :datetime attribute :created_before, :datetime
attribute :group attribute :group
attribute :current_user attribute :current_user
attribute :value_stream
FINDER_PARAM_NAMES.each do |param_name| FINDER_PARAM_NAMES.each do |param_name|
attribute param_name attribute param_name
...@@ -68,6 +69,7 @@ module Gitlab ...@@ -68,6 +69,7 @@ module Gitlab
def to_data_attributes def to_data_attributes
{}.tap do |attrs| {}.tap do |attrs|
attrs[:group] = group_data_attributes if group attrs[:group] = group_data_attributes if group
attrs[:value_stream] = value_stream_data_attributes if value_stream
attrs[:created_after] = created_after.to_date.iso8601 attrs[:created_after] = created_after.to_date.iso8601
attrs[:created_before] = created_before.to_date.iso8601 attrs[:created_before] = created_before.to_date.iso8601
attrs[:projects] = group_projects(project_ids) if group && project_ids.present? attrs[:projects] = group_projects(project_ids) if group && project_ids.present?
...@@ -90,6 +92,12 @@ module Gitlab ...@@ -90,6 +92,12 @@ module Gitlab
} }
end end
def value_stream_data_attributes
{
id: value_stream.id
}
end
def group_projects(project_ids) def group_projects(project_ids)
GroupProjectsFinder.new( GroupProjectsFinder.new(
group: group, group: group,
......
...@@ -62,4 +62,16 @@ RSpec.describe Groups::Analytics::CycleAnalyticsController do ...@@ -62,4 +62,16 @@ RSpec.describe Groups::Analytics::CycleAnalyticsController do
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
context 'with group and value stream params' do
let(:value_stream) { create(:cycle_analytics_group_value_stream, group: group) }
it 'builds request params with group and value stream' do
expect_next_instance_of(Gitlab::Analytics::CycleAnalytics::RequestParams) do |instance|
expect(instance).to have_attributes(group: group, value_stream: value_stream)
end
get(:show, params: { group_id: group, value_stream_id: value_stream })
end
end
end end
...@@ -168,6 +168,26 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::RequestParams do ...@@ -168,6 +168,26 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::RequestParams do
end end
end end
describe 'optional `value_stream`' do
context 'when `value_stream` is not empty' do
let(:value_stream) { instance_double('Analytics::CycleAnalytics::GroupValueStream') }
before do
params[:value_stream] = value_stream
end
it { expect(subject.value_stream).to eq(value_stream) }
end
context 'when `value_stream` is nil' do
before do
params[:value_stream] = nil
end
it { expect(subject.value_stream).to eq(nil) }
end
end
describe 'issuable filter params' do describe 'issuable filter params' do
before do before do
params.merge!( params.merge!(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment