Mailinglist Archive: opensuse-buildservice (245 mails)

< Previous Next >
[opensuse-buildservice] [PATCH] [webui] paths order can now be changed in the project repository configuration
  • From: Sascha Peilicke <sasch.pe@xxxxxx>
  • Date: Thu, 14 Oct 2010 17:44:44 +0200
  • Message-id: <201010141744.49119.sasch.pe@xxxxxx>
Hi all,

this patch allows to change the order of repository paths directly in the
project configuration. Currently, this is only possible via editing the raw
config. As the screenie shows, some (hopefully self-explaining) icons where
added (deliberately stolen from the bento icon theme, which deliberately stole
it elsewhere :-). Writing tests for the controller parts remains to be done
though.

As I'm fairly new to the intricacies of webui, this may not be the most ruby-
esque way of doing it. Therefore I'd like to get some comments on it before
committing.
--
Mit freundlichen Grüßen,
Sascha Peilicke
http://saschpe.wordpress.com
From 5834a8a0a8d69c2080697506e229b26181a68af8 Mon Sep 17 00:00:00 2001
From: Sascha Peilicke <sasch.pe@xxxxxx>
Date: Thu, 14 Oct 2010 08:53:27 +0200
Subject: [PATCH] [webui] paths order can now be changed in the project
repository configuration.

Allow changing the order of repository paths (to fetch additional RPMs
from) in the webui directly.
---
src/webui/app/controllers/project_controller.rb | 22 ++++++--
src/webui/app/models/project.rb | 58 +++++++++++++++++++-
.../app/views/project/_edit_repository.html.erb | 14 ++++-
.../vendor/neutral/images/icons/arrow_down.png | Bin 0 -> 379 bytes
.../vendor/neutral/images/icons/arrow_up.png | Bin 0 -> 372 bytes
5 files changed, 86 insertions(+), 8 deletions(-)
create mode 100644 src/webui/public/vendor/neutral/images/icons/arrow_down.png
create mode 100644 src/webui/public/vendor/neutral/images/icons/arrow_up.png

diff --git a/src/webui/app/controllers/project_controller.rb
b/src/webui/app/controllers/project_controller.rb
index 96188e9..7f5d109 100644
--- a/src/webui/app/controllers/project_controller.rb
+++ b/src/webui/app/controllers/project_controller.rb
@@ -573,10 +573,24 @@ class ProjectController < ApplicationController
end

def remove_path_from_target
- @project.remove_path_from_target( params['repository'],
params['path_project'], params['path_repository'] )
- @project.save
- redirect_to :action => :repositories, :project => @project
- return
+ @project.remove_path_from_target( params['repository'],
params['path_project'], params['path_repository'] )
+ @project.save
+ redirect_to :action => :repositories, :project => @project
+ return
+ end
+
+ def move_path_up
+ @project.repository[params['repository']].move_path(params['path_project']
+ '/' + params['path_repository'], :up)
+ @project.save
+ redirect_to :action => :repositories, :project => @project
+ return
+ end
+
+ def move_path_down
+ @project.repository[params['repository']].move_path(params['path_project']
+ '/' + params['path_repository'], :down)
+ @project.save
+ redirect_to :action => :repositories, :project => @project
+ return
end

def save_person
diff --git a/src/webui/app/models/project.rb b/src/webui/app/models/project.rb
index 1296f85..48a9271 100644
--- a/src/webui/app/models/project.rb
+++ b/src/webui/app/models/project.rb
@@ -45,6 +45,63 @@ class Project < ActiveXML::Base
set_archs new_archs
end

+ def paths
+ @paths ||= each_path.map { |p| p.project + '/' + p.repository }
+ return @paths
+ end
+
+ def add_path (path)
+ return nil if paths.include? path
+ project, repository = path.split("/")
+ @paths.push path
+ e = add_element('path')
+ e.data.attributes['repository'] = repository
+ e.data.attributes['project'] = project
+ end
+
+ def remove_path (path)
+ return nil unless paths.include? path
+ project, repository = path.split("/")
+ each_path do |p|
+ delete_element p if p.data.attributes['project'] == project and
p.data.attributes['repository'] == repository
+ end
+ @paths.delete path
+ end
+
+ def set_paths (new_paths)
+ paths.clone.each{ |path| remove_path path }
+ new_paths.each{ |path| add_path path }
+ end
+ def paths= (new_paths)
+ set_paths new_paths
+ end
+
+ # directions are :up and :down
+ def move_path (path, direction=:up)
+ return nil unless (path and not paths.empty?)
+ new_paths = paths.clone
+ for i in 0..new_paths.length
+ if new_paths[i] == path # found the path to move?
+ if direction == :up and i != 0 # move up and is not the first?
+ tmp = new_paths[i - 1]
+ new_paths[i - 1] = new_paths[i]
+ new_paths[i] = tmp
+ break
+ elsif direction == :down and i != new_paths.length - 1
+ tmp = new_paths[i + 1]
+ new_paths[i + 1] = new_paths[i]
+ new_paths[i] = tmp
+ break
+ end
+ end
+ end
+ set_paths new_paths
+ # Relax-NG is only happy when <arch> elems come after <path> elems
+ same_archs = archs.clone
+ set_archs []
+ set_archs same_archs
+ end
+
# def name= (name)
# data.attributes['name'] = name
# end
@@ -162,7 +219,6 @@ class Project < ActiveXML::Base
delete_element "repository[@name='#{repository}']"
end

-
#get all architectures used in this project
#TODO could/should be optimized... somehow...here are many possibilities
#eg. object attribute, ...
diff --git a/src/webui/app/views/project/_edit_repository.html.erb
b/src/webui/app/views/project/_edit_repository.html.erb
index dab449a..11f8561 100644
--- a/src/webui/app/views/project/_edit_repository.html.erb
+++ b/src/webui/app/views/project/_edit_repository.html.erb
@@ -23,9 +23,17 @@
<% if path.project == 'deleted' %>
<%= image_tag 'icons/exclamation.png' %> Target repository has
been removed
<% else %>
- <span><%= h path.project + "/" + path.repository %></span>
- <%= link_to(image_tag('icons/drive_delete.png'), {:action =>
:remove_path_from_target, :project => @project, :repository => repository.name,
:path_project => path.project, :path_repository => path.repository},
- {:confirm => "Really remove #{path.project} /
#{path.repository} path from repository '#{repository.name}'?", :class => 'x',
:method => :post}) -%>
+ <span><%= h path.project + "/" + path.repository %></span>
+ <% if repository.each_path.length > 1 %>
+ <% if path.data != repository.each_path.first.data %>
+ <%= link_to(image_tag('icons/arrow_up.png'), {:action =>
:move_path_up, :project => @project, :repository => repository.name,
:path_project => path.project, :path_repository => path.repository}, {:class =>
'x', :method => :post}) -%>
+ <% end %>
+ <% if path.data != repository.each_path.last.data %>
+ <%= link_to(image_tag('icons/arrow_down.png'), {:action =>
:move_path_down, :project => @project, :repository => repository.name,
:path_project => path.project, :path_repository => path.repository}, {:class =>
'x', :method => :post}) -%>
+ <% end %>
+ <% end %>
+ <%= link_to(image_tag('icons/drive_delete.png'), {:action =>
:remove_path_from_target, :project => @project, :repository => repository.name,
:path_project => path.project, :path_repository => path.repository},
+ {:confirm => "Really remove #{path.project} /
#{path.repository} path from repository '#{repository.name}'?", :class => 'x',
:method => :post}) -%>
<br/>
<% end %>
<% end -%>
diff --git a/src/webui/public/vendor/neutral/images/icons/arrow_down.png
b/src/webui/public/vendor/neutral/images/icons/arrow_down.png
new file mode 100644
index
0000000000000000000000000000000000000000..2c4e279377bf348f9cf53894e76bb673ccf067bd
GIT binary patch
literal 379
zcmV->0fhdEP)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV00004XF*Lt006JZ
zHwB960000PbVXQnQ*UN;cVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBUz4M{{nR5;6}
zlRrxXQ4qxE#1v^2iJY~ff`1CZNGj1T;`fL}y7)m98^!M-SlC$D33d@<A$F#}dpo=P
zEUweLgj}|L!;hKWH%W{U^UPw^!{DVCV~j9$m>RB*?~^j!LKVQ>(O&A{Xr%)RXLn#U
zs4LtZ6rCMFY5|B2$)yG$6aaIF<TWBlAZP}UhET_W1ObikX!RmUE=7d84njuI2%F-d
z^dFqvoVJ^dCg=(^MVPR}e}L}w$%Ewb)LL$Vrl2d*)f7AZ&1|c;{x}s7aybtfzkbGJ
zs28Us2?qV9X!ox^sVdXK<?d^muI-x{K8B;W;q7RzOqWb*<MzeIvr-%Hcb|t<nq=NO
Z{{lQDx5sGRxEBBb002ovPDHLkV1gFGqDue(

literal 0
HcmV?d00001

diff --git a/src/webui/public/vendor/neutral/images/icons/arrow_up.png
b/src/webui/public/vendor/neutral/images/icons/arrow_up.png
new file mode 100644
index
0000000000000000000000000000000000000000..1ebb193243780b8eb1919a51ef27c2a0d36ccec2
GIT binary patch
literal 372
zcmV-)0gL{LP)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV00004XF*Lt006JZ
zHwB960000PbVXQnQ*UN;cVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBUz21!IgR5;6}
zlRqy6Q540`vYCWvXEm}B(P|~^Cy|IoEL#e`l8Q`7mZ%9cl_-RWhIWVOym$XSm1biG
zZ%%tpemUpf+*SwyO*BzA+`ri=b}#!^QGmVc?Yp!+yPPJS-r!>6w#wHUuW*nL5>vZR
zlg{G&%mT~|kL3ei%GW0*UOHUMs5XI$4uxe-L?I@SAefq*207}Iqtjm#e5*fP53AiC
z)C|RQfwzxx<#_WfANRGZx{+tFDl8~Q?;~Ve=lM^*8UTTnVL?HTDz8uta0D@d28E9S
z_)i8aLz^UE6PPKy<A?-~z$(pmU_rs2BLT`V7?>mi;2GJ`34{eIia-CtfAt0H61rk0
SPTNud0000<MNUMnLSTabij-pj

literal 0
HcmV?d00001

--
1.7.1

< Previous Next >
Follow Ups