Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added notifications #161

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions app/views/layouts/_navbar.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<%# https://getbootstrap.com/docs/4.5/components/navbar/ %>
<nav class="navbar navbar-expand-md navbar-dark bg-dark">
<div class="navbar-brand"><%= link_to I18n.t('index.portal_name'), root_path, class: 'portal-link' %></div>
<form class="form-inline">
<i class="fa fa-bell" style="color: white; padding: 10px"></i>
<a href="<%= search_users_path %>"><i class="fa fa-search" style="color: white; padding: 10px"></i> </a>
</form>
<% if user_signed_in? %>
<form class="form-inline">
<% if current_user.contact_requests.any? %>
rheaSPK marked this conversation as resolved.
Show resolved Hide resolved
<a href="<%= user_contact_requests_path(current_user) %>"> <i class="fa fa-bell" style="color: red; padding: 3px"></i> </a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would extract all styles into an appropriate css file

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't like to do that, because if someone else uses the bell icon, they don't necessarily want my styling...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but you could use a class like notification-bell or something like that. I just don't like to have HTML, CSS and application logic all in one file 😅 But if you prefer the inline styling that's fine for me because it's not such a big issue 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @felixauringer. If someone doesn't like the styling, the class can be changed even easier

<span class="badge badge-pill badge-danger"> <%= current_user.contact_requests.length %> </span>
rheaSPK marked this conversation as resolved.
Show resolved Hide resolved
<% else %>
<i class="fa fa-bell" style="color: white; padding: 10px"></i>
<% end %>
<a href="<%= search_users_path %>"><i class="fa fa-search" style="color: white; padding: 10px"></i> </a>
</form>
<% end %>
<%= render 'layouts/navbar_desktop_part' %>
</nav>
rheaSPK marked this conversation as resolved.
Show resolved Hide resolved
16 changes: 16 additions & 0 deletions spec/features/header_and_footer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,20 @@
expect(page).not_to have_link('My contacts')
end
end

describe 'notification' do
let(:alice) { FactoryBot.create :user }
let(:bob) { FactoryBot.create :user }

before do
alice.contact_requests << bob # bob added a contact request for alice
sign_in alice
visit notes_path
end

it 'shows the number of notifications in the navbar' do
element = page.find('nav.navbar')
expect(element).to have_text '1'
end
end
end