Skip to content

Commit 606a685

Browse files
committed
Merge branch 'CHEF-505' of git://github.com/me/chef into me/CHEF-505
2 parents b3f0d73 + e73e0d6 commit 606a685

3 files changed

Lines changed: 60 additions & 24 deletions

File tree

chef-server-webui/app/controllers/roles.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ def show
4444
def new
4545
@available_recipes = get_available_recipes
4646
@role = Chef::Role.new
47-
@current_recipes = @role.recipes
47+
@available_roles = Chef::Role.list.keys.sort
48+
@run_list = @role.run_list
4849
render
4950
end
5051

@@ -56,7 +57,8 @@ def edit
5657
raise NotFound, "Cannot load role #{params[:id]}"
5758
end
5859
@available_recipes = get_available_recipes
59-
@current_recipes = @role.recipes
60+
@available_roles = Chef::Role.list.keys.sort
61+
@run_list = @role.run_list
6062
render
6163
end
6264

@@ -65,7 +67,7 @@ def create
6567
begin
6668
@role = Chef::Role.new
6769
@role.name(params[:name])
68-
@role.recipes(params[:for_role] ? params[:for_role] : [])
70+
@role.run_list(params[:for_role] ? params[:for_role] : [])
6971
@role.description(params[:description]) if params[:description] != ''
7072
@role.default_attributes(JSON.parse(params[:default_attributes])) if params[:default_attributes] != ''
7173
@role.override_attributes(JSON.parse(params[:override_attributes])) if params[:override_attributes] != ''
@@ -84,7 +86,7 @@ def create
8486
@role = Chef::Role.new
8587
@role.default_attributes(JSON.parse(params[:default_attributes])) if params[:default_attributes] != ''
8688
@role.override_attributes(JSON.parse(params[:override_attributes])) if params[:override_attributes] != ''
87-
@current_recipes = params[:for_role] ? params[:for_role] : []
89+
@run_list = params[:for_role] ? params[:for_role] : []
8890
@_message = { :error => $! }
8991
render :new
9092
end
@@ -99,7 +101,7 @@ def update
99101
end
100102

101103
begin
102-
@role.recipes(params[:for_role] ? params[:for_role] : [])
104+
@role.run_list(params[:for_role] ? params[:for_role] : [])
103105
@role.description(params[:description]) if params[:description] != ''
104106
@role.default_attributes(JSON.parse(params[:default_attributes])) if params[:default_attributes] != ''
105107
@role.override_attributes(JSON.parse(params[:override_attributes])) if params[:override_attributes] != ''
@@ -108,7 +110,7 @@ def update
108110
render :show
109111
rescue ArgumentError
110112
@available_recipes = get_available_recipes
111-
@current_recipes = params[:for_role] ? params[:for_role] : []
113+
@run_list = params[:for_role] ? params[:for_role] : []
112114
@role.default_attributes(JSON.parse(params[:default_attributes])) if params[:default_attributes] != ''
113115
@role.override_attributes(JSON.parse(params[:override_attributes])) if params[:override_attributes] != ''
114116
render :edit

chef-server-webui/app/views/roles/_form.html.haml

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,34 @@
1414
%table.sortable
1515
%tr
1616
%td
17-
%label.label Available Recipes
17+
%label.label Available Roles
1818
%td
19-
%label.label Recipes for this Role
19+
%label.label Run List
2020
%tr
2121
%td
2222
%div.sortable
23-
%ul#available_recipes.connectedSortable
24-
- @available_recipes.each do |recipe|
25-
%li{ :id => h(recipe), :class => 'ui-state-highlight' }= h recipe
26-
%td
27-
%div.sortable
23+
%ul#node_available_roles.connectedSortable
24+
- @available_roles.each do |role|
25+
%li{ :id => "role[#{role}]", :class => 'ui-state-highlight' }= h role
26+
%td{:rowspan => 3}
27+
%div.sortable.run-list
2828
%ul#for_role.connectedSortable
29-
- @current_recipes.each do |recipe|
30-
%li{ :id => h(recipe), :class => 'ui-state-highlight' }= h recipe
31-
29+
- @run_list.each do |entry|
30+
- type, name, fname = @run_list.parse_entry(entry)
31+
%li{ :id => h(fname), :class => type == 'role' ? 'ui-state-highlight' : 'ui-state-default' }= h name
3232
%td.help
3333
%span.description
3434
Drag recipes from the list of Available Recipes section on the left, and drop them
35-
in the "Recipes for this Role" section on the right. Then sort the recipes for this role list to the order you would like to see the recipes applied.
35+
in the "Recipes for this node" section on the right. Then sort the recipes for this node list to the order you would like to see the recipes applied.
36+
%tr
37+
%td
38+
%label.label Available Recipes
39+
%tr
40+
%td
41+
%div.sortable
42+
%ul#node_available_recipes.connectedSortable
43+
- @available_recipes.each do |recipe|
44+
%li{ :id => "recipe[#{recipe}]", :class => 'ui-state-default' }= h recipe
3645

3746
%div.group.form{:style => "position:relative;"}
3847
%label.label Default and Override Attributes

chef-server-webui/app/views/roles/show.html.haml

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,41 @@
99
%h3 Description
1010
= @role.description
1111

12-
.left
13-
%h3 Recipes
14-
%table#recipes.table
12+
.left
13+
%h3 Run List
14+
%table.table
1515
%tr
1616
%th.first Position
17-
%th.last Name
18-
- @role.recipes.each_index do |i|
17+
%th Name
18+
%th.last Type
19+
- if @role.run_list.empty?
20+
%tr
21+
%td{:colspan => 2} This role does not include any roles or recipes.
22+
- else
23+
-@role.run_list.each_index do |i|
24+
- type, name, fname = @role.run_list.parse_entry(@role.run_list[i])
25+
%tr
26+
%td.position= i
27+
%td= name
28+
%td= type
29+
.left.accordion
30+
%h3.head= link_to("Recipes", "#")
31+
- full_recipe_list, default_attrs, override_attrs = @role.run_list.expand()
32+
%div
33+
%span.description.form.help
34+
This is the list of recipes, fully expanded, as they will be applied to the node in question.
35+
%table#recipes.table
1936
%tr
20-
%td.position= i
21-
%td= @role.recipes[i]
37+
%th.first Position
38+
%th.last Name
39+
- if @role.run_list.empty?
40+
%tr
41+
%td{:colspan => 2} This node has no recipes applied.
42+
- else
43+
- full_recipe_list.each_index do |i|
44+
%tr
45+
%td.position= i
46+
%td= full_recipe_list[i]
2247
.left
2348
%h3 Default Attributes
2449
= build_tree('defattrs', @role.default_attributes)

0 commit comments

Comments
 (0)