Skip to content

Commit 9dd4ee3

Browse files
author
Vidas P
committed
Remove cookie based agent hiding
1 parent a937c0c commit 9dd4ee3

File tree

4 files changed

+0
-59
lines changed

4 files changed

+0
-59
lines changed

app/controllers/agents_controller.rb

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ class AgentsController < ApplicationController
66
def index
77
@agents = current_user.agents.includes(:receivers)
88

9-
@agents = @agents.where(disabled: false) if show_only_enabled_agents?
10-
119
# Trigger undefined agents handling.
1210
@agents.map { |agent| agent } if current_user.undefined_agent_types
1311

@@ -57,16 +55,6 @@ def table
5755
render json: rows
5856
end
5957

60-
def toggle_visibility
61-
if show_only_enabled_agents?
62-
mark_all_agents_viewable
63-
else
64-
set_only_enabled_agents_as_viewable
65-
end
66-
67-
redirect_to agents_path
68-
end
69-
7058
def handle_details_post
7159
@agent = current_user.agents.find(params[:id])
7260
if @agent.respond_to?(:handle_details_post)
@@ -285,21 +273,6 @@ def initialize_presenter
285273

286274
private
287275

288-
def show_only_enabled_agents?
289-
!!cookies[:active_workflow_view_only_enabled_agents]
290-
end
291-
292-
def set_only_enabled_agents_as_viewable
293-
cookies[:active_workflow_view_only_enabled_agents] = {
294-
value: 'true',
295-
expires: 1.year.from_now
296-
}
297-
end
298-
299-
def mark_all_agents_viewable
300-
cookies.delete(:active_workflow_view_only_enabled_agents)
301-
end
302-
303276
def set_workflow
304277
return unless params[:workflow_id]
305278

app/helpers/agent_helper.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ def agent_show_view(agent)
66
end
77
end
88

9-
def toggle_disabled_text
10-
if cookies[:active_workflow_view_only_enabled_agents]
11-
' Show Disabled Agents'
12-
else
13-
' Hide Disabled Agents'
14-
end
15-
end
16-
179
def workflow_links(agent)
1810
agent.workflows.map { |workflow|
1911
link_to(workflow.name, workflow, class: 'badge', style: style_colors(workflow))

app/views/agents/_buttons.html.erb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
<div class="d-flex justify-content-end">
22
<%= link_to icon_tag('fa-plus') + ' New Agent', new_agent_path, class: "btn btn-primary btn-sm" %>
3-
<%= link_to icon_tag('fa-adjust') + toggle_disabled_text, toggle_visibility_agents_path, method: :put, class: "btn btn-primary btn-sm" %>
43
</div>

spec/controllers/agents_controller_spec.rb

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@ def valid_attributes(options = {})
1616
get :index
1717
expect(assigns(:agents).all? { |i| expect(i.user).to eq(users(:bob)) }).to be_truthy
1818
end
19-
20-
it 'should not show disabled agents if the cookie is set' do
21-
@request.cookies['active_workflow_view_only_enabled_agents'] = 'true'
22-
23-
sign_in users(:bob)
24-
get :index
25-
expect(assigns(:agents).map(&:disabled).uniq).to eq([false])
26-
end
2719
end
2820

2921
describe 'GET table' do
@@ -86,21 +78,6 @@ def valid_attributes(options = {})
8678
end
8779
end
8880

89-
describe 'PUT toggle_visibility' do
90-
it 'should set the cookie' do
91-
sign_in users(:jane)
92-
put :toggle_visibility
93-
expect(response.cookies['active_workflow_view_only_enabled_agents']).to eq('true')
94-
end
95-
96-
it 'should delete the cookie' do
97-
@request.cookies['active_workflow_view_only_enabled_agents'] = 'true'
98-
sign_in users(:jane)
99-
put :toggle_visibility
100-
expect(response.cookies['active_workflow_view_only_enabled_agents']).to be_nil
101-
end
102-
end
103-
10481
describe 'GET show' do
10582
it 'only shows Agents for the current user' do
10683
sign_in users(:bob)

0 commit comments

Comments
 (0)