Commit f59b7409cb653a6e31b5fdc1f45fab211bc3d646

Authored by Dmitriy Zaporozhets
1 parent bbd12591

Improve user expirience while create/edit project settings

app/assets/javascripts/commits.js.coffee
... ... @@ -23,7 +23,7 @@ class CommitsList
23 23 @data.offset = limit
24 24  
25 25 this.initLoadMore()
26   - this.showProgress();
  26 + this.showProgress()
27 27  
28 28 @getOld: ->
29 29 this.showProgress()
... ... @@ -41,7 +41,7 @@ class CommitsList
41 41 else
42 42 @disable = true
43 43  
44   - @initLoadMore: ->
  44 + @initLoadMore: ->
45 45 $(document).endlessScroll
46 46 bottomPixels: 400
47 47 fireDelay: 1000
... ... @@ -51,4 +51,4 @@ class CommitsList
51 51 callback: =>
52 52 this.getOld()
53 53  
54   -this.CommitsList = CommitsList
55 54 \ No newline at end of file
  55 +this.CommitsList = CommitsList
... ...
app/assets/javascripts/main.js.coffee
... ... @@ -55,8 +55,10 @@ $ ->
55 55 $(".one_click_select").on 'click', -> $(@).select()
56 56  
57 57 # Click a .appear-link, appear-data fadeout
58   - $(".appear-link").on 'click', ->
  58 + $(".appear-link").on 'click', (e) ->
59 59 $('.appear-data').fadeIn()
  60 + e.preventDefault()
  61 +
60 62  
61 63 # Initialize chosen selects
62 64 $('select.chosen').chosen()
... ...
app/assets/javascripts/project.js.coffee
1 1 class Project
2 2 constructor: ->
3   - $('.new_project, .edit_project').on 'ajax:before', ->
4   - $('.project_new_holder, .project_edit_holder').hide()
  3 + $('.project-edit-container').on 'ajax:before', =>
  4 + $('.project-edit-container').hide()
5 5 $('.save-project-loader').show()
6 6  
7   - $('form #project_default_branch').chosen()
  7 + @initEvents()
  8 +
  9 +
  10 + initEvents: ->
8 11 disableButtonIfEmptyField '#project_name', '.project-submit'
9 12  
10 13 $('#project_issues_enabled').change ->
... ... @@ -21,6 +24,7 @@ class Project
21 24 else
22 25 $('#project_issues_tracker_id').removeAttr('disabled')
23 26  
  27 +
24 28 @Project = Project
25 29  
26 30 $ ->
... ...
app/views/projects/_errors.html.haml 0 → 100644
... ... @@ -0,0 +1,4 @@
  1 +- if @project.errors.any?
  2 + .alert.alert-error
  3 + %button{ type: "button", class: "close", "data-dismiss" => "alert"} ×
  4 + = @project.errors.full_messages.first
... ...
app/views/projects/_form.html.haml
... ... @@ -1,151 +0,0 @@
1   -.row
2   - .span3
3   - %ul.nav.nav-pills.nav-stacked
4   - %li.active
5   - = link_to 'Settings', '#tab-settings', 'data-toggle' => 'tab'
6   - %li
7   - = link_to 'Transfer', '#tab-transfer', 'data-toggle' => 'tab'
8   - %li
9   - = link_to 'Remove', '#tab-remove', 'data-toggle' => 'tab'
10   -
11   - .span9
12   - .tab-content
13   - .tab-pane.active#tab-settings
14   - .ui-box.white
15   - %h5.title Settings:
16   - .form-holder
17   - = form_for(@project, remote: true) do |f|
18   - - if @project.errors.any?
19   - .alert.alert-error
20   - %ul
21   - - @project.errors.full_messages.each do |msg|
22   - %li= msg
23   -
24   - %fieldset
25   - .clearfix.project_name_holder
26   - = f.label :name do
27   - Project name is
28   - .input
29   - = f.text_field :name, placeholder: "Example Project", class: "span5"
30   -
31   -
32   - .clearfix
33   - = f.label :description do
34   - Project description
35   - %span.light (optional)
36   - .input
37   - = f.text_area :description, placeholder: "awesome project", class: "span5", rows: 3, maxlength: 250
38   -
39   - - unless @project.empty_repo?
40   - .clearfix
41   - = f.label :default_branch, "Default Branch"
42   - .input= f.select(:default_branch, @repository.branch_names, {})
43   -
44   -
45   - - if can?(current_user, :change_public_mode, @project)
46   - %fieldset.public-mode
47   - %legend
48   - Public mode:
49   - .control-group
50   - = f.label :public, class: 'control-label' do
51   - %span Public access
52   - .controls
53   - = f.check_box :public
54   - %span.descr
55   - If checked, this project can be cloned
56   - %em without any
57   - authentication.
58   - It will also be listed on the #{link_to "public access directory", public_root_path}.
59   - %em Any
60   - user will have #{link_to "Guest", help_permissions_path} permissions on the repository.
61   -
62   - %fieldset.features
63   - %legend
64   - Labels:
65   - .control-group
66   - = f.label :label_list, "Labels", class: 'control-label'
67   - .controls
68   - = f.text_field :label_list, maxlength: 2000, class: "span5"
69   - %p.hint Separate with comma.
70   -
71   - %fieldset.features
72   - %legend
73   - Features:
74   - .control-group
75   - = f.label :issues_enabled, "Issues", class: 'control-label'
76   - .controls
77   - = f.check_box :issues_enabled
78   - %span.descr Lightweight issue tracking system for this project
79   -
80   - - if Project.issues_tracker.values.count > 1
81   - .control-group
82   - = f.label :issues_tracker, "Issues tracker", class: 'control-label'
83   - .input= f.select(:issues_tracker, Project.issues_tracker.values, {}, { disabled: !@project.issues_enabled })
84   -
85   - .clearfix
86   - = f.label :issues_tracker_id, "Project name or id in issues tracker", class: 'control-label'
87   - .input= f.text_field :issues_tracker_id, disabled: !@project.can_have_issues_tracker_id?
88   -
89   - .control-group
90   - = f.label :merge_requests_enabled, "Merge Requests", class: 'control-label'
91   - .controls
92   - = f.check_box :merge_requests_enabled
93   - %span.descr Submit changes to be merged upstream.
94   -
95   - .control-group
96   - = f.label :wiki_enabled, "Wiki", class: 'control-label'
97   - .controls
98   - = f.check_box :wiki_enabled
99   - %span.descr Pages for project documentation
100   -
101   - .control-group
102   - = f.label :wall_enabled, "Wall", class: 'control-label'
103   - .controls
104   - = f.check_box :wall_enabled
105   - %span.descr Simple chat system for broadcasting inside project
106   -
107   - .control-group
108   - = f.label :snippets_enabled, "Snippets", class: 'control-label'
109   - .controls
110   - = f.check_box :snippets_enabled
111   - %span.descr Share code pastes with others out of git repository
112   -
113   -
114   - .form-actions
115   - = f.submit 'Save', class: "btn btn-save"
116   -
117   - .tab-pane#tab-transfer
118   - - if can?(current_user, :change_namespace, @project)
119   - .ui-box.ui-box-danger
120   - %h5.title Transfer project
121   - .errors-holder
122   - .form-holder
123   - = form_for(@project, url: transfer_project_path(@project), remote: true, html: { class: 'transfer-project' }) do |f|
124   - .control-group
125   - = f.label :namespace_id do
126   - %span Namespace
127   - .controls
128   - .clearfix
129   - = f.select :namespace_id, namespaces_options(@project.namespace_id || Namespace::global_id), {prompt: 'Choose a project namespace'}, {class: 'chosen'}
130   - %ul
131   - %li Be careful. Changing project namespace can have unintended side effects
132   - %li You can transfer project only to namespaces you can manage
133   - %li You will need to update your local repositories to point to the new location.
134   - .form-actions
135   - = f.submit 'Transfer', class: "btn btn-remove"
136   - - else
137   - %p.nothing_here_message Only project owner can transfer a project
138   -
139   - .tab-pane#tab-remove
140   - - if can?(current_user, :remove_project, @project)
141   - .ui-box.ui-box-danger
142   - %h5.title Remove project
143   - .ui-box-body
144   - %p
145   - Remove of project will cause removing repository and all related resources like issues, merge requests etc.
146   - %p
147   - %strong Removed project can not be restored!
148   -
149   - = link_to 'Remove project', @project, confirm: 'Removed project can not be restored! Are you sure?', method: :delete, class: "btn btn-remove btn-small"
150   - - else
151   - %p.nothing_here_message Only project owner can remove a project
app/views/projects/_new_form.html.haml
... ... @@ -1,48 +0,0 @@
1   -= form_for(@project, remote: true) do |f|
2   - - if @project.errors.any?
3   - .alert.alert-error
4   - %span= @project.errors.full_messages.first
5   - .clearfix.project_name_holder
6   - = f.label :name do
7   - Project name is
8   - .input
9   - = f.text_field :name, placeholder: "Example Project", class: "xxlarge"
10   - = f.submit 'Create project', class: "btn btn-create project-submit"
11   -
12   - - if current_user.can_select_namespace?
13   - .clearfix
14   - = f.label :namespace_id do
15   - %span Namespace
16   - .input
17   - = f.select :namespace_id, namespaces_options(params[:namespace_id] || :current_user), {}, {class: 'chosen'}
18   -
19   -
20   - .clearfix
21   - .input
22   - = link_to "#", class: 'appear-link' do
23   - %i.icon-upload-alt
24   - %span Import existing repository?
25   - .clearfix.appear-data
26   - = f.label :import_url do
27   - %span Import existing repo
28   - .input
29   - = f.text_field :import_url, class: 'xlarge', placeholder: 'https://github.com/randx/six.git'
30   - .light
31   - URL must be clonable
32   -
33   - %p.padded
34   - New projects are private by default. You choose who can see the project and commit to repository.
35   - %hr
36   -
37   - - if current_user.can_create_group?
38   - .clearfix
39   - .input.light
40   - Need a group for several dependent projects?
41   - = link_to new_group_path, class: "btn btn-tiny" do
42   - Create a group
43   - - if current_user.can_create_team?
44   - .clearfix
45   - .input.light
46   - Want to share a project between team?
47   - = link_to new_team_path, class: "btn btn-tiny" do
48   - Create a team
app/views/projects/create.js.haml
... ... @@ -3,8 +3,6 @@
3 3 location.href = "#{project_path(@project)}";
4 4 - else
5 5 :plain
6   - $('.project_new_holder').show();
7   - $("#new_project").replaceWith("#{escape_javascript(render('new_form'))}");
  6 + $(".project-edit-errors").html("#{escape_javascript(render('errors'))}");
8 7 $('.save-project-loader').hide();
9   - new Projects();
10   - $('select.chosen').chosen()
  8 + $('.project-edit-container').show();
... ...
app/views/projects/edit.html.haml
1 1 = render "projects/settings_nav"
2 2  
3   -.project_edit_holder
  3 +.project-edit-container
4 4 %h3.page_title Edit Project
5 5 %hr
6   - = render "projects/form"
7   -%div.save-project-loader.hide
  6 + .project-edit-errors
  7 + .project-edit-content
  8 + .row
  9 + .span3
  10 + %ul.nav.nav-pills.nav-stacked
  11 + %li.active
  12 + = link_to 'Settings', '#tab-settings', 'data-toggle' => 'tab'
  13 + %li
  14 + = link_to 'Transfer', '#tab-transfer', 'data-toggle' => 'tab'
  15 + %li
  16 + = link_to 'Remove', '#tab-remove', 'data-toggle' => 'tab'
  17 +
  18 + .span9
  19 + .tab-content
  20 + .tab-pane.active#tab-settings
  21 + .ui-box.white
  22 + %h5.title Settings:
  23 + .form-holder
  24 + = form_for(@project, remote: true) do |f|
  25 + %fieldset
  26 + .clearfix.project_name_holder
  27 + = f.label :name do
  28 + Project name is
  29 + .input
  30 + = f.text_field :name, placeholder: "Example Project", class: "span5"
  31 +
  32 +
  33 + .clearfix
  34 + = f.label :description do
  35 + Project description
  36 + %span.light (optional)
  37 + .input
  38 + = f.text_area :description, placeholder: "awesome project", class: "span5", rows: 3, maxlength: 250
  39 +
  40 + - unless @project.empty_repo?
  41 + .clearfix
  42 + = f.label :default_branch, "Default Branch"
  43 + .input= f.select(:default_branch, @repository.branch_names, {}, {class: 'chosen'})
  44 +
  45 +
  46 + - if can?(current_user, :change_public_mode, @project)
  47 + %fieldset.public-mode
  48 + %legend
  49 + Public mode:
  50 + .control-group
  51 + = f.label :public, class: 'control-label' do
  52 + %span Public access
  53 + .controls
  54 + = f.check_box :public
  55 + %span.descr
  56 + If checked, this project can be cloned
  57 + %em without any
  58 + authentication.
  59 + It will also be listed on the #{link_to "public access directory", public_root_path}.
  60 + %em Any
  61 + user will have #{link_to "Guest", help_permissions_path} permissions on the repository.
  62 +
  63 + %fieldset.features
  64 + %legend
  65 + Labels:
  66 + .control-group
  67 + = f.label :label_list, "Labels", class: 'control-label'
  68 + .controls
  69 + = f.text_field :label_list, maxlength: 2000, class: "span5"
  70 + %p.hint Separate with comma.
  71 +
  72 + %fieldset.features
  73 + %legend
  74 + Features:
  75 + .control-group
  76 + = f.label :issues_enabled, "Issues", class: 'control-label'
  77 + .controls
  78 + = f.check_box :issues_enabled
  79 + %span.descr Lightweight issue tracking system for this project
  80 +
  81 + - if Project.issues_tracker.values.count > 1
  82 + .control-group
  83 + = f.label :issues_tracker, "Issues tracker", class: 'control-label'
  84 + .input= f.select(:issues_tracker, Project.issues_tracker.values, {}, { disabled: !@project.issues_enabled })
  85 +
  86 + .clearfix
  87 + = f.label :issues_tracker_id, "Project name or id in issues tracker", class: 'control-label'
  88 + .input= f.text_field :issues_tracker_id, disabled: !@project.can_have_issues_tracker_id?
  89 +
  90 + .control-group
  91 + = f.label :merge_requests_enabled, "Merge Requests", class: 'control-label'
  92 + .controls
  93 + = f.check_box :merge_requests_enabled
  94 + %span.descr Submit changes to be merged upstream.
  95 +
  96 + .control-group
  97 + = f.label :wiki_enabled, "Wiki", class: 'control-label'
  98 + .controls
  99 + = f.check_box :wiki_enabled
  100 + %span.descr Pages for project documentation
  101 +
  102 + .control-group
  103 + = f.label :wall_enabled, "Wall", class: 'control-label'
  104 + .controls
  105 + = f.check_box :wall_enabled
  106 + %span.descr Simple chat system for broadcasting inside project
  107 +
  108 + .control-group
  109 + = f.label :snippets_enabled, "Snippets", class: 'control-label'
  110 + .controls
  111 + = f.check_box :snippets_enabled
  112 + %span.descr Share code pastes with others out of git repository
  113 +
  114 +
  115 + .form-actions
  116 + = f.submit 'Save', class: "btn btn-save"
  117 +
  118 + .tab-pane#tab-transfer
  119 + - if can?(current_user, :change_namespace, @project)
  120 + .ui-box.ui-box-danger
  121 + %h5.title Transfer project
  122 + .errors-holder
  123 + .form-holder
  124 + = form_for(@project, url: transfer_project_path(@project), remote: true, html: { class: 'transfer-project' }) do |f|
  125 + .control-group
  126 + = f.label :namespace_id do
  127 + %span Namespace
  128 + .controls
  129 + .clearfix
  130 + = f.select :namespace_id, namespaces_options(@project.namespace_id || Namespace::global_id), {prompt: 'Choose a project namespace'}, {class: 'chosen'}
  131 + %ul
  132 + %li Be careful. Changing project namespace can have unintended side effects
  133 + %li You can transfer project only to namespaces you can manage
  134 + %li You will need to update your local repositories to point to the new location.
  135 + .form-actions
  136 + = f.submit 'Transfer', class: "btn btn-remove"
  137 + - else
  138 + %p.nothing_here_message Only project owner can transfer a project
  139 +
  140 + .tab-pane#tab-remove
  141 + - if can?(current_user, :remove_project, @project)
  142 + .ui-box.ui-box-danger
  143 + %h5.title Remove project
  144 + .ui-box-body
  145 + %p
  146 + Remove of project will cause removing repository and all related resources like issues, merge requests etc.
  147 + %p
  148 + %strong Removed project can not be restored!
  149 +
  150 + = link_to 'Remove project', @project, confirm: 'Removed project can not be restored! Are you sure?', method: :delete, class: "btn btn-remove btn-small"
  151 + - else
  152 + %p.nothing_here_message Only project owner can remove a project
  153 +
  154 +.save-project-loader.hide
8 155 %center
9 156 = image_tag "ajax_loader.gif"
10 157 %h3 Saving project. Please wait a moment, this page will automatically refresh when ready.
... ...
app/views/projects/new.html.haml
1   -.project_new_holder
2   - %h3.page_title
3   - New Project
  1 +.project-edit-container
  2 + %h3.page_title New Project
4 3 %hr
5   - = render 'new_form'
6   -%div.save-project-loader.hide
  4 + .project-edit-errors
  5 + .project-edit-content
  6 + = form_for @project, remote: true do |f|
  7 + .clearfix.project_name_holder
  8 + = f.label :name do
  9 + Project name is
  10 + .input
  11 + = f.text_field :name, placeholder: "Example Project", class: "xxlarge", tabindex: 1
  12 + = f.submit 'Create project', class: "btn btn-create project-submit", tabindex: 3
  13 +
  14 + - if current_user.can_select_namespace?
  15 + .clearfix
  16 + = f.label :namespace_id do
  17 + %span Namespace
  18 + .input
  19 + = f.select :namespace_id, namespaces_options(params[:namespace_id] || :current_user), {}, {class: 'chosen', tabindex: 2}
  20 +
  21 + .clearfix
  22 + .input
  23 + = link_to "#", class: 'appear-link' do
  24 + %i.icon-upload-alt
  25 + %span Import existing repository?
  26 + .clearfix.appear-data.import-url-data
  27 + = f.label :import_url do
  28 + %span Import existing repo
  29 + .input
  30 + = f.text_field :import_url, class: 'xlarge', placeholder: 'https://github.com/randx/six.git'
  31 + .light
  32 + URL must be clonable
  33 +
  34 + %p.padded
  35 + New projects are private by default. You choose who can see the project and commit to repository.
  36 + %hr
  37 +
  38 + - if current_user.can_create_group?
  39 + .clearfix
  40 + .input.light
  41 + Need a group for several dependent projects?
  42 + = link_to new_group_path, class: "btn btn-tiny" do
  43 + Create a group
  44 + - if current_user.can_create_team?
  45 + .clearfix
  46 + .input.light
  47 + Want to share a project between team?
  48 + = link_to new_team_path, class: "btn btn-tiny" do
  49 + Create a team
  50 +
  51 +.save-project-loader.hide
7 52 %center
8 53 = image_tag "ajax_loader.gif"
9 54 %h3 Creating project & repository. Please wait a moment, this page will automatically refresh when ready.
... ...
app/views/projects/update.js.haml
... ... @@ -3,6 +3,7 @@
3 3 location.href = "#{edit_project_path(@project)}";
4 4 - else
5 5 :plain
6   - $('.project_edit_holder').show();
7   - $(".edit_project").replaceWith("#{escape_javascript(render('form'))}");
  6 + $(".project-edit-errors").html("#{escape_javascript(render('errors'))}");
8 7 $('.save-project-loader').hide();
  8 + $('.project-edit-container').show();
  9 + $('.project-edit-content .btn-save').enableButton();
... ...