From 7b3c74e97db00e9bbd724ff381374f504eba0786 Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Tue, 10 Jul 2012 00:43:01 +0400 Subject: [PATCH] [issue #561] Changed BuildList pages * Removed mass_build, cancel and updated_at fields from list * Added link to commit in list (instead of version) * Added platform field in list * Added filter by main platforms * Added cancel button and mass_build field to BuildList#show --- app/controllers/projects/build_lists_controller.rb | 2 +- app/helpers/build_lists_helper.rb | 9 +++++++++ app/models/build_list.rb | 1 + app/models/build_list/filter.rb | 3 +++ .../projects/build_lists/_build_list.html.haml | 6 ++---- app/views/projects/build_lists/_filter.html.haml | 2 ++ app/views/projects/build_lists/index.html.haml | 4 +--- app/views/projects/build_lists/show.html.haml | 13 +++++-------- config/locales/models/build_list.en.yml | 1 + config/locales/models/build_list.ru.yml | 1 + 10 files changed, 26 insertions(+), 16 deletions(-) diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index 7893f98c0..8ceb1836f 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -25,7 +25,7 @@ class Projects::BuildListsController < Projects::BaseController def index @action_url = @project ? search_project_build_lists_path(@project) : search_build_lists_path @filter = BuildList::Filter.new(@project, current_user, params[:filter] || {}) - @build_lists = @filter.find.recent.paginate :page => params[:page] + @build_lists = @filter.find.scoped(:include => [:save_to_platform]).recent.paginate :page => params[:page] @build_server_status = begin BuildServer.get_status diff --git a/app/helpers/build_lists_helper.rb b/app/helpers/build_lists_helper.rb index 2b9d66882..6509b3cb5 100644 --- a/app/helpers/build_lists_helper.rb +++ b/app/helpers/build_lists_helper.rb @@ -34,4 +34,13 @@ module BuildListsHelper return advisoriable + nonadvisoriable end + + def build_list_version_link(build_list, str_version = false) + if build_list.commit_hash.present? + link_to str_version ? "#{shortest_hash_id @build_list.commit_hash} ( #{@build_list.project_version} )" : shortest_hash_id(build_list.commit_hash), + commit_path(build_list.project.owner, build_list.project, build_list.commit_hash) + else + build_list.project_version + end + end end diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 6c60b6d89..a3f0b416b 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -76,6 +76,7 @@ class BuildList < ActiveRecord::Base scope :for_platform, lambda { |platform| where(:build_for_platform_id => platform.id) } scope :by_mass_build, lambda { |mass_build| where(:mass_build_id => mass_build) } scope :scoped_to_arch, lambda {|arch| where(:arch_id => arch) } + scope :scoped_to_save_platform, lambda {|pl_id| where(:save_to_platform_id => pl_id) } scope :scoped_to_project_version, lambda {|project_version| where(:project_version => project_version) } scope :scoped_to_is_circle, lambda {|is_circle| where(:is_circle => is_circle) } scope :for_creation_date_period, lambda{|start_date, end_date| diff --git a/app/models/build_list/filter.rb b/app/models/build_list/filter.rb index f023d25cc..85192256f 100644 --- a/app/models/build_list/filter.rb +++ b/app/models/build_list/filter.rb @@ -15,6 +15,7 @@ class BuildList::Filter build_lists = build_lists.accessible_by(::Ability.new(@user), @options[:ownership].to_sym) if @options[:ownership] build_lists = build_lists.for_status(@options[:status]) if @options[:status] build_lists = build_lists.scoped_to_arch(@options[:arch_id]) if @options[:arch_id] + build_lists = build_lists.scoped_to_save_platform(@options[:platform_id]) if @options[:platform_id] build_lists = build_lists.scoped_to_project_version(@options[:project_version]) if @options[:project_version] build_lists = build_lists.scoped_to_is_circle(@options[:is_circle]) if @options[:is_circle].present? build_lists = build_lists.scoped_to_project_name(@options[:project_name]) if @options[:project_name] @@ -51,6 +52,7 @@ class BuildList::Filter :updated_at_start => nil, :updated_at_end => nil, :arch_id => nil, + :platform_id => nil, :is_circle => nil, :project_version => nil, :bs_id => nil, @@ -66,6 +68,7 @@ class BuildList::Filter @options[:updated_at_end] = build_date_from_params(:updated_at_end, @options) @options[:project_version] = @options[:project_version].presence @options[:arch_id] = @options[:arch_id].present? ? @options[:arch_id].to_i : nil + @options[:platform_id] = @options[:platform_id].present? ? @options[:platform_id].to_i : nil @options[:is_circle] = @options[:is_circle].present? ? @options[:is_circle] == "1" : nil @options[:bs_id] = @options[:bs_id].presence @options[:project_name] = @options[:project_name].presence diff --git a/app/views/projects/build_lists/_build_list.html.haml b/app/views/projects/build_lists/_build_list.html.haml index 8e3f67d91..153ead5fd 100644 --- a/app/views/projects/build_lists/_build_list.html.haml +++ b/app/views/projects/build_lists/_build_list.html.haml @@ -1,10 +1,8 @@ %tr{:id => "row#{build_list_counter}", :class => "#{build_list_status_color(build_list.status)}"} %td= link_to (build_list.bs_id.present? ? build_list.bs_id : t("layout.build_lists.bs_id_not_set")), build_list - %td= build_list.mass_build_id ? link_to(build_list.mass_build.name, platform_mass_builds_path(build_list.save_to_platform)) : "" %td= build_list.human_status %td= link_to build_list.project.name_with_owner, build_list.project - %td= link_to build_list.project_version, "#" + %td= build_list_version_link(build_list) %td= build_list.arch.name + %td= link_to build_list.save_to_platform.name, build_list.save_to_platform %td= link_to build_list.user.try(:fullname), build_list.user - %td= link_to image_tag('x.png', :class => 'delete-row', :id => "delete-row#{build_list_counter}"), cancel_build_list_path(build_list), :method => :put, :confirm => t('layout.confirm') if build_list.can_cancel? and can?(:cancel, build_list) - %td= build_list.updated_at diff --git a/app/views/projects/build_lists/_filter.html.haml b/app/views/projects/build_lists/_filter.html.haml index 67ea7082c..6ff7b7bd6 100644 --- a/app/views/projects/build_lists/_filter.html.haml +++ b/app/views/projects/build_lists/_filter.html.haml @@ -45,6 +45,8 @@ .lineForm.aside= f.select :is_circle, [[t("layout.yes_"), 1], [t("layout.no_"), 0]], {:include_blank => true, :selected => @filter.is_circle.present? ? (@filter.is_circle ? "1" : "0") : nil}, {:class => 'sel80 aside', :id => 'recurrent', :tabindex => 2} %h3.small= t("activerecord.attributes.build_list.arch") .lineForm.aside= f.select :arch_id, Arch.recent.collect{|arch| [arch.name, arch.id]}, {:include_blank => true, :selected => @filter.arch_id}, {:class => 'sel80 aside', :id => 'architecture', :tabindex => 2} + %h3.small= t("activerecord.models.platform") + .lineForm.aside= f.select :platform_id, Platform.main.collect{|pl| [pl.name, pl.id]}, {:include_blank => true, :selected => @filter.platform_id}, {:class => 'sel80 aside', :id => 'platform', :tabindex => 2} %h3.small= t("layout.build_lists.created_at_start") .date_select= f.date_select(:created_at_start, :include_blank => true, :selected => @filter.created_at_start) %h3.small= t("layout.build_lists.created_at_end") diff --git a/app/views/projects/build_lists/index.html.haml b/app/views/projects/build_lists/index.html.haml index 37cb2c2ea..40a290a49 100644 --- a/app/views/projects/build_lists/index.html.haml +++ b/app/views/projects/build_lists/index.html.haml @@ -4,14 +4,12 @@ %thead %tr %th.lpadding16= t("activerecord.attributes.build_list.bs_id") - %th.lpadding16= t('activerecord.attributes.build_list.mass_build_id') %th.lpadding16= t("activerecord.attributes.build_list.status") %th.lpadding16= t("activerecord.attributes.build_list.project") %th.lpadding16= t("activerecord.attributes.build_list.project_version") %th.lpadding16= t("activerecord.attributes.build_list.arch") + %th.lpadding16= t("activerecord.models.platform") %th.lpadding16= t("activerecord.attributes.build_list.user") - %th= t("layout.build_lists.action") - %th.lpadding16= t("activerecord.attributes.build_list.updated_at") %tbody= render :partial => 'projects/build_lists/build_list', :collection => @build_lists .both diff --git a/app/views/projects/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml index beb41fa11..5de1af34b 100644 --- a/app/views/projects/build_lists/show.html.haml +++ b/app/views/projects/build_lists/show.html.haml @@ -43,7 +43,7 @@ .rightlist= t("layout.#{@build_list.auto_publish}_") .both .leftlist= t("activerecord.attributes.build_list.project_version") - .rightlist= @build_list.project_version + .rightlist= build_list_version_link(@build_list, true) .both .leftlist= t("activerecord.attributes.build_list.arch") .rightlist= @build_list.arch.name @@ -71,6 +71,10 @@ = "#{@build_list.human_current_duration} / #{@build_list.project.human_average_build_time}" .both + - if @build_list.can_cancel? and can?(:cancel, @build_list) + = link_to t("layout.build_lists.cancel"), cancel_build_list_path(@build_list), + :method => :put, :confirm => t("layout.confirm"), :class => 'button' + - if @build_list.can_publish? and @build_list.save_to_platform.released and @build_list.advisory.nil? #advisory_block .leftlist= label_tag :attach_advisory, t("layout.build_lists.attached_advisory") @@ -90,13 +94,6 @@ .info{:class => el} %p= t("layout.advisories.banners.#{el}") - -#.info.advisory_not_found - %p= t("layout.advisories.banners.advisory_not_found") - -#.info.server_error - %p= t("layout.advisories.banners.server_error") - -#.info.continue_input - %p= t("layout.advisories.banners.continue_input") - #new_advisory_form = f.fields_for @build_list.build_advisory do |f| = render :partial => 'advisories/form', :locals => {:f => f} diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index 139ae436b..92090d98e 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -58,6 +58,7 @@ en: packages_header: Container data no_items_data: No data show: Show + cancel: Cancel build cancel_success: 'Build canceled' cancel_fail: 'Errors during build cancelation!' publish_success: 'Build is queued for publishing' diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index 910292188..814b202cb 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -57,6 +57,7 @@ ru: packages_header: Данные о контейнере no_items_data: Данных нет show: Просмотр + cancel: Отменить сборку cancel_success: 'Сборка отменена.' cancel_fail: 'При отмене сборки произошла ошибка!' publish_success: 'Сборка поставлена в очередь на публикацию.'