#452: Show only main platforms which user used as default on BuildLists#new page
This commit is contained in:
parent
2a01474d03
commit
71c41cb723
|
@ -214,6 +214,8 @@ module BuildListsHelper
|
|||
|
||||
def save_to_repositories(project, params)
|
||||
project.repositories.map do |r|
|
||||
# Show only main platforms which user used as default.
|
||||
next if r.platform.main? && current_user_platforms.present? && current_user_platforms.exclude?(r.platform.id)
|
||||
{
|
||||
id: r.id,
|
||||
name: "#{r.platform.name}/#{r.name}",
|
||||
|
@ -224,11 +226,13 @@ module BuildListsHelper
|
|||
default_arches: ( r.platform.platform_arch_settings.by_default.pluck(:arch_id).presence ||
|
||||
Arch.where(name: Arch::DEFAULT).pluck(:id) )
|
||||
}
|
||||
end.sort_by { |e| e[:name] }
|
||||
end.compact.sort_by { |e| e[:name] }
|
||||
end
|
||||
|
||||
def new_build_list_platforms(params)
|
||||
availables_main_platforms.map do |pl|
|
||||
# Show only main platforms which user used as default.
|
||||
next if current_user_platforms.present? && current_user_platforms.exclude?(pl.id)
|
||||
platform = { id: pl.id, name: pl.name, repositories: [] }
|
||||
Repository.custom_sort(pl.repositories).each do |repo|
|
||||
platform[:repositories] << { id: repo.id,
|
||||
|
@ -237,7 +241,11 @@ module BuildListsHelper
|
|||
checked: is_repository_checked(repo, params) }
|
||||
end
|
||||
platform
|
||||
end
|
||||
end.compact
|
||||
end
|
||||
|
||||
def current_user_platforms
|
||||
@current_user_platforms ||= (current_user.builds_setting.try(:platforms) || []).select(&:present?).map(&:to_i)
|
||||
end
|
||||
|
||||
def include_repos(params)
|
||||
|
|
|
@ -5,7 +5,6 @@ class UserBuildsSetting < ActiveRecord::Base
|
|||
|
||||
validates :user, presence: true
|
||||
|
||||
attr_accessible :platforms,
|
||||
:use_extra_tests
|
||||
attr_accessible :platforms
|
||||
|
||||
end
|
||||
|
|
|
@ -29,7 +29,10 @@ h4.offset10= t("activerecord.attributes.build_list.preferences")
|
|||
= f.check_box kind, checked: checked
|
||||
= BuildList.human_attribute_name kind
|
||||
|
||||
- selected = params[:build_list].try(:[], :external_nodes) ? {selected: params[:build_list][:external_nodes]} : {}
|
||||
- selected = params[:build_list].try(:[], :external_nodes)
|
||||
- selected = current_user.builds_setting.try(:external_nodes) if selected.nil?
|
||||
- selected = selected && { selected: selected } || {}
|
||||
= f.label :external_nodes
|
||||
= f.select :external_nodes, external_nodes, selected.merge(include_blank: true),
|
||||
class: 'form-control'
|
||||
= f.select :external_nodes, external_nodes,
|
||||
selected.merge(include_blank: true),
|
||||
class: 'form-control'
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
.row
|
||||
= simple_form_for @user.builds_setting,
|
||||
url: builds_settings_settings_path,
|
||||
wrapper: :horizontal_form,
|
||||
wrapper_mappings: { boolean: :horizontal_boolean } do |f|
|
||||
wrapper: :horizontal_form do |f|
|
||||
|
||||
fieldset
|
||||
legend
|
||||
|
@ -29,7 +28,6 @@
|
|||
|
||||
.col-sm-8
|
||||
= f.input :external_nodes, collection: external_nodes, include_blank: true
|
||||
= f.input :use_extra_tests, as: :boolean
|
||||
|
||||
.clearfix
|
||||
hr
|
||||
|
|
|
@ -11,10 +11,8 @@ en:
|
|||
user_builds_setting:
|
||||
platforms: "Platforms"
|
||||
external_nodes: "External nodes"
|
||||
use_extra_tests: "Use extra tests"
|
||||
# placeholders:
|
||||
hints:
|
||||
user_builds_setting:
|
||||
platforms: "Select a platforms that you'd like to use."
|
||||
external_nodes: "Select the type of nodes that you'd like to use."
|
||||
use_extra_tests: "Uncheck this to disable extra tests."
|
||||
|
|
|
@ -11,10 +11,8 @@ ru:
|
|||
user_builds_setting:
|
||||
platforms: "Платформы"
|
||||
external_nodes: "Дополнительные ноды"
|
||||
use_extra_tests: "Использовать дополнительные тесты"
|
||||
# placeholders:
|
||||
hints:
|
||||
user_builds_setting:
|
||||
platforms: "Выберите платформы, которые вы хотели бы использовать."
|
||||
external_nodes: "Выберите ноды, которые вы хотели бы использовать."
|
||||
use_extra_tests: "Снимите тут, чтобы отключить дополнительные тесты."
|
||||
|
|
|
@ -3,7 +3,6 @@ class CreateUserBuildsSettings < ActiveRecord::Migration
|
|||
create_table :user_builds_settings do |t|
|
||||
t.integer :user_id, null: false
|
||||
t.text :platforms, null: false, default: [], array: true
|
||||
t.boolean :use_extra_tests, null: false, default: true
|
||||
t.string :external_nodes
|
||||
end
|
||||
|
||||
|
|
|
@ -629,9 +629,8 @@ ActiveRecord::Schema.define(version: 20150210192749) do
|
|||
end
|
||||
|
||||
create_table "user_builds_settings", force: true do |t|
|
||||
t.integer "user_id", null: false
|
||||
t.text "platforms", default: [], null: false, array: true
|
||||
t.boolean "use_extra_tests", default: true, null: false
|
||||
t.integer "user_id", null: false
|
||||
t.text "platforms", default: [], null: false, array: true
|
||||
t.string "external_nodes"
|
||||
t.index ["user_id"], :name => "index_user_builds_settings_on_user_id", :unique => true
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue