new.html.haml 6.7 KB
Newer Older
1
- page_title    'New Project'
2
- header_title  "Projects", dashboard_projects_path
B
Use dig  
blackst0ne 已提交
3
- visibility_level = params.dig(:project, :visibility_level) || default_project_visibility
D
Douwe Maan 已提交
4

D
Dmitriy Zaporozhets 已提交
5
.project-edit-container
6
  .project-edit-errors
7
    = render 'projects/errors'
8 9 10 11 12 13 14 15
  .row.prepend-top-default
    .col-lg-3.profile-settings-sidebar
      %h4.prepend-top-0
        New project
      %p
        Create or Import your project from popular Git services
    .col-lg-9
      = form_for @project, html: { class: 'new_project' } do |f|
16
        .row
17 18 19 20 21 22 23 24 25
          .form-group.col-xs-12.col-sm-6
            = f.label :namespace_id, class: 'label-light' do
              %span
                Project path
            .form-group
              .input-group
                - if current_user.can_select_namespace?
                  .input-group-addon
                    = root_url
26
                  = f.select :namespace_id, namespaces_options(namespace_id_from(params) || :current_user, display_path: true, extra_group: namespace_id_from(params)), {}, { class: 'select2 js-select-namespace', tabindex: 1}
27

28
                - else
29 30
                  .input-group-addon.static-namespace
                    #{root_url}#{current_user.username}/
31
                  = f.hidden_field :namespace_id, value: current_user.namespace_id
32
          .form-group.col-xs-12.col-sm-6.project-path
33
            = f.label :path, class: 'label-light' do
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
              %span
                Project name
            = f.text_field :path, placeholder: "my-awesome-project", class: "form-control", tabindex: 2, autofocus: true, required: true
        - if current_user.can_create_group?
          .help-block
            Want to house several dependent projects under the same namespace?
            = link_to "Create a group", new_group_path

        - if import_sources_enabled?
          .project-import.js-toggle-container
            .form-group.clearfix
              = f.label :visibility_level, class: 'label-light' do
                Import project from
              .col-sm-12.import-buttons
                %div
                  - if github_import_enabled?
50
                    = link_to new_import_github_path, class: 'btn import_github' do
51
                      = icon('github', text: 'GitHub')
52 53
                %div
                  - if bitbucket_import_enabled?
B
Bryce Johnson 已提交
54
                    = link_to status_import_bitbucket_path, class: "btn import_bitbucket #{'how_to_import_link' unless bitbucket_import_configured?}" do
55 56
                      = icon('bitbucket', text: 'Bitbucket')
                    - unless bitbucket_import_configured?
57 58 59
                      = render 'bitbucket_import_modal'
                %div
                  - if gitlab_import_enabled?
Z
Z.J. van de Weg 已提交
60
                    = link_to status_import_gitlab_path, class: "btn import_gitlab #{'how_to_import_link' unless gitlab_import_configured?}" do
61 62
                      = icon('gitlab', text: 'GitLab.com')
                    - unless gitlab_import_configured?
63 64 65 66
                      = render 'gitlab_import_modal'
                %div
                  - if google_code_import_enabled?
                    = link_to new_import_google_code_path, class: 'btn import_google_code' do
67
                      = icon('google', text: 'Google Code')
68 69 70
                %div
                  - if fogbugz_import_enabled?
                    = link_to new_import_fogbugz_path, class: 'btn import_fogbugz' do
71
                      = icon('bug', text: 'Fogbugz')
72 73 74 75 76
                %div
                  - if gitea_import_enabled?
                    = link_to new_import_gitea_url, class: 'btn import_gitea' do
                      = custom_icon('go_logo')
                      Gitea
77 78
                %div
                  - if git_import_enabled?
E
Eric Eastwood 已提交
79
                    %button.btn.js-toggle-button.import_git{ type: "button" }
80
                      = icon('git', text: 'Repo by URL')
81
                .import_gitlab_project.has-tooltip{ data: { container: 'body' } }
82
                  - if gitlab_project_import_enabled?
83
                    = link_to new_import_gitlab_project_path, class: 'btn btn_import_gitlab_project project-submit' do
84
                      = icon('gitlab', text: 'GitLab export')
85 86 87 88 89 90 91 92 93 94 95 96 97

            .js-toggle-content.hide
              = render "shared/import_form", f: f

        .form-group
          = f.label :description, class: 'label-light' do
            Project description
            %span.light (optional)
          = f.text_area :description, placeholder: 'Description format',  class: "form-control", rows: 3, maxlength: 250

        .form-group.project-visibility-level-holder
          = f.label :visibility_level, class: 'label-light' do
            Visibility Level
98
            = link_to icon('question-circle'), help_page_path("public_access/public_access"), aria: { label: 'Documentation for Visibility Level' }
B
blackst0ne 已提交
99
          = render 'shared/visibility_level', f: f, visibility_level: visibility_level.to_i, can_change_visibility_level: true, form_model: @project, with_label: false
100

D
Dmitriy Zaporozhets 已提交
101
        = f.submit 'Create project', class: "btn btn-create project-submit", tabindex: 4
102
        = link_to 'Cancel', dashboard_projects_path, class: 'btn btn-cancel'
103

104
.save-project-loader.hide
105
  .center
106
    %h2
S
Sullivan SENECHAL 已提交
107
      %i.fa.fa-spinner.fa-spin
108
      Creating project & repository.
D
Dmitriy Zaporozhets 已提交
109
    %p Please wait a moment, this page will automatically refresh when ready.
V
Valery Sizov 已提交
110

111
:javascript
K
Kushal Pandya 已提交
112
  var importBtnTooltip = "Please enter a valid project name.";
113
  var $importBtnWrapper = $('.import_gitlab_project');
K
Kushal Pandya 已提交
114

115 116 117 118
  $('.how_to_import_link').bind('click', function (e) {
    e.preventDefault();
    var import_modal = $(this).next(".modal").show();
  });
119

120 121 122
  $('.modal-header .close').bind('click', function() {
    $(".modal").hide();
  });
123

124 125 126
  $('.btn_import_gitlab_project').bind('click', function() {
    var _href = $("a.btn_import_gitlab_project").attr("href");
    $(".btn_import_gitlab_project").attr("href", _href + '?namespace_id=' + $("#project_namespace_id").val() + '&path=' + $("#project_path").val());
127
  });
128

129
  $('.btn_import_gitlab_project').attr('disabled', $('#project_path').val().trim().length === 0);
130
  $importBtnWrapper.attr('title', importBtnTooltip);
131

132 133 134 135 136
  $('#new_project').submit(function(){
    var $path = $('#project_path');
    $path.val($path.val().trim());
  });

137
  $('#project_path').keyup(function(){
138
    if($(this).val().trim().length !== 0) {
139
      $('.btn_import_gitlab_project').attr('disabled', false);
140 141
      $importBtnWrapper.attr('title','');
      $importBtnWrapper.removeClass('has-tooltip');
142
    } else {
143
      $('.btn_import_gitlab_project').attr('disabled',true);
144
      $importBtnWrapper.addClass('has-tooltip');
145
    }
J
James Lopez 已提交
146 147
  });

148
  $('#project_import_url').disable();
J
James Lopez 已提交
149
  $('.import_git').click(function( event ) {
150 151
    $projectImportUrl = $('#project_import_url');
    $projectImportUrl.attr('disabled', !$projectImportUrl.attr('disabled'));
152
  });