From 84508c40b7a132b775717d2aeef313d4e370a2b9 Mon Sep 17 00:00:00 2001 From: Darby Date: Mon, 14 Sep 2015 16:37:11 -0700 Subject: PAtrially working notification button --- app/controllers/projects_controller.rb | 1 + app/helpers/notifications_helper.rb | 31 ++++++++++++++++++++++ app/views/projects/_home_panel.html.haml | 2 ++ .../projects/buttons/_notifications.html.haml | 15 +++++++++++ 4 files changed, 49 insertions(+) create mode 100644 app/views/projects/buttons/_notifications.html.haml diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index dafc11d0707..2c80f237f86 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -82,6 +82,7 @@ class ProjectsController < ApplicationController if @project.empty_repo? render 'projects/empty' else + @membership_id = @project.project_members.where(user_id: current_user.id).first render :show end else diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index 2f8e64c375f..db6fe3b29ed 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -12,4 +12,35 @@ module NotificationsHelper icon('circle-o', class: 'ns-default') end end + + def notification_list_item(notification_level) + case notification_level + when Notification::N_DISABLED + content_tag(:li) do + icon('microphone-slash') do + 'Disabled' + end + end + when Notification::N_PARTICIPATING + content_tag(:li) do + icon('volume-up') do + 'Participating' + end + end + when Notification::N_WATCH + content_tag(:li) do + icon('globe') do + 'Watch' + end + end + when Notification::N_MENTION + content_tag(:li) do + icon('at') do + 'Mention' + end + end + else + # do nothing + end + end end diff --git a/app/views/projects/_home_panel.html.haml b/app/views/projects/_home_panel.html.haml index b93036e78e6..67a00b4ebef 100644 --- a/app/views/projects/_home_panel.html.haml +++ b/app/views/projects/_home_panel.html.haml @@ -25,6 +25,8 @@ = icon('download fw') Download + = render 'projects/buttons/notifications' + = render 'projects/buttons/dropdown' = render "shared/clone_panel" diff --git a/app/views/projects/buttons/_notifications.html.haml b/app/views/projects/buttons/_notifications.html.haml new file mode 100644 index 00000000000..fb30868fc6b --- /dev/null +++ b/app/views/projects/buttons/_notifications.html.haml @@ -0,0 +1,15 @@ +- if current_user and !@membership_id.nil? + %span.dropdown + = form_tag profile_notifications_path, method: :put, remote: true do + = hidden_field_tag :notification_type, 'project' + = hidden_field_tag :notification_id, @membership_id + %a.dropdown-toggle.btn.btn-new{href: '#', "data-toggle" => "dropdown"} + = icon('bell') + Notifications + %ul.dropdown-menu.dropdown-menu-right.project-home-dropdown + - Notification.notification_levels.each do | level | + = notification_list_item(level) + + + + -- cgit v1.2.1