Skip to content

Commit

Permalink
Merge pull request #177 from hpi-swt2/layout-fixes
Browse files Browse the repository at this point in the history
Move chat to new page, remove second navbar
  • Loading branch information
frcroth authored Feb 5, 2021
2 parents d87e2d6 + 6aae4f7 commit f7419e6
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 24 deletions.
9 changes: 9 additions & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ def filter_users_status
@users = @users.sample(maximum_length_user_list)
end

def chat
if user_signed_in?
@room_messages = Room.global_chat_room.room_messages
render 'home/chat_page'
else
render 'index'
end
end

private

def maximum_length_user_list
Expand Down
5 changes: 5 additions & 0 deletions app/views/home/chat_page.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<%= stylesheet_link_tag 'home', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= stylesheet_link_tag 'home_mobile', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= render 'chat' %>
21 changes: 2 additions & 19 deletions app/views/home/dashboard.html+mobile.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,8 @@

<div id="dashboard">
<div id="content">
<div class="tab-content">
<div id="users" class="tab-pane fade show active">
<div id="users">
<%= render 'users' %>
</div>
<div id="chat" class="tab-pane fade">
<%= render 'chat' %>
</div>
</div>
</div>
<div id="navigation">
<ul class="nav nav-pills nav-justified">
<li class="nav-item">
<a class="nav-link active" data-toggle="pill" href="#users">
<i class="fa fa-group"></i>
</a></li>
<li class="nav-item">
<a class="nav-link" data-toggle="pill" href="#chat">
<i class="fa fa-comments"></i>
</a></li>
</ul>
</div>
</div>
</div>
10 changes: 5 additions & 5 deletions app/views/layouts/_footer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
<div id="navigation">
<ul class="nav nav-pills nav-justified">
<li class="nav-item">
<!-- new path to this when dashboard is rewritten -->
<a class="nav-link <%= active_link_to_class(root_path, active: :exclusive)%>" href="<%= root_url %>">
<i class="fa fa-home"></i>
</a></li>
<li class="nav-item">
<!-- please update the path when reworked the chat -->
<a class="nav-link <%= active_link_to_class(root_path, active: :exclusive)%>" href="<%= root_url %>">
<a class="nav-link <%= active_link_to_class(chat_path, active: :exclusive)%>" href="<%= chat_path %>">
<i class="fa fa-comments"></i>
</a></li>
<li class="nav-item">
<a class="nav-link <%= active_link_to_class(user_contacts_path(current_user), active: :exclusive)%>" href="<%= user_contacts_path(current_user) %>">
<a class="nav-link <%= active_link_to_class(user_contacts_path(current_user), active: :exclusive)%>"
href="<%= user_contacts_path(current_user) %>">
<i class="fa fa-address-book"></i>
</a></li>
<li class="nav-item">
Expand All @@ -21,7 +20,8 @@
<i class="fa fa-history"></i>
</a></li>
<li class="nav-item">
<a class="nav-link <%= active_link_to_class(edit_user_path(current_user), active: :exclusive)%>" href="<%= edit_user_path(current_user) %>">
<a class="nav-link <%= active_link_to_class(edit_user_path(current_user), active: :exclusive)%>"
href="<%= edit_user_path(current_user) %>">
<i class="fa fa-cog"></i>
</a></li>
</ul>
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@

resources :activities, only: :create
resources :jitsi_calls, only: :create

get 'chat', to: 'home#chat'
end
22 changes: 22 additions & 0 deletions spec/requests/chat_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'rails_helper'

RSpec.describe 'Chat', type: :request do
let(:user) { FactoryBot.create :user }

describe 'GET chat/' do
context 'when signed in' do
it 'returns http success' do
sign_in user
get chat_path
expect(response).to have_http_status(:success)
end
end

context 'when not signed in' do
it 'returns http success' do
get chat_path
expect(response).to have_http_status(:success)
end
end
end
end

0 comments on commit f7419e6

Please sign in to comment.