Skip to content

Commit

Permalink
Updated sessions widget to not render if there are no active sessions (
Browse files Browse the repository at this point in the history
  • Loading branch information
abujeda authored Feb 24, 2023
1 parent 747c315 commit cc72eaf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
32 changes: 14 additions & 18 deletions apps/dashboard/app/views/widgets/_sessions.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,21 @@
session_selection = active_sessions.first(max_sessions)
-%>

<%= javascript_include_tag 'sessions_poller', nonce: true %>
<%- unless session_selection.empty? %>
<%= javascript_include_tag 'sessions_poller', nonce: true %>

<div class="active-sessions-header">
<h3>
<%= t('dashboard.active_sessions_title') %>
<small><%= t('dashboard.active_sessions_caption_html', all_sessions_url: batch_connect_sessions_path, number_of_sessions: active_sessions.length) %></small>
</h3>
</div>
<div class="active-sessions-header">
<h3>
<%= t('dashboard.active_sessions_title') %>
<small><%= t('dashboard.active_sessions_caption_html', all_sessions_url: batch_connect_sessions_path, number_of_sessions: active_sessions.length) %></small>
</h3>
</div>

<div class="active-sessions-content">
<% if session_selection.empty? %>
<p class="lead">
<%= t('dashboard.active_sessions_no_sessions') %>
</p>
<% else %>
<div id="batch_connect_sessions" class="row" data-toggle="poll" data-url="<%= batch_connect_sessions_path(format: :js) %>" data-delay="<%= poll_delay %>">
<div class="col-md-12">
<%= render partial: "/batch_connect/sessions/panel", collection: session_selection, as: :session %>
<div class="active-sessions-content">
<div id="batch_connect_sessions" class="row" data-toggle="poll" data-url="<%= batch_connect_sessions_path(format: :js) %>" data-delay="<%= poll_delay %>">
<div class="col-md-12">
<%= render partial: "/batch_connect/sessions/panel", collection: session_selection, as: :session %>
</div>
</div>
</div>
<% end %>
</div>
<% end %>
1 change: 0 additions & 1 deletion apps/dashboard/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ en:
development_apps_caption: "Sandbox App"

active_sessions_title: 'Active interactive sessions'
active_sessions_no_sessions: 'You have no active sessions.'
active_sessions_caption_html: '<a href="%{all_sessions_url}"> view all (%{number_of_sessions})</a>'

recently_used_apps_title: 'Recently Used Apps'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ def setup
})
end

test 'should render active sessions widget with empty message' do
test 'should not render active sessions widget when no active sessions' do
BatchConnect::Session.stubs(:all).returns([])

get '/'

assert_select 'div.active-sessions-header h3', 1
assert_select 'div.active-sessions-content p.lead', text: I18n.t('dashboard.active_sessions_no_sessions')
assert_select 'div.active-sessions-header h3', 0
end

test 'should render active sessions widget with session card' do
Expand Down

0 comments on commit cc72eaf

Please sign in to comment.