Commit 279d3314 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '214061-enable-realtime-sidebar-when-actioncable-in-app' into 'master'

Enable real-time assignees when ActionCable in-app

See merge request gitlab-org/gitlab!38204
parents 0f21f8dc 98f5014b
......@@ -51,7 +51,10 @@ class Projects::IssuesController < Projects::ApplicationController
end
before_action only: :show do
push_frontend_feature_flag(:real_time_issue_sidebar, @project)
real_time_feature_flag = :real_time_issue_sidebar
real_time_enabled = Gitlab::ActionCable::Config.in_app? || Feature.enabled?(real_time_feature_flag, @project)
gon.push({ features: { real_time_feature_flag.to_s.camelize(:lower) => real_time_enabled } }, true)
end
before_action only: :index do
......
......@@ -22,7 +22,7 @@ module Issues
end
def after_update(issue)
IssuesChannel.broadcast_to(issue, event: 'updated') if Feature.enabled?(:broadcast_issue_updates, issue.project)
IssuesChannel.broadcast_to(issue, event: 'updated') if Gitlab::ActionCable::Config.in_app? || Feature.enabled?(:broadcast_issue_updates, issue.project)
end
def handle_changes(issue, options)
......
......@@ -109,6 +109,15 @@ Key actions for Issues include:
On an issue's page, you can view [all aspects of the issue](issue_data_and_actions.md),
and modify them if you have the necessary [permissions](../../permissions.md).
#### Real-time sidebar **(CORE ONLY)**
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/17589) in GitLab 13.3.
> - It cannot be enabled or disabled per-project.
> - It's not recommended for production use.
Assignees in the sidebar are updated in real time. This feature is **disabled by default**.
To enable, you need to enable [ActionCable in-app mode](https://docs.gitlab.com/omnibus/settings/actioncable.html).
### Issues list
![Project issues list view](img/project_issues_list_view.png)
......
......@@ -964,6 +964,33 @@ RSpec.describe Projects::IssuesController do
expect { issue.update(description: [issue.description, labels].join(' ')) }
.not_to exceed_query_limit(control_count + 2 * labels.count)
end
context 'real-time sidebar feature flag' do
using RSpec::Parameterized::TableSyntax
let_it_be(:project) { create(:project, :public) }
let_it_be(:issue) { create(:issue, project: project) }
where(:action_cable_in_app_enabled, :feature_flag_enabled, :gon_feature_flag) do
true | true | true
true | false | true
false | true | true
false | false | false
end
with_them do
before do
expect(Gitlab::ActionCable::Config).to receive(:in_app?).and_return(action_cable_in_app_enabled)
stub_feature_flags(real_time_issue_sidebar: feature_flag_enabled)
end
it 'broadcasts to the issues channel based on ActionCable and feature flag values' do
go(id: issue.to_param)
expect(Gon.features).to include('realTimeIssueSidebar' => gon_feature_flag)
end
end
end
end
describe 'GET #realtime_changes' do
......
......@@ -840,27 +840,27 @@ RSpec.describe Issues::UpdateService, :mailer do
end
context 'real-time updates' do
let(:update_params) { { assignee_ids: [user2.id] } }
using RSpec::Parameterized::TableSyntax
context 'when broadcast_issue_updates is enabled' do
before do
stub_feature_flags(broadcast_issue_updates: true)
end
it 'broadcasts to the issues channel' do
expect(IssuesChannel).to receive(:broadcast_to).with(issue, event: 'updated')
let(:update_params) { { assignee_ids: [user2.id] } }
update_issue(update_params)
end
where(:action_cable_in_app_enabled, :feature_flag_enabled, :should_broadcast) do
true | true | true
true | false | true
false | true | true
false | false | false
end
context 'when broadcast_issue_updates is disabled' do
before do
stub_feature_flags(broadcast_issue_updates: false)
end
with_them do
it 'broadcasts to the issues channel based on ActionCable and feature flag values' do
expect(Gitlab::ActionCable::Config).to receive(:in_app?).and_return(action_cable_in_app_enabled)
stub_feature_flags(broadcast_issue_updates: feature_flag_enabled)
it 'does not broadcast to the issues channel' do
expect(IssuesChannel).not_to receive(:broadcast_to)
if should_broadcast
expect(IssuesChannel).to receive(:broadcast_to).with(issue, event: 'updated')
else
expect(IssuesChannel).not_to receive(:broadcast_to)
end
update_issue(update_params)
end
......
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