From 65448e2ff75a92409e246d8e9aae494bc4132457 Mon Sep 17 00:00:00 2001 From: Jason Blanchard Date: Tue, 17 Dec 2013 09:39:39 -0500 Subject: [PATCH 01/14] Added dropdown menus to issue#show page for assignee and milestone --- CHANGELOG | 3 + app/assets/javascripts/issues.js.coffee | 6 ++ app/assets/stylesheets/sections/issues.scss | 5 ++ .../projects/issues/_issue_context.html.haml | 31 ++++++++ app/views/projects/issues/show.html.haml | 25 ++---- app/views/projects/issues/update.js.haml | 9 +++ spec/features/issues_spec.rb | 78 +++++++++++++++++++ 7 files changed, 140 insertions(+), 17 deletions(-) create mode 100644 app/views/projects/issues/_issue_context.html.haml diff --git a/CHANGELOG b/CHANGELOG index d311984676..842978468a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +v 6.5.0 + - Dropdown menus on issue#show page for assignee and milestone (Jason Blanchard) + v 6.4.0 - Added sorting to project issues page (Jason Blanchard) - Assembla integration (Carlos Paramio) diff --git a/app/assets/javascripts/issues.js.coffee b/app/assets/javascripts/issues.js.coffee index c273ddbd39..43571409bc 100644 --- a/app/assets/javascripts/issues.js.coffee +++ b/app/assets/javascripts/issues.js.coffee @@ -79,3 +79,9 @@ $("#update_issues_ids").val [] $(".issues_bulk_update").hide() $(".issues-filters").show() + +$ -> + $('.edit-issue.inline-update input[type="submit"]').hide(); + $("body").on "change", ".edit-issue.inline-update select", -> + $(this).submit() + diff --git a/app/assets/stylesheets/sections/issues.scss b/app/assets/stylesheets/sections/issues.scss index 792bcef02f..68e8f3fa08 100644 --- a/app/assets/stylesheets/sections/issues.scss +++ b/app/assets/stylesheets/sections/issues.scss @@ -119,3 +119,8 @@ input.check_all_issues { background-color: #f4f4f4; } } + +.edit-issue.inline-update select { + width: 100%; + max-width: 230px; +} diff --git a/app/views/projects/issues/_issue_context.html.haml b/app/views/projects/issues/_issue_context.html.haml new file mode 100644 index 0000000000..29eb338d44 --- /dev/null +++ b/app/views/projects/issues/_issue_context.html.haml @@ -0,0 +1,31 @@ += form_for [@project, @issue], :remote => true, :html => {:class => 'edit-issue inline-update'} do |f| + .pull-right + Created by #{link_to_member(@project, issue.author)} + - if issue.assignee + \ and currently assigned to + + - if can?(current_user, :modify_issue, @issue) + = link_to profile_path(issue.assignee) do + = image_tag(avatar_icon(issue.assignee.email), :class => 'avatar avatar-inline s16 assignee') if issue.assignee + = f.select(:assignee_id, @project.team.members.sort_by(&:name).map {|p| [ p.name, p.id ] }, { include_blank: "Assign to user (none):" }, {class: 'chosen'}) + - elsif issue.assignee + = link_to_member(@project, @issue.assignee) + + - if issue.milestone + - milestone = issue.milestone + %cite.cgray and attached to milestone + + - if can?(current_user, :modify_issue, @issue) + = f.select(:milestone_id, @project.milestones.active.all.collect {|p| [ p.title, p.id ] }, { include_blank: "Select milestone (none):" }, {class: 'chosen'}) + + = hidden_field_tag :issue_context + = f.submit :class => 'btn' + - elsif issue.milestone + = link_to issue.milestone.title, project_milestone_path + +.pull-right + - issue.labels.each do |label| + %span{class: "label #{label_css_class(label.name)}"} + %i.icon-tag + = label.name +   diff --git a/app/views/projects/issues/show.html.haml b/app/views/projects/issues/show.html.haml index 36ea57805a..b23e577c6f 100644 --- a/app/views/projects/issues/show.html.haml +++ b/app/views/projects/issues/show.html.haml @@ -26,7 +26,12 @@ .back-link = link_to project_issues_path(@project) do ← To issues list - + %span.milestone-nav-link + - if @issue.milestone + | + = link_to project_milestone_path(@project, @issue.milestone) do + Milestone: + = @issue.milestone.title .ui-box.ui-box-show .ui-box-head @@ -39,21 +44,7 @@ .ui-box-body %cite.cgray - Created by #{link_to_member(@project, @issue.author)} - - if @issue.assignee - \ and currently assigned to #{link_to_member(@project, @issue.assignee)} - - - if @issue.milestone - - milestone = @issue.milestone - %cite.cgray and attached to milestone - %strong= link_to_gfm truncate(milestone.title, length: 20), project_milestone_path(milestone.project, milestone) - - .pull-right - - @issue.labels.each do |label| - %span{class: "label #{label_css_class(label.name)}"} - %i.icon-tag - = label.name -   + = render partial: 'issue_context', locals: { issue: @issue } - if @issue.description.present? .ui-box-bottom @@ -73,4 +64,4 @@ - @issue.participants.each do |participant| = link_to_member(@project, participant, name: false, size: 24) -.voting_notes#notes= render "projects/notes/notes_with_form" \ No newline at end of file +.voting_notes#notes= render "projects/notes/notes_with_form" diff --git a/app/views/projects/issues/update.js.haml b/app/views/projects/issues/update.js.haml index 7f66022a2d..eb27faa312 100644 --- a/app/views/projects/issues/update.js.haml +++ b/app/views/projects/issues/update.js.haml @@ -2,3 +2,12 @@ - if @issue.valid? :plain $("##{dom_id(@issue)}").fadeOut(); +- elsif params[:issue_context] + $('.ui-box-body').html("#{escape_javascript(render partial: 'issue_context', locals: { issue: @issue })}"); + $('.ui-box-body').effect('highlight'); + $('.chosen').chosen(); + $('.edit-issue.inline-update input[type="submit"]').hide(); + - if @issue.milestone + $('.milestone-nav-link').replaceWith("#{escape_javascript(link_to "| #{@issue.milestone.title}", project_milestone_path(@issue.project, @issue.milestone), :class => 'milestone-nav-link')}") + - else + $('.milestone-nav-link').html('') diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb index bb0c4dbd5d..e33684ed83 100644 --- a/spec/features/issues_spec.rb +++ b/spec/features/issues_spec.rb @@ -175,6 +175,84 @@ describe "Issues" do end end + describe 'update assignee from issue#show' do + let(:issue) { create(:issue, project: project, author: @user) } + + context 'by autorized user' do + + it 'with dropdown menu' do + visit project_issue_path(project, issue) + + find('.edit-issue.inline-update').select(project.team.members.first.name, from: 'issue_assignee_id') + click_button 'Update Issue' + + page.should have_content "currently assigned to" + page.has_select?('issue_assignee_id', :selected => project.team.members.first.name) + end + end + + context 'by unauthorized user' do + + let(:guest) { create(:user) } + + before :each do + project.team << [[guest], :guest] + issue.assignee = @user + issue.save + end + + it 'shows assignee text' do + logout + login_with guest + + visit project_issue_path(project, issue) + page.should have_content "currently assigned to #{issue.assignee.name}" + + end + end + + end + + describe 'update milestone from issue#show' do + let!(:issue) { create(:issue, project: project, author: @user) } + let!(:milestone) { create(:milestone, project: project) } + + context 'by authorized user' do + + it 'with dropdown menu' do + visit project_issue_path(project, issue) + + p find('.edit-issue.inline-update').text + + find('.edit-issue.inline-update').select(milestone.title, from: 'issue_milestone_id') + click_button 'Update Issue' + + page.should have_content "and attached to milestone" + page.has_select?('issue_assignee_id', :selected => milestone.title) + end + end + + context 'by unauthorized user' do + + let(:guest) { create(:user) } + + before :each do + project.team << [[guest], :guest] + issue.milestone = milestone + issue.save + end + + it 'shows milestone text' do + logout + login_with guest + + visit project_issue_path(project, issue) + + page.should have_content "attached to milestone #{milestone.title}" + end + end + end + def first_issue all("ul.issues-list li").first.text end From 0760ba3efb7566b9f56bb066f4b15ba8ea34e1e7 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Mon, 9 Dec 2013 00:34:51 -0500 Subject: [PATCH 02/14] Customization and previewing of broadcast messages --- CHANGELOG | 1 + app/assets/javascripts/admin.js.coffee | 17 +++++++++++++++ app/assets/stylesheets/common.scss | 5 +++++ app/helpers/broadcast_messages_helper.rb | 9 ++++++++ app/models/broadcast_message.rb | 4 +++- .../admin/broadcast_messages/index.html.haml | 15 ++++++++++++- app/views/layouts/_broadcast.html.haml | 2 +- ...dd_color_and_font_to_broadcast_messages.rb | 6 ++++++ db/schema.rb | 2 ++ features/admin/broadcast_messages.feature | 7 +++++++ .../steps/admin/admin_broadcast_messages.rb | 14 +++++++++++++ spec/factories/broadcast_messages.rb | 4 ++++ .../helpers/broadcast_messages_helper_spec.rb | 21 +++++++++++++++++++ spec/models/broadcast_message_spec.rb | 2 ++ 14 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 app/helpers/broadcast_messages_helper.rb create mode 100644 db/migrate/20131130165425_add_color_and_font_to_broadcast_messages.rb create mode 100644 spec/helpers/broadcast_messages_helper_spec.rb diff --git a/CHANGELOG b/CHANGELOG index d311984676..5677a5b5d2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -23,6 +23,7 @@ v 6.4.0 - API Cross-origin resource sharing - Show READMe link at project home page - Show repo size for projects in Admin area + - Add color custimization and previewing to broadcast messages v 6.3.0 - API for adding gitlab-ci service diff --git a/app/assets/javascripts/admin.js.coffee b/app/assets/javascripts/admin.js.coffee index 6230fe7f93..6634bb6cc3 100644 --- a/app/assets/javascripts/admin.js.coffee +++ b/app/assets/javascripts/admin.js.coffee @@ -8,6 +8,23 @@ class Admin else elems.removeAttr 'disabled' + $('body').on 'click', '.js-toggle-colors-link', (e) -> + e.preventDefault() + $('.js-toggle-colors-link').hide() + $('.js-toggle-colors-container').show() + + $('input#broadcast_message_color').on 'input', -> + previewColor = $('input#broadcast_message_color').val() + $('div.broadcast-message-preview').css('background-color', previewColor) + + $('input#broadcast_message_font').on 'input', -> + previewColor = $('input#broadcast_message_font').val() + $('div.broadcast-message-preview').css('color', previewColor) + + $('textarea#broadcast_message_message').on 'input', -> + previewMessage = $('textarea#broadcast_message_message').val() + $('div.broadcast-message-preview span').text(previewMessage) + $('.log-tabs a').click (e) -> e.preventDefault() $(this).tab('show') diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 1615cd7925..1cfcbcedc6 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -361,6 +361,11 @@ table { color: #BBB; } +.broadcast-message-preview { + @extend .broadcast-message; + margin-bottom: 20px; +} + .ajax-users-select { width: 400px; diff --git a/app/helpers/broadcast_messages_helper.rb b/app/helpers/broadcast_messages_helper.rb new file mode 100644 index 0000000000..29ff47663d --- /dev/null +++ b/app/helpers/broadcast_messages_helper.rb @@ -0,0 +1,9 @@ +module BroadcastMessagesHelper + def broadcast_styling(broadcast_message) + if(broadcast_message.color || broadcast_message.font) + "background-color:#{broadcast_message.color};color:#{broadcast_message.font}" + else + "" + end + end +end diff --git a/app/models/broadcast_message.rb b/app/models/broadcast_message.rb index a8b1db9c24..05b4dfc366 100644 --- a/app/models/broadcast_message.rb +++ b/app/models/broadcast_message.rb @@ -9,10 +9,12 @@ # alert_type :integer # created_at :datetime not null # updated_at :datetime not null +# color :string(255) +# font :string(255) # class BroadcastMessage < ActiveRecord::Base - attr_accessible :alert_type, :ends_at, :message, :starts_at + attr_accessible :alert_type, :color, :ends_at, :font, :message, :starts_at validates :message, presence: true validates :starts_at, presence: true diff --git a/app/views/admin/broadcast_messages/index.html.haml b/app/views/admin/broadcast_messages/index.html.haml index b16d82f4ab..8a0d5e4d76 100644 --- a/app/views/admin/broadcast_messages/index.html.haml +++ b/app/views/admin/broadcast_messages/index.html.haml @@ -2,7 +2,9 @@ Broadcast Messages %p.light Broadcast messages are displayed for every user and can be used to notify users about scheduled maintenance, recent upgrades and more. -%hr +.broadcast-message-preview + %i.icon-bullhorn + %span Your message here = form_for [:admin, @broadcast_message] do |f| -if @broadcast_message.errors.any? @@ -13,6 +15,17 @@ = f.label :message .controls = f.text_area :message, class: "input-xxlarge", rows: 2, required: true + %div + = link_to '#', class: 'js-toggle-colors-link' do + Customize colors + .control-group.js-toggle-colors-container.hide + = f.label :color, "Background Color" + .controls + = f.text_field :color + .control-group.js-toggle-colors-container.hide + = f.label :font, "Font Color" + .controls + = f.text_field :font .control-group = f.label :starts_at .controls.datetime-controls diff --git a/app/views/layouts/_broadcast.html.haml b/app/views/layouts/_broadcast.html.haml index 4c4de743fd..5794e3de33 100644 --- a/app/views/layouts/_broadcast.html.haml +++ b/app/views/layouts/_broadcast.html.haml @@ -1,4 +1,4 @@ - if broadcast_message.present? - .broadcast-message + .broadcast-message{ style: broadcast_styling(broadcast_message) } %i.icon-bullhorn = broadcast_message.message diff --git a/db/migrate/20131130165425_add_color_and_font_to_broadcast_messages.rb b/db/migrate/20131130165425_add_color_and_font_to_broadcast_messages.rb new file mode 100644 index 0000000000..473f355ece --- /dev/null +++ b/db/migrate/20131130165425_add_color_and_font_to_broadcast_messages.rb @@ -0,0 +1,6 @@ +class AddColorAndFontToBroadcastMessages < ActiveRecord::Migration + def change + add_column :broadcast_messages, :color, :string + add_column :broadcast_messages, :font, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index cda5c3cf94..e02799e0db 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -20,6 +20,8 @@ ActiveRecord::Schema.define(version: 20131217102743) do t.integer "alert_type" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.string "color" + t.string "font" end create_table "deploy_keys_projects", force: true do |t| diff --git a/features/admin/broadcast_messages.feature b/features/admin/broadcast_messages.feature index 0294b51a7c..5f16120b7c 100644 --- a/features/admin/broadcast_messages.feature +++ b/features/admin/broadcast_messages.feature @@ -11,3 +11,10 @@ Feature: Admin Broadcast Messages When submit form with new broadcast message Then I should be redirected to admin messages page And I should see newly created broadcast message + + Scenario: Create a customized broadcast message + When submit form with new customized broadcast message + Then I should be redirected to admin messages page + And I should see newly created broadcast message + Then I visit dashboard page + And I should see a customized broadcast message diff --git a/features/steps/admin/admin_broadcast_messages.rb b/features/steps/admin/admin_broadcast_messages.rb index 4dfaac06ae..a35fa34a3a 100644 --- a/features/steps/admin/admin_broadcast_messages.rb +++ b/features/steps/admin/admin_broadcast_messages.rb @@ -24,4 +24,18 @@ class Spinach::Features::AdminBroadcastMessages < Spinach::FeatureSteps step 'I should see newly created broadcast message' do page.should have_content 'Application update from 4:00 CST to 5:00 CST' end + + step 'submit form with new customized broadcast message' do + fill_in 'broadcast_message_message', with: 'Application update from 4:00 CST to 5:00 CST' + click_link "Customize colors" + fill_in 'broadcast_message_color', with: '#f2dede' + fill_in 'broadcast_message_font', with: '#b94a48' + select '2018', from: "broadcast_message_ends_at_1i" + click_button "Add broadcast message" + end + + step 'I should see a customized broadcast message' do + page.should have_content 'Application update from 4:00 CST to 5:00 CST' + page.should have_selector %(div[style="background-color:#f2dede;color:#b94a48"]) + end end diff --git a/spec/factories/broadcast_messages.rb b/spec/factories/broadcast_messages.rb index 84dea94502..ad16edaf2e 100644 --- a/spec/factories/broadcast_messages.rb +++ b/spec/factories/broadcast_messages.rb @@ -9,6 +9,8 @@ # alert_type :integer # created_at :datetime not null # updated_at :datetime not null +# color :string(255) +# font :string(255) # # Read about factories at https://github.com/thoughtbot/factory_girl @@ -19,5 +21,7 @@ FactoryGirl.define do starts_at "2013-11-12 13:43:25" ends_at "2013-11-12 13:43:25" alert_type 1 + color "#555" + font "#BBB" end end diff --git a/spec/helpers/broadcast_messages_helper_spec.rb b/spec/helpers/broadcast_messages_helper_spec.rb new file mode 100644 index 0000000000..1338ce4873 --- /dev/null +++ b/spec/helpers/broadcast_messages_helper_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +describe BroadcastMessagesHelper do + describe 'broadcast_styling' do + let(:broadcast_message) { double(color: "", font: "") } + + context "default style" do + it "should have no style" do + broadcast_styling(broadcast_message).should match('') + end + end + + context "customiezd style" do + before { broadcast_message.stub(color: "#f2dede", font: "#b94a48") } + + it "should have a customized style" do + broadcast_styling(broadcast_message).should match('background-color:#f2dede;color:#b94a48') + end + end + end +end diff --git a/spec/models/broadcast_message_spec.rb b/spec/models/broadcast_message_spec.rb index 998e89fa26..cf0b36a283 100644 --- a/spec/models/broadcast_message_spec.rb +++ b/spec/models/broadcast_message_spec.rb @@ -9,6 +9,8 @@ # alert_type :integer # created_at :datetime not null # updated_at :datetime not null +# color :string(255) +# font :string(255) # require 'spec_helper' From 1616dfdc07689ccea258e606f414e65836f666a3 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 19 Dec 2013 19:36:27 +0200 Subject: [PATCH 03/14] UI improvements to issue show page * labels moved below the issue * removed margin in "created by..." area Signed-off-by: Dmitriy Zaporozhets --- app/assets/stylesheets/sections/issues.scss | 10 +++++++++- .../projects/issues/_issue_context.html.haml | 17 +++++------------ app/views/projects/issues/show.html.haml | 9 ++++++++- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/app/assets/stylesheets/sections/issues.scss b/app/assets/stylesheets/sections/issues.scss index 68e8f3fa08..5e808cf692 100644 --- a/app/assets/stylesheets/sections/issues.scss +++ b/app/assets/stylesheets/sections/issues.scss @@ -122,5 +122,13 @@ input.check_all_issues { .edit-issue.inline-update select { width: 100%; - max-width: 230px; + max-width: 200px; +} + +.issue-labels .label { + padding: 6px 10px; +} + +form.edit-issue { + margin: 0; } diff --git a/app/views/projects/issues/_issue_context.html.haml b/app/views/projects/issues/_issue_context.html.haml index 29eb338d44..25e2e03581 100644 --- a/app/views/projects/issues/_issue_context.html.haml +++ b/app/views/projects/issues/_issue_context.html.haml @@ -1,12 +1,12 @@ -= form_for [@project, @issue], :remote => true, :html => {:class => 'edit-issue inline-update'} do |f| += form_for [@project, @issue], remote: true, html: {class: 'edit-issue inline-update'} do |f| .pull-right - Created by #{link_to_member(@project, issue.author)} + Created by #{link_to_member(@project, issue.author)}  - if issue.assignee \ and currently assigned to - if can?(current_user, :modify_issue, @issue) = link_to profile_path(issue.assignee) do - = image_tag(avatar_icon(issue.assignee.email), :class => 'avatar avatar-inline s16 assignee') if issue.assignee + = image_tag(avatar_icon(issue.assignee.email), class: 'avatar avatar-inline s16 assignee') if issue.assignee = f.select(:assignee_id, @project.team.members.sort_by(&:name).map {|p| [ p.name, p.id ] }, { include_blank: "Assign to user (none):" }, {class: 'chosen'}) - elsif issue.assignee = link_to_member(@project, @issue.assignee) @@ -14,18 +14,11 @@ - if issue.milestone - milestone = issue.milestone %cite.cgray and attached to milestone - + - if can?(current_user, :modify_issue, @issue) = f.select(:milestone_id, @project.milestones.active.all.collect {|p| [ p.title, p.id ] }, { include_blank: "Select milestone (none):" }, {class: 'chosen'}) = hidden_field_tag :issue_context - = f.submit :class => 'btn' + = f.submit class: 'btn' - elsif issue.milestone = link_to issue.milestone.title, project_milestone_path - -.pull-right - - issue.labels.each do |label| - %span{class: "label #{label_css_class(label.name)}"} - %i.icon-tag - = label.name -   diff --git a/app/views/projects/issues/show.html.haml b/app/views/projects/issues/show.html.haml index b23e577c6f..1096dc0d70 100644 --- a/app/views/projects/issues/show.html.haml +++ b/app/views/projects/issues/show.html.haml @@ -28,7 +28,7 @@ ← To issues list %span.milestone-nav-link - if @issue.milestone - | + | = link_to project_milestone_path(@project, @issue.milestone) do Milestone: = @issue.milestone.title @@ -64,4 +64,11 @@ - @issue.participants.each do |participant| = link_to_member(@project, participant, name: false, size: 24) + .issue-labels.pull-right + - @issue.labels.each do |label| + %span{class: "label #{label_css_class(label.name)}"} + %i.icon-tag + = label.name +   + .voting_notes#notes= render "projects/notes/notes_with_form" From 5c68f4f4e51b88d73b8fce0defc51f977280d967 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 19 Dec 2013 19:39:58 +0200 Subject: [PATCH 04/14] remove unecessary bold text on Issue#show page Signed-off-by: Dmitriy Zaporozhets --- app/views/projects/issues/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/projects/issues/show.html.haml b/app/views/projects/issues/show.html.haml index 1096dc0d70..e0d1a740c8 100644 --- a/app/views/projects/issues/show.html.haml +++ b/app/views/projects/issues/show.html.haml @@ -30,7 +30,7 @@ - if @issue.milestone | = link_to project_milestone_path(@project, @issue.milestone) do - Milestone: + %span.light Milestone = @issue.milestone.title .ui-box.ui-box-show From 3958330edc5aa6044ebe90382fd901834ecfa821 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 19 Dec 2013 19:54:57 +0200 Subject: [PATCH 05/14] Added milestone_options and assigne_options helpers Signed-off-by: Dmitriy Zaporozhets --- app/helpers/issues_helper.rb | 8 ++++++++ app/views/projects/issues/_form.html.haml | 4 ++-- app/views/projects/issues/_issue_context.html.haml | 4 ++-- app/views/projects/merge_requests/_form.html.haml | 4 ++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 56b776cff4..cdba6ce84d 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -76,4 +76,12 @@ module IssuesHelper def bulk_update_assignee_options options_for_select(["None (unassigned)", nil]) + options_from_collection_for_select(@project.team.members, "id", "name", params[:assignee_id]) end + + def assignee_options object + options_from_collection_for_select(@project.team.members.sort_by(&:name), 'id', 'name', object.assignee_id) + end + + def milestone_options object + options_from_collection_for_select(@project.milestones.active, 'id', 'title', object.milestone_id) + end end diff --git a/app/views/projects/issues/_form.html.haml b/app/views/projects/issues/_form.html.haml index d56009fac6..78f852e4e3 100644 --- a/app/views/projects/issues/_form.html.haml +++ b/app/views/projects/issues/_form.html.haml @@ -21,7 +21,7 @@ Assign to .controls .pull-left - = f.select(:assignee_id, @project.team.members.sort_by(&:name).map {|p| [ p.name, p.id ] }, { include_blank: "Select a user" }, {class: 'chosen'}) + = f.select(:assignee_id, assignee_options(@issue), { include_blank: "Select a user" }, {class: 'chosen'}) .pull-right   = link_to 'Assign to me', '#', class: 'btn btn-small assign-to-me-link' @@ -29,7 +29,7 @@ = f.label :milestone_id do %i.icon-time Milestone - .controls= f.select(:milestone_id, @project.milestones.active.collect {|p| [ p.title, p.id ] }, { include_blank: "Select milestone" }, {class: 'chosen'}) + .controls= f.select(:milestone_id, milestone_options(@issue), { include_blank: "Select milestone" }, {class: 'chosen'}) .ui-box-bottom .control-group diff --git a/app/views/projects/issues/_issue_context.html.haml b/app/views/projects/issues/_issue_context.html.haml index 25e2e03581..6882787e6b 100644 --- a/app/views/projects/issues/_issue_context.html.haml +++ b/app/views/projects/issues/_issue_context.html.haml @@ -7,7 +7,7 @@ - if can?(current_user, :modify_issue, @issue) = link_to profile_path(issue.assignee) do = image_tag(avatar_icon(issue.assignee.email), class: 'avatar avatar-inline s16 assignee') if issue.assignee - = f.select(:assignee_id, @project.team.members.sort_by(&:name).map {|p| [ p.name, p.id ] }, { include_blank: "Assign to user (none):" }, {class: 'chosen'}) + = f.select(:assignee_id, assignee_options(@issue), { include_blank: "Assign to user (none):" }, {class: 'chosen'}) - elsif issue.assignee = link_to_member(@project, @issue.assignee) @@ -16,7 +16,7 @@ %cite.cgray and attached to milestone - if can?(current_user, :modify_issue, @issue) - = f.select(:milestone_id, @project.milestones.active.all.collect {|p| [ p.title, p.id ] }, { include_blank: "Select milestone (none):" }, {class: 'chosen'}) + = f.select(:milestone_id, milestone_options(@issue), { include_blank: "Select milestone (none):" }, {class: 'chosen'}) = hidden_field_tag :issue_context = f.submit class: 'btn' diff --git a/app/views/projects/merge_requests/_form.html.haml b/app/views/projects/merge_requests/_form.html.haml index b69fcef7f1..ed81ef65fe 100644 --- a/app/views/projects/merge_requests/_form.html.haml +++ b/app/views/projects/merge_requests/_form.html.haml @@ -39,12 +39,12 @@ = f.label :assignee_id do %i.icon-user Assign to - .controls= f.select(:assignee_id, @project.team.members.sort_by(&:name).map {|p| [ p.name, p.id ] }, { include_blank: "Select user" }, {class: 'chosen span3'}) + .controls= f.select(:assignee_id, assignee_options(@merge_request), { include_blank: "Select user" }, {class: 'chosen span3'}) .left = f.label :milestone_id do %i.icon-time Milestone - .controls= f.select(:milestone_id, @project.milestones.active.map {|p| [ p.title, p.id ] }, { include_blank: "Select milestone" }, {class: 'chosen'}) + .controls= f.select(:milestone_id, milestone_options(@merge_request), { include_blank: "Select milestone" }, {class: 'chosen'}) .control-group = f.label :description, "Description" .controls From e78c51f7cf2686e081e7f17f60ef1e9eb4d7bb76 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 19 Dec 2013 19:59:19 +0200 Subject: [PATCH 06/14] Move broadcast colors CHANGELOG to 6.5 Signed-off-by: Dmitriy Zaporozhets --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 7d9c897546..6ca729c841 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ v 6.5.0 - Dropdown menus on issue#show page for assignee and milestone (Jason Blanchard) + - Add color custimization and previewing to broadcast messages v 6.4.0 - Added sorting to project issues page (Jason Blanchard) @@ -26,7 +27,6 @@ v 6.4.0 - API Cross-origin resource sharing - Show READMe link at project home page - Show repo size for projects in Admin area - - Add color custimization and previewing to broadcast messages v 6.3.0 - API for adding gitlab-ci service From d1e8495890ed28d221595e3a60c2df8567b277c1 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 19 Dec 2013 20:11:01 +0200 Subject: [PATCH 07/14] Add validations to BroadcastMessage color and font Signed-off-by: Dmitriy Zaporozhets --- app/models/broadcast_message.rb | 3 +++ app/views/admin/broadcast_messages/index.html.haml | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/models/broadcast_message.rb b/app/models/broadcast_message.rb index 05b4dfc366..bebe0da9c6 100644 --- a/app/models/broadcast_message.rb +++ b/app/models/broadcast_message.rb @@ -20,6 +20,9 @@ class BroadcastMessage < ActiveRecord::Base validates :starts_at, presence: true validates :ends_at, presence: true + validates :color, format: { with: /\A\#[0-9A-Fa-f]{6}+\Z/ }, allow_blank: true + validates :font, format: { with: /\A\#[0-9A-Fa-f]{6}+\Z/ }, allow_blank: true + def self.current where("ends_at > :now AND starts_at < :now", now: Time.zone.now).last end diff --git a/app/views/admin/broadcast_messages/index.html.haml b/app/views/admin/broadcast_messages/index.html.haml index 8a0d5e4d76..d7c78950b9 100644 --- a/app/views/admin/broadcast_messages/index.html.haml +++ b/app/views/admin/broadcast_messages/index.html.haml @@ -21,11 +21,13 @@ .control-group.js-toggle-colors-container.hide = f.label :color, "Background Color" .controls - = f.text_field :color + = f.text_field :color, placeholder: "#AA33EE" + .light Hex values as 3 double digit numbers, starting with a # sign. .control-group.js-toggle-colors-container.hide = f.label :font, "Font Color" .controls - = f.text_field :font + = f.text_field :font, placeholder: "#224466" + .light Hex values as 3 double digit numbers, starting with a # sign. .control-group = f.label :starts_at .controls.datetime-controls From 63d5fcc868b0502c7d56a093256a4fcb270a8728 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 19 Dec 2013 20:21:22 +0200 Subject: [PATCH 08/14] UI: allign milestone to right for issue, mr show page Signed-off-by: Dmitriy Zaporozhets --- app/assets/stylesheets/selects.scss | 4 ++++ .../projects/issues/_issue_context.html.haml | 20 ++++++++++--------- .../merge_requests/show/_mr_box.html.haml | 8 ++++---- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/app/assets/stylesheets/selects.scss b/app/assets/stylesheets/selects.scss index 8a695d8b16..7259c7d7e4 100644 --- a/app/assets/stylesheets/selects.scss +++ b/app/assets/stylesheets/selects.scss @@ -51,3 +51,7 @@ .chosen-container .chosen-drop .chosen-search input { background-position-y: -24px !important; } + +.chosen-compact { + max-width: 170px !important; +} diff --git a/app/views/projects/issues/_issue_context.html.haml b/app/views/projects/issues/_issue_context.html.haml index 6882787e6b..1e6c04d2b9 100644 --- a/app/views/projects/issues/_issue_context.html.haml +++ b/app/views/projects/issues/_issue_context.html.haml @@ -11,14 +11,16 @@ - elsif issue.assignee = link_to_member(@project, @issue.assignee) - - if issue.milestone - - milestone = issue.milestone - %cite.cgray and attached to milestone - - if can?(current_user, :modify_issue, @issue) - = f.select(:milestone_id, milestone_options(@issue), { include_blank: "Select milestone (none):" }, {class: 'chosen'}) + .pull-right + - if issue.milestone + - milestone = issue.milestone + %cite.cgray Attached to milestone - = hidden_field_tag :issue_context - = f.submit class: 'btn' - - elsif issue.milestone - = link_to issue.milestone.title, project_milestone_path + - if can?(current_user, :modify_issue, @issue) + = f.select(:milestone_id, milestone_options(@issue), { include_blank: "Select milestone (none):" }, {class: 'chosen chosen-compact'}) + + = hidden_field_tag :issue_context + = f.submit class: 'btn' + - elsif issue.milestone + = link_to issue.milestone.title, project_milestone_path diff --git a/app/views/projects/merge_requests/show/_mr_box.html.haml b/app/views/projects/merge_requests/show/_mr_box.html.haml index b85a6ec996..02d5d2915c 100644 --- a/app/views/projects/merge_requests/show/_mr_box.html.haml +++ b/app/views/projects/merge_requests/show/_mr_box.html.haml @@ -17,10 +17,10 @@ - if @merge_request.assignee Currently assigned to #{link_to_member(@project, @merge_request.assignee)}. - if @merge_request.milestone - - milestone = @merge_request.milestone - %cite.cgray Attached to milestone - %strong= link_to_gfm truncate(milestone.title, length: 20), project_milestone_path(milestone.project, milestone) - \. + .pull-right + - milestone = @merge_request.milestone + %cite.cgray Attached to milestone + %strong= link_to_gfm truncate(milestone.title, length: 20), project_milestone_path(milestone.project, milestone) - if @merge_request.description.present? From 3cdb8f26c9c1580d33557a0f619a90989df23245 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 19 Dec 2013 20:25:01 +0200 Subject: [PATCH 09/14] UI: use different padding in labels for Issues#show and Issues#index Signed-off-by: Dmitriy Zaporozhets --- app/assets/stylesheets/sections/issues.scss | 2 +- app/views/projects/issues/show.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/sections/issues.scss b/app/assets/stylesheets/sections/issues.scss index 5e808cf692..c8e5577504 100644 --- a/app/assets/stylesheets/sections/issues.scss +++ b/app/assets/stylesheets/sections/issues.scss @@ -125,7 +125,7 @@ input.check_all_issues { max-width: 200px; } -.issue-labels .label { +.issue-show-labels .label { padding: 6px 10px; } diff --git a/app/views/projects/issues/show.html.haml b/app/views/projects/issues/show.html.haml index e0d1a740c8..74cbfe3dd9 100644 --- a/app/views/projects/issues/show.html.haml +++ b/app/views/projects/issues/show.html.haml @@ -64,7 +64,7 @@ - @issue.participants.each do |participant| = link_to_member(@project, participant, name: false, size: 24) - .issue-labels.pull-right + .issue-show-labels.pull-right - @issue.labels.each do |label| %span{class: "label #{label_css_class(label.name)}"} %i.icon-tag From d1aff25ca4d20c39340936b2fa2976349f028e43 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 19 Dec 2013 21:00:44 +0200 Subject: [PATCH 10/14] Consistent place for state-label across issues, mr, milestones Signed-off-by: Dmitriy Zaporozhets --- .../stylesheets/gitlab_bootstrap/common.scss | 6 +-- app/views/projects/issues/show.html.haml | 9 +++-- .../merge_requests/show/_mr_box.html.haml | 9 +---- .../merge_requests/show/_mr_title.html.haml | 40 ++++++++++++++----- app/views/projects/milestones/show.html.haml | 14 ++++--- 5 files changed, 45 insertions(+), 33 deletions(-) diff --git a/app/assets/stylesheets/gitlab_bootstrap/common.scss b/app/assets/stylesheets/gitlab_bootstrap/common.scss index 26fe02e492..d542698242 100644 --- a/app/assets/stylesheets/gitlab_bootstrap/common.scss +++ b/app/assets/stylesheets/gitlab_bootstrap/common.scss @@ -106,13 +106,11 @@ pre.well-pre { /** Big Labels **/ .state-label { font-size: 14px; - padding: 5px 15px; + padding: 6px 25px; text-align: center; - float: right; - position: relative; - top: -5px; @include border-radius(4px); text-shadow: none; + margin-left: 10px; &.state-label-green { background: #4A4; diff --git a/app/views/projects/issues/show.html.haml b/app/views/projects/issues/show.html.haml index 74cbfe3dd9..9c2b06118b 100644 --- a/app/views/projects/issues/show.html.haml +++ b/app/views/projects/issues/show.html.haml @@ -5,6 +5,11 @@ created at = @issue.created_at.stamp("Aug 21, 2011") + - if @issue.closed? + %span.state-label.state-label-red Closed + - else + %span.state-label.state-label-green Open + %span.pull-right - if can?(current_user, :write_issue, @project) = link_to new_project_issue_path(@project), class: "btn grouped", title: "New Issue", id: "new_issue_link" do @@ -36,10 +41,6 @@ .ui-box.ui-box-show .ui-box-head %h4.box-title - - if @issue.closed? - .state-label.state-label-red Closed - - else - .state-label.state-label-green Open = gfm escape_once(@issue.title) .ui-box-body diff --git a/app/views/projects/merge_requests/show/_mr_box.html.haml b/app/views/projects/merge_requests/show/_mr_box.html.haml index 02d5d2915c..2d80a76652 100644 --- a/app/views/projects/merge_requests/show/_mr_box.html.haml +++ b/app/views/projects/merge_requests/show/_mr_box.html.haml @@ -2,18 +2,11 @@ .ui-box-head %h4.box-title = gfm escape_once(@merge_request.title) - - if @merge_request.merged? - .state-label.state-label-green - %i.icon-ok - Merged - - elsif @merge_request.closed? - .state-label.state-label-red - Closed .ui-box-body %div %cite.cgray - Created on #{@merge_request.created_at.stamp("Aug 21, 2011")} by #{link_to_member(@project, @merge_request.author)}. + Created by #{link_to_member(@project, @merge_request.author)}. - if @merge_request.assignee Currently assigned to #{link_to_member(@project, @merge_request.assignee)}. - if @merge_request.milestone diff --git a/app/views/projects/merge_requests/show/_mr_title.html.haml b/app/views/projects/merge_requests/show/_mr_title.html.haml index 456101fb5e..0d6a546bd5 100644 --- a/app/views/projects/merge_requests/show/_mr_title.html.haml +++ b/app/views/projects/merge_requests/show/_mr_title.html.haml @@ -1,16 +1,21 @@ %h3.page-title - = "Merge Request ##{@merge_request.iid}:" -   - -if @merge_request.for_fork? - %span.label-branch - %span.label-project= truncate(@merge_request.source_project_path, length: 25) - #{@merge_request.source_branch} - → - %span.label-branch= @merge_request.target_branch + = "Merge Request ##{@merge_request.iid}" + %small + created at + = @merge_request.created_at.stamp("Aug 21, 2011") + + - if @merge_request.merged? + %span.state-label.state-label-green + %i.icon-ok + Merged + - elsif @merge_request.closed? + %span.state-label.state-label-red + Closed - else - %span.label-branch= @merge_request.source_branch - → - %span.label-branch= @merge_request.target_branch + %span.state-label.state-label-green + Open + + %span.pull-right - if can?(current_user, :modify_merge_request, @merge_request) @@ -36,3 +41,16 @@ .back-link = link_to project_merge_requests_path(@project) do ← To merge requests + + %span.prepend-left-20.monospace + -if @merge_request.for_fork? + %span + %strong + #{truncate(@merge_request.source_project_path, length: 25)}: + #{@merge_request.source_branch} + → + %span= @merge_request.target_branch + - else + %span= @merge_request.source_branch + → + %spanh= @merge_request.target_branch diff --git a/app/views/projects/milestones/show.html.haml b/app/views/projects/milestones/show.html.haml index a5bd7a2901..fda39a6f96 100644 --- a/app/views/projects/milestones/show.html.haml +++ b/app/views/projects/milestones/show.html.haml @@ -3,15 +3,21 @@ Milestone ##{@milestone.iid} %small = @milestone.expires_at + - if @milestone.closed? + %span.state-label.state-label-red Closed + - elsif @milestone.expired? + %span.state-label.state-label-red Expired + - else + %span.state-label.state-label-green Open .pull-right - if can?(current_user, :admin_milestone, @project) = link_to edit_project_milestone_path(@project, @milestone), class: "btn grouped" do %i.icon-edit Edit - if @milestone.active? - = link_to 'Close Milestone', project_milestone_path(@project, @milestone, milestone: {state_event: :close }), method: :put, class: "btn btn-remove" + = link_to 'Close Milestone', project_milestone_path(@project, @milestone, milestone: {state_event: :close }), method: :put, class: "btn btn-remove grouped" - else - = link_to 'Reopen Milestone', project_milestone_path(@project, @milestone, milestone: {state_event: :activate }), method: :put, class: "btn" + = link_to 'Reopen Milestone', project_milestone_path(@project, @milestone, milestone: {state_event: :activate }), method: :put, class: "btn grouped" - if @milestone.issues.any? && @milestone.can_be_closed? .alert.alert-success @@ -25,10 +31,6 @@ .ui-box.ui-box-show .ui-box-head %h4.box-title - - if @milestone.closed? - .state-label.state-label-red Closed - - elsif @milestone.expired? - .state-label.state-label-red Expired = gfm escape_once(@milestone.title) From 9728ae854eaa10c2e6d4bdf1de2bccd86577aa01 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 19 Dec 2013 21:06:59 +0200 Subject: [PATCH 11/14] Fix broadcast message factory Signed-off-by: Dmitriy Zaporozhets --- spec/factories/broadcast_messages.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/factories/broadcast_messages.rb b/spec/factories/broadcast_messages.rb index ad16edaf2e..6339d5c400 100644 --- a/spec/factories/broadcast_messages.rb +++ b/spec/factories/broadcast_messages.rb @@ -21,7 +21,7 @@ FactoryGirl.define do starts_at "2013-11-12 13:43:25" ends_at "2013-11-12 13:43:25" alert_type 1 - color "#555" - font "#BBB" + color "#555555" + font "#BBBBBB" end end From e64c3b2b5c1907034a07aa69c0e732afc40170a5 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 20 Dec 2013 08:56:39 +0200 Subject: [PATCH 12/14] Fix tests Signed-off-by: Dmitriy Zaporozhets --- spec/features/issues_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb index e33684ed83..538a6ee9fc 100644 --- a/spec/features/issues_spec.rb +++ b/spec/features/issues_spec.rb @@ -192,9 +192,9 @@ describe "Issues" do end context 'by unauthorized user' do - + let(:guest) { create(:user) } - + before :each do project.team << [[guest], :guest] issue.assignee = @user @@ -227,15 +227,15 @@ describe "Issues" do find('.edit-issue.inline-update').select(milestone.title, from: 'issue_milestone_id') click_button 'Update Issue' - page.should have_content "and attached to milestone" + page.should have_content "Attached to milestone" page.has_select?('issue_assignee_id', :selected => milestone.title) end end context 'by unauthorized user' do - + let(:guest) { create(:user) } - + before :each do project.team << [[guest], :guest] issue.milestone = milestone @@ -248,7 +248,7 @@ describe "Issues" do visit project_issue_path(project, issue) - page.should have_content "attached to milestone #{milestone.title}" + page.should have_content "Attached to milestone #{milestone.title}" end end end From a84967630097f198601805695845da4f5138ef46 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 20 Dec 2013 10:03:29 +0200 Subject: [PATCH 13/14] Use relative dates with tooltips fopr Issue#show and MR#show Signed-off-by: Dmitriy Zaporozhets --- app/views/projects/issues/show.html.haml | 3 +-- app/views/projects/merge_requests/show/_mr_title.html.haml | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/views/projects/issues/show.html.haml b/app/views/projects/issues/show.html.haml index 9c2b06118b..7d40721f68 100644 --- a/app/views/projects/issues/show.html.haml +++ b/app/views/projects/issues/show.html.haml @@ -2,8 +2,7 @@ Issue ##{@issue.iid} %small - created at - = @issue.created_at.stamp("Aug 21, 2011") + created #{time_ago_with_tooltip(@issue.created_at)} ago - if @issue.closed? %span.state-label.state-label-red Closed diff --git a/app/views/projects/merge_requests/show/_mr_title.html.haml b/app/views/projects/merge_requests/show/_mr_title.html.haml index 0d6a546bd5..b649a189c9 100644 --- a/app/views/projects/merge_requests/show/_mr_title.html.haml +++ b/app/views/projects/merge_requests/show/_mr_title.html.haml @@ -1,8 +1,7 @@ %h3.page-title = "Merge Request ##{@merge_request.iid}" %small - created at - = @merge_request.created_at.stamp("Aug 21, 2011") + created #{time_ago_with_tooltip(@merge_request.created_at)} ago - if @merge_request.merged? %span.state-label.state-label-green From 68118b5446602640cf41d5413ff5b1e57e787daf Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 21 Dec 2013 23:23:13 +0200 Subject: [PATCH 14/14] Version to 6.5.0.pre Signed-off-by: Dmitriy Zaporozhets --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 9a6f197457..24f0dc3141 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.4.0.beta1 +6.5.0.pre