Commit 69e41250d1b1eea609ae63f2702d5888396cba9a

Authored by randx
1 parent 21781043

Styled New/Edit Project for admin area

app/views/admin/projects/_form.html.haml
1   -= form_for [:admin, @admin_project] do |f|
2   - -if @admin_project.errors.any?
  1 += form_for [:admin, project] do |f|
  2 + -if project.errors.any?
3 3 .alert-message.block-message.error
4 4 %ul
5   - - @admin_project.errors.full_messages.each do |msg|
  5 + - project.errors.full_messages.each do |msg|
6 6 %li= msg
7 7  
8   - .clearfix
9   - = f.label :name
10   - .input= f.text_field :name
11   - .clearfix
12   - = f.label :path do
13   - Path
  8 + .clearfix.project_name_holder
  9 + = f.label :name do
  10 + Project name is
14 11 .input
15   - .input-prepend
16   - %span.add-on= Gitlab.config.ssh_path
17   - = f.text_field :path, :placeholder => "example_project", :disabled => !@admin_project.new_record?
18   - .clearfix
19   - = f.label :code do
20   - Code
21   - .input
22   - .input-prepend
23   - %span.add-on= web_app_url
24   - = f.text_field :code, :placeholder => "example"
  12 + = f.text_field :name, :placeholder => "Example Project", :class => "xxlarge"
  13 + = f.submit project.new_record? ? 'Create project' : 'Save Project', :class => "btn primary"
25 14  
26   - - unless @admin_project.new_record?
  15 + %hr
  16 + .alert.alert-info
  17 + %h5 Advanced settings:
  18 + .clearfix
  19 + = f.label :path do
  20 + Git Clone
  21 + .input
  22 + .input-prepend
  23 + %span.add-on= Gitlab.config.ssh_path
  24 + = f.text_field :path, :placeholder => "example_project", :disabled => !!project.id
  25 + %span.add-on= ".git"
27 26 .clearfix
28   - = f.label :owner_id
29   - .input= f.select :owner_id, User.all.map { |user| [user.name, user.id] }
  27 + = f.label :code do
  28 + URL
  29 + .input
  30 + .input-prepend
  31 + %span.add-on= web_app_url
  32 + = f.text_field :code, :placeholder => "example"
30 33  
31   - - if @admin_project.repo_exists?
  34 + - unless project.new_record?
32 35 .clearfix
33   - = f.label :default_branch, "Default Branch"
34   - .input= f.select(:default_branch, @admin_project.heads.map(&:name), {}, :style => "width:210px;")
  36 + = f.label :owner_id
  37 + .input= f.select :owner_id, User.all.map { |user| [user.name, user.id] }
35 38  
36   - .well
37   - %h5 Features
  39 + - if project.repo_exists?
  40 + .clearfix
  41 + = f.label :default_branch, "Default Branch"
  42 + .input= f.select(:default_branch, project.heads.map(&:name), {}, :style => "width:210px;")
  43 +
  44 + - unless project.new_record?
  45 + .alert.alert-info
  46 + %h5 Features:
38 47  
39 48 .clearfix
40 49 = f.label :issues_enabled, "Issues"
... ... @@ -48,19 +57,19 @@
48 57 = f.label :wall_enabled, "Wall"
49 58 .input= f.check_box :wall_enabled
50 59  
51   - .clearfix
52   - = f.label :description
53   - .input= f.text_area :description, :class => "xxlarge"
54   - .clear
55   - %br
56   - .actions
57   - = f.submit 'Save', :class => "btn primary"
58   - = link_to 'Cancel', [:admin, @admin_project], :class => "btn"
59   - - unless @admin_project.new_record?
60   - = link_to 'Destroy', [:admin, @admin_project], :confirm => 'Are you sure?', :method => :delete, :class => "btn danger right"
  60 + .clearfix
  61 + = f.label :wiki_enabled, "Wiki"
  62 + .input= f.check_box :wiki_enabled
  63 +
  64 + - unless project.new_record?
  65 + .actions
  66 + = f.submit 'Save Project', :class => "btn primary"
  67 +
  68 +
61 69  
62 70 :javascript
63 71 $(function(){
64 72 $('#project_owner_id').chosen();
65 73 new Projects();
66 74 })
  75 +
... ...
app/views/admin/projects/edit.html.haml
1   -%h3= @admin_project.name
  1 +%h3.page_title #{@admin_project.name} → Edit project
2 2 %hr
3   -= render 'form'
  3 += render 'form', :project => @admin_project
... ...
app/views/admin/projects/new.html.haml
1   -%h2 New project
  1 +%h3.page_title New project
2 2 %hr
3   -= render 'form'
  3 += render 'form', :project => @admin_project
... ...
app/views/admin/projects/show.html.haml
... ... @@ -25,9 +25,9 @@
25 25 %tr
26 26 %td
27 27 %b
28   - Description:
  28 + Owner:
29 29 %td
30   - = @admin_project.description
  30 + = @admin_project.owner.name
31 31 %tr
32 32 %td
33 33 %b
... ...
spec/requests/admin/admin_projects_spec.rb
... ... @@ -41,15 +41,15 @@ describe "Admin::Projects" do
41 41 end
42 42  
43 43 it "should have project edit page" do
44   - page.should have_content("Name")
45   - page.should have_content("Code")
  44 + page.should have_content("Project name")
  45 + page.should have_content("URL")
46 46 end
47 47  
48 48 describe "Update project" do
49 49 before do
50 50 fill_in "project_name", :with => "Big Bang"
51 51 fill_in "project_code", :with => "BB1"
52   - click_button "Save"
  52 + click_button "Save Project"
53 53 @project.reload
54 54 end
55 55  
... ... @@ -76,20 +76,19 @@ describe "Admin::Projects" do
76 76 end
77 77  
78 78 it "should have labels for new project" do
79   - page.should have_content("Name")
80   - page.should have_content("Path")
81   - page.should have_content("Description")
  79 + page.should have_content("Project name is")
  80 + page.should have_content("Git Clone")
  81 + page.should have_content("URL")
82 82 end
83 83 end
84 84  
85 85 describe "POST /admin/projects" do
86 86 before do
87 87 visit new_admin_project_path
88   - fill_in 'Name', :with => 'NewProject'
89   - fill_in 'Code', :with => 'NPR'
90   - fill_in 'Path', :with => 'gitlabhq_1'
91   - fill_in 'Description', :with => 'New Project Description'
92   - expect { click_button "Save" }.to change { Project.count }.by(1)
  88 + fill_in 'project_name', :with => 'NewProject'
  89 + fill_in 'project_code', :with => 'NPR'
  90 + fill_in 'project_path', :with => 'gitlabhq_1'
  91 + expect { click_button "Create project" }.to change { Project.count }.by(1)
93 92 @project = Project.last
94 93 end
95 94  
... ... @@ -100,7 +99,6 @@ describe "Admin::Projects" do
100 99 it "should show project" do
101 100 page.should have_content(@project.name)
102 101 page.should have_content(@project.path)
103   - page.should have_content(@project.description)
104 102 end
105 103 end
106 104  
... ...