diff options
author | Felipe Artur <felipefac@gmail.com> | 2016-06-14 15:36:36 -0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2016-06-16 23:34:21 -0300 |
commit | f82ab42d0534950c1ceb458e0152f329df80ae9d (patch) | |
tree | fbb3d51a8d2c899eb5037176ff3c247b09b68793 /app/views | |
parent | 5c45d5933faa0cc27e1b465322067bd2861b3e47 (diff) | |
download | gitlab-ce-f82ab42d0534950c1ceb458e0152f329df80ae9d.tar.gz |
Re-use notifications dropdown on user profile
Diffstat (limited to 'app/views')
-rw-r--r-- | app/views/notifications/buttons/_notifications.html.haml | 25 | ||||
-rw-r--r-- | app/views/profiles/notifications/_group_settings.html.haml | 3 | ||||
-rw-r--r-- | app/views/profiles/notifications/_project_settings.html.haml | 3 | ||||
-rw-r--r-- | app/views/profiles/notifications/show.html.haml | 10 | ||||
-rw-r--r-- | app/views/projects/_home_panel.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/buttons/_notifications.html.haml | 21 | ||||
-rw-r--r-- | app/views/shared/notifications/_custom_notifications.html.haml (renamed from app/views/shared/projects/_custom_notifications.html.haml) | 9 | ||||
-rw-r--r-- | app/views/shared/notifications/_notification_dropdown.html.haml | 12 | ||||
-rw-r--r-- | app/views/shared/projects/_notification_dropdown.html.haml | 9 |
9 files changed, 50 insertions, 44 deletions
diff --git a/app/views/notifications/buttons/_notifications.html.haml b/app/views/notifications/buttons/_notifications.html.haml new file mode 100644 index 00000000000..5e81e6c96b9 --- /dev/null +++ b/app/views/notifications/buttons/_notifications.html.haml @@ -0,0 +1,25 @@ +- if notification_setting + .dropdown.notification-dropdown.pull-right + - url = notification_setting.persisted? ? notification_setting_path(notification_setting) : notification_settings_path(notification_setting) + + = form_for notification_setting, remote: true, html: { class: "inline", id: "notification-form" } do |f| + = hidden_setting_source_input(notification_setting) + = f.hidden_field :level, class: "notification_setting_level" + .js-notification-toggle-btns + .btn-group + - if notification_setting.level != "custom" + %button.dropdown-new.btn.btn-default.notifications-btn#notifications-button{ type: "button", data: { toggle: "dropdown", target: notifications_menu_identifier("dropdown", notification_setting) } } + = icon("bell", class: "js-notification-loading") + = notification_title(notification_setting.level) + = icon("caret-down") + - else + %button.dropdown-new.btn.btn-default.notifications-btn#notifications-button{ type: "button", data: { toggle: "modal", target: "#" + notifications_menu_identifier("modal", notification_setting) } } + = icon("bell", class: "js-notification-loading") + = notification_title(notification_setting.level) + %button.btn.btn-danger.dropdown-toggle{ data: { toggle: "dropdown", target: notifications_menu_identifier("dropdown", notification_setting) } } + %span.caret + .sr-only Toggle dropdown + = render "shared/notifications/notification_dropdown", notification_setting: notification_setting + + = content_for :scripts_body do + = render "shared/notifications/custom_notifications", notification_setting: notification_setting diff --git a/app/views/profiles/notifications/_group_settings.html.haml b/app/views/profiles/notifications/_group_settings.html.haml index f0cf82afe83..04becd5d860 100644 --- a/app/views/profiles/notifications/_group_settings.html.haml +++ b/app/views/profiles/notifications/_group_settings.html.haml @@ -9,5 +9,4 @@ = link_to group.name, group_path(group) .pull-right - = form_for [group, setting], remote: true, html: { class: 'update-notifications' } do |f| - = f.select :level, NotificationSetting.levels.keys, {}, class: 'form-control trigger-submit' + = render 'notifications/buttons/notifications', notification_setting: setting diff --git a/app/views/profiles/notifications/_project_settings.html.haml b/app/views/profiles/notifications/_project_settings.html.haml index e0fad555c09..664a17418db 100644 --- a/app/views/profiles/notifications/_project_settings.html.haml +++ b/app/views/profiles/notifications/_project_settings.html.haml @@ -9,5 +9,4 @@ = link_to_project(project) .pull-right - = form_for [project.namespace.becomes(Namespace), project, setting], remote: true, html: { class: 'update-notifications' } do |f| - = f.select :level, NotificationSetting.levels.keys, {}, class: 'form-control trigger-submit' + = render 'notifications/buttons/notifications', notification_setting: setting diff --git a/app/views/profiles/notifications/show.html.haml b/app/views/profiles/notifications/show.html.haml index f2659ac14b5..ef65ac53302 100644 --- a/app/views/profiles/notifications/show.html.haml +++ b/app/views/profiles/notifications/show.html.haml @@ -24,12 +24,12 @@ .form-group = f.label :notification_email, class: "label-light" = f.select :notification_email, @user.all_emails, { include_blank: false }, class: "select2" - .form-group - = f.label :notification_level, class: 'label-light' - = notification_level_radio_buttons - .prepend-top-default - = f.submit 'Update settings', class: "btn btn-create" + .form-group.pull-left + = render 'notifications/buttons/notifications', notification_setting: @global_notification_setting + + .clearfix + %hr %h5 Groups (#{@group_notifications.count}) diff --git a/app/views/projects/_home_panel.html.haml b/app/views/projects/_home_panel.html.haml index f5bc1b4e409..df725d81a39 100644 --- a/app/views/projects/_home_panel.html.haml +++ b/app/views/projects/_home_panel.html.haml @@ -32,7 +32,7 @@ .project-repo-buttons.btn-group.project-right-buttons = render "projects/buttons/download" = render 'projects/buttons/dropdown' - = render 'projects/buttons/notifications' + = render 'notifications/buttons/notifications', notification_setting: @notification_setting :javascript new Star(); diff --git a/app/views/projects/buttons/_notifications.html.haml b/app/views/projects/buttons/_notifications.html.haml deleted file mode 100644 index 47a12e6f8cb..00000000000 --- a/app/views/projects/buttons/_notifications.html.haml +++ /dev/null @@ -1,21 +0,0 @@ -- if @notification_setting - .dropdown.notification-dropdown.pull-right - = form_for @notification_setting, url: namespace_project_notification_setting_path(@project.namespace.becomes(Namespace), @project), method: :patch, remote: true, html: { class: "inline", id: "notification-form" } do |f| - = f.hidden_field :level - .js-notification-toggle-btns - - if @notification_setting.level != "custom" - %button.dropdown-new.btn.btn-default.notifications-btn#notifications-button{ type: "button", data: { toggle: "dropdown", target: ".notification-dropdown" } } - = icon("bell", class: "js-notification-loading") - = notification_title(@notification_setting.level) - = icon("caret-down") - - else - .btn-group - %button.dropdown-new.btn.btn-default.notifications-btn#notifications-button{ type: "button", data: { toggle: "modal", target: "#custom-notifications-modal" } } - = icon("bell", class: "js-notification-loading") - = notification_title(@notification_setting.level) - %button.btn.btn-danger.dropdown-toggle{ data: { toggle: "dropdown", target: ".notification-dropdown" } } - %span.caret - .sr-only Toggle dropdown - = render "shared/projects/notification_dropdown" - = content_for :scripts_body do - = render "shared/projects/custom_notifications" diff --git a/app/views/shared/projects/_custom_notifications.html.haml b/app/views/shared/notifications/_custom_notifications.html.haml index 4e446fe2d10..f0b46c7a4c0 100644 --- a/app/views/shared/projects/_custom_notifications.html.haml +++ b/app/views/shared/notifications/_custom_notifications.html.haml @@ -1,4 +1,4 @@ -#custom-notifications-modal.modal.fade{ tabindex: "-1", role: "dialog", aria: { labelledby: "custom-notifications-title" } } +.modal.fade{ tabindex: "-1", role: "dialog", id: notifications_menu_identifier("modal", notification_setting), aria: { labelledby: "custom-notifications-title" } } .modal-dialog .modal-content .modal-header @@ -6,10 +6,11 @@ %span{ aria: { hidden: "true" } } × %h4#custom-notifications-title.modal-title Custom notification events + .modal-body .container-fluid - = form_for @notification_setting, url: namespace_project_notification_setting_path(@project.namespace.becomes(Namespace), @project), method: :patch, html: { class: "custom-notifications-form" } do |f| - = f.hidden_field :level + = form_for notification_setting, html: { class: "custom-notifications-form" } do |f| + = hidden_setting_source_input(notification_setting) .row .col-lg-3 %h4.prepend-top-0 @@ -20,7 +21,7 @@ .form-group .checkbox{ class: ("prepend-top-0" if index == 0) } %label{ for: "events_#{event}" } - = check_box("notification_setting", event, {id: "events_#{event}", class: "js-custom-notification-event"}) + = check_box("", event, { name: "notification_setting[#{event}]", class: "js-custom-notification-event", checked: notification_setting.events[event] }) %strong = event.to_s.humanize diff --git a/app/views/shared/notifications/_notification_dropdown.html.haml b/app/views/shared/notifications/_notification_dropdown.html.haml new file mode 100644 index 00000000000..e6e04b98c82 --- /dev/null +++ b/app/views/shared/notifications/_notification_dropdown.html.haml @@ -0,0 +1,12 @@ +%ul.dropdown-menu.dropdown-menu-no-wrap.dropdown-menu-align-right.dropdown-menu-selectable.dropdown-menu-large{ role: "menu", class: notifications_menu_identifier("dropdown", notification_setting) } + - NotificationSetting.levels.each_key do |level| + - next if level == "custom" + - next if level == "global" && notification_setting.source.nil? + + = notification_list_item(level, notification_setting) + + - unless notification_setting.custom? + %li.divider + %li + %a.update-notification{ href: "#", role: "button", data: { toggle: "modal", target: "#" + notifications_menu_identifier("modal", notification_setting), notification_level: "custom", notification_title: "Custom" } } + Custom diff --git a/app/views/shared/projects/_notification_dropdown.html.haml b/app/views/shared/projects/_notification_dropdown.html.haml deleted file mode 100644 index 6388f907eb3..00000000000 --- a/app/views/shared/projects/_notification_dropdown.html.haml +++ /dev/null @@ -1,9 +0,0 @@ -%ul.dropdown-menu.dropdown-menu-no-wrap.dropdown-menu-align-right.dropdown-menu-selectable.dropdown-menu-large{ role: "menu" } - - NotificationSetting.levels.each do |level| - - if level.first != "custom" - = notification_list_item(level.first, @notification_setting) - - if @notification_setting.level != "custom" - %li.divider - %li - %a.update-notification{ href: "#", role: "button", data: { toggle: "modal", target: "#custom-notifications-modal", notification_level: "custom", notification_title: "Custom" } } - Custom |