summaryrefslogtreecommitdiff
path: root/app/views/projects/new.html.haml
blob: d129da943f8519c0f49267541b553ba732d7e566 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
- page_title    'New Project'
- header_title  "Projects", dashboard_projects_path
- visibility_level = params.dig(:project, :visibility_level) || default_project_visibility

.project-edit-container
  .project-edit-errors
    = render 'projects/errors'
  .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|
        .row
          .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
                  = f.select :namespace_id, namespaces_options(namespace_id_from(params) || :current_user, display_path: true), {}, {class: 'select2 js-select-namespace', tabindex: 1}

                - else
                  .input-group-addon.static-namespace
                    #{root_url}#{current_user.username}/
                  = f.hidden_field :namespace_id, value: current_user.namespace_id
          .form-group.col-xs-12.col-sm-6.project-path
            = f.label :namespace_id, class: 'label-light' do
              %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?
                    = link_to new_import_github_path, class: 'btn import_github' do
                      = icon('github', text: 'GitHub')
                %div
                  - if bitbucket_import_enabled?
                    = link_to status_import_bitbucket_path, class: "btn import_bitbucket #{'how_to_import_link' unless bitbucket_import_configured?}" do
                      = icon('bitbucket', text: 'Bitbucket')
                    - unless bitbucket_import_configured?
                      = render 'bitbucket_import_modal'
                %div
                  - if gitlab_import_enabled?
                    = link_to status_import_gitlab_path, class: "btn import_gitlab #{'how_to_import_link' unless gitlab_import_configured?}" do
                      = icon('gitlab', text: 'GitLab.com')
                    - unless gitlab_import_configured?
                      = render 'gitlab_import_modal'
                %div
                  - if google_code_import_enabled?
                    = link_to new_import_google_code_path, class: 'btn import_google_code' do
                      = icon('google', text: 'Google Code')
                %div
                  - if fogbugz_import_enabled?
                    = link_to new_import_fogbugz_path, class: 'btn import_fogbugz' do
                      = icon('bug', text: 'Fogbugz')
                %div
                  - if gitea_import_enabled?
                    = link_to new_import_gitea_url, class: 'btn import_gitea' do
                      = custom_icon('go_logo')
                      Gitea
                %div
                  - if git_import_enabled?
                    = link_to "#", class: 'btn js-toggle-button import_git' do
                      = icon('git', text: 'Repo by URL')
                .import_gitlab_project
                  - if gitlab_project_import_enabled?
                    = link_to new_import_gitlab_project_path, class: 'btn btn_import_gitlab_project project-submit' do
                      = icon('gitlab', text: 'GitLab export')

            .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
            = link_to icon('question-circle'), help_page_path("public_access/public_access")
          = render 'shared/visibility_level', f: f, visibility_level: visibility_level.to_i, can_change_visibility_level: true, form_model: @project, with_label: false

        = f.submit 'Create project', class: "btn btn-create project-submit", tabindex: 4
        = link_to 'Cancel', dashboard_projects_path, class: 'btn btn-cancel'

.save-project-loader.hide
  .center
    %h2
      %i.fa.fa-spinner.fa-spin
      Creating project & repository.
    %p Please wait a moment, this page will automatically refresh when ready.

:javascript
  $('.how_to_import_link').bind('click', function (e) {
    e.preventDefault();
    var import_modal = $(this).next(".modal").show();
  });

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

  $('.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());
  });

  $('.btn_import_gitlab_project').attr('disabled',true)
  $('.import_gitlab_project').attr('title', 'Project path and name required.');

  $('.import_gitlab_project').click(function( event ) {
    if($('.btn_import_gitlab_project').attr('disabled')) {
      event.preventDefault();
      new Flash("Please enter path and name for the project to be imported to.");
    }
  });

  $('#new_project').submit(function(){
    var $path = $('#project_path');
    $path.val($path.val().trim());
  });

  $('#project_path').keyup(function(){
    if($(this).val().length !=0) {
      $('.btn_import_gitlab_project').attr('disabled', false);
      $('.import_gitlab_project').attr('title','');
      $(".flash-container").html("")
    } else {
      $('.btn_import_gitlab_project').attr('disabled',true);
      $('.import_gitlab_project').attr('title', 'Project path and name required.');
    }
  });

  $('.import_git').click(function( event ) {
    $projectImportUrl = $('#project_import_url')
    $projectImportUrl.attr('disabled', !$projectImportUrl.attr('disabled'))
  });