Skip to content

Commit

Permalink
Merge pull request #6452 from ChrisBr/bootstrap/subprojects
Browse files Browse the repository at this point in the history
Migrate Subprojects to Bootstrap
  • Loading branch information
Dany Marcoux committed Dec 6, 2018
2 parents 16b6503 + b1e9b6e commit 215ff80
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/api/app/controllers/webui/project_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def subprojects
parent = @project.parent
@parent_name = parent.name unless parent.nil?
@siblings = @project.siblingprojects
switch_to_webui2
end

def pulse
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/views/webui/project/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
<% end %>
<br/>
</p>
<p><%= submit_tag "Create Project" %></p>
<p><%= submit_tag 'Accept' %></p>
<% end %>
2 changes: 1 addition & 1 deletion src/api/app/views/webui/project/subprojects.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

- if User.current.can_modify?(@project)
%p
= link_to sprite_tag('brick_add', title: 'New subproject') + ' New subproject', '#', id: 'create_subproject_link'
= link_to(sprite_tag('brick_add', title: 'Add New Subproject') + ' Add New Subproject', '#', id: 'create_subproject_link')
.hidden#create-subproject
= render partial: 'form', locals: { project: Project.new, configuration: @configuration, ns: @project.name }

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.modal.fade#add-new-subproject-modal{ tabindex: -1, role: 'dialog', aria: { labelledby: 'add-new-subproject-modal-label', hidden: true } }
.modal-dialog.modal-lg{ role: 'document' }
.modal-content
.modal-header
%h5.modal-title#add-new-subproject-modal-label
Create subproject
.modal-body
= render partial: 'form', locals: { project: Project.new, namespace: project.name, configuration: configuration }
35 changes: 35 additions & 0 deletions src/api/app/views/webui2/webui/project/_form.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
= form_for(project, url: projects_create_path, method: :post) do |form|
.form-group
- if local_assigns.key?(:namespace)
= hidden_field_tag(:ns, namespace)
= form.label(:name, 'Subproject Name:')
.input-group
.input-group-prepend
%span.input-group-text
#{namespace}:
= form.text_field(:name, required: true, class: 'form-control')
- else
= form.label(:name, 'Project Name:', class: 'form-control')
= form.text_field(:name, required: true, class: 'form-control')
.form-group
= form.label(:title, 'Title:')
= form.text_field(:title, class: 'form-control')
.form-group
= form.label(:description, 'Description:')
= form.text_area(:description, rows: 8, class: 'form-control')
- unless configuration['hide_private_options']
.form-group.custom-control.custom-checkbox
= check_box_tag(:access_protection, 1, false, class: 'custom-control-input')
= label_tag(:access_protection, 'Hide the entire project', class: 'custom-control-label')
.form-group.custom-control.custom-checkbox
= check_box_tag(:source_protection, 1, false, class: 'custom-control-input')
= label_tag(:source_protection, 'Deny access to sources of project', class: 'custom-control-label')
.form-group.custom-control.custom-checkbox
= check_box_tag(:disable_publishing, 1, false, class: 'custom-control-input')
= label_tag(:disable_publishing, 'Disable build results publishing', class: 'custom-control-label')

- if @show_restore_message
= hidden_field_tag(:restore_option_provided, true)

.modal-footer
= render partial: 'webui2/shared/dialog_action_buttons'
61 changes: 61 additions & 0 deletions src/api/app/views/webui2/webui/project/subprojects.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
:ruby
@pagetitle = "Subprojects of #{@project}"

.card.mb-3
= render partial: 'tabs', locals: { project: @project }
.card-body
.row
.col-md-12
- if @parentprojects.present?
%h3 Parent projects of #{@project}
%table.responsive.table.table-striped.table-bordered.subproject-table
%thead
%tr
%th Parent Project
%th Title
%tbody
- @parentprojects.each do |project|
%tr
%td.project_name= link_to(word_break(project.name), project_show_path(project))
%td.project_title= word_break(project.title)
.row{ class: ('mt-3' if @parentprojects.present?) }
.col-md-12
%h3.d-md-inline-block Subprojects of #{@project}
- if @subprojects.present?
%table.responsive.table.table-striped.table-bordered.subproject-table
%thead
%tr
%th Subproject
%th Title
%tbody
- @subprojects.each do |project|
%tr
%td.project_name= link_to(word_break(remove_parent_name(project.name, @project.name), 50), project_show_path(project))
%td.project_title= word_break(project.title)
- else
%p
%i This project has no subprojects
- if User.current.can_modify?(@project)
= link_to('#', data: { toggle: 'modal', target: '#add-new-subproject-modal' }, title: 'Add New Subproject', class: 'nav-link') do
%i.fas.fa-plus-circle.text-primary
Add New Subproject

.row.mt-3
.col-md-12
- if @siblings.present?
%h3 Sibling projects of #{@project}
%table.responsive.table.table-striped.table-bordered.subproject-table
%thead
%tr
%th Sibling Project
%th Title
%tbody
- @siblings.each do |project|
%tr
%td.project_name= link_to(word_break(remove_parent_name(project.name, @parent_name), 50), project_show_path(project))
%td.project_title= word_break(project.title)

= render partial: 'add_new_subproject_modal', locals: { project: @project, configuration: @configuration }

:javascript
initializeDataTable('.subproject-table');
11 changes: 6 additions & 5 deletions src/api/spec/features/webui/projects_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@
click_link('Subprojects')

expect(page).to have_text('This project has no subprojects')
click_link('create_subproject_link')
click_link('Add New Subproject')
fill_in 'project_name', with: 'coolstuff'
click_button 'Create Project'
click_button('Accept')
expect(page).to have_content("Project '#{user.home_project_name}:coolstuff' was created successfully")

expect(page.current_path).to match(project_show_path(project: "#{user.home_project_name}:coolstuff"))
Expand All @@ -130,10 +130,11 @@
login user
visit project_subprojects_path(project: user.home_project)

click_link('create_subproject_link')
click_link('Add New Subproject')
fill_in 'project_name', with: 'coolstuff'
check('disable_publishing')
click_button('Create Project')
# Check the checkbox by clicking on its label (side-effect from using custom Bootstrap checkbox)
check('disable_publishing', allow_label_click: true)
click_button('Accept')
click_link('Repositories')

expect(page).to have_selector('.current_flag_state.icons-publish_disable_blue')
Expand Down

0 comments on commit 215ff80

Please sign in to comment.