Added labels empty state and priority label empty state
Fixed delete labels not working Review changes
This commit is contained in:
		
							parent
							
								
									09567e93ad
								
							
						
					
					
						commit
						bfbdc62a3f
					
				|  | @ -8,6 +8,7 @@ | |||
|       this.prioritizedLabels = prioritizedLabels || $('.js-prioritized-labels'); | ||||
|       this.otherLabels = otherLabels || $('.js-other-labels'); | ||||
|       this.errorMessage = 'Unable to update label prioritization at this time'; | ||||
|       this.emptyState = document.querySelector('#js-priority-labels-empty-state'); | ||||
|       this.prioritizedLabels.sortable({ | ||||
|         items: 'li', | ||||
|         placeholder: 'list-placeholder', | ||||
|  | @ -29,7 +30,12 @@ | |||
|       const action = $btn.parents('.js-prioritized-labels').length ? 'remove' : 'add'; | ||||
|       const $tooltip = $(`#${$btn.find('.has-tooltip:visible').attr('aria-describedby')}`); | ||||
|       $tooltip.tooltip('destroy'); | ||||
|       return _this.toggleLabelPriority($label, action); | ||||
|       _this.toggleLabelPriority($label, action); | ||||
|       _this.toggleEmptyState($label, $btn, action); | ||||
|     } | ||||
| 
 | ||||
|     toggleEmptyState($label, $btn, action) { | ||||
|       this.emptyState.classList.toggle('hidden', !!this.prioritizedLabels[0].querySelector(':scope > li')); | ||||
|     } | ||||
| 
 | ||||
|     toggleLabelPriority($label, action, persistState) { | ||||
|  |  | |||
|  | @ -278,6 +278,10 @@ | |||
|     display: inline-block; | ||||
|   } | ||||
| 
 | ||||
|   .btn { | ||||
|     margin: $btn-side-margin $btn-side-margin 0 0; | ||||
|   } | ||||
| 
 | ||||
|   @media(max-width: $screen-xs-max) { | ||||
|     margin-top: 50px; | ||||
|     text-align: center; | ||||
|  | @ -286,6 +290,12 @@ | |||
|       width: 100%; | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   @media(min-width: $screen-xs-max) { | ||||
|     &.labels .text-content { | ||||
|       margin-top: 70px; | ||||
|     } | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| .flex-container-block { | ||||
|  |  | |||
|  | @ -71,13 +71,7 @@ class Projects::LabelsController < Projects::ApplicationController | |||
|     @label.destroy | ||||
|     @labels = find_labels | ||||
| 
 | ||||
|     respond_to do |format| | ||||
|       format.html do | ||||
|         redirect_to(namespace_project_labels_path(@project.namespace, @project), | ||||
|                     notice: 'Label was removed') | ||||
|       end | ||||
|       format.js | ||||
|     end | ||||
|     redirect_to(namespace_project_labels_path(@project.namespace, @project), notice: 'Label was removed') | ||||
|   end | ||||
| 
 | ||||
|   def remove_priority | ||||
|  |  | |||
|  | @ -1,2 +0,0 @@ | |||
| - if @labels.empty? | ||||
|   $('.labels').load(document.URL + ' .nothing-here-block').hide().fadeIn(1000) | ||||
|  | @ -3,37 +3,35 @@ | |||
| - hide_class = '' | ||||
| = render "projects/issues/head" | ||||
| 
 | ||||
| %div{ class: container_class } | ||||
|   .top-area.adjust | ||||
|     .nav-text | ||||
|       Labels can be applied to issues and merge requests. Star a label to make it a priority label. Order the prioritized labels to change their relative priority, by dragging. | ||||
| - if @labels.exists? || @prioritized_labels.exists? | ||||
|   %div{ class: container_class } | ||||
|     .top-area.adjust | ||||
|       .nav-text | ||||
|         Labels can be applied to issues and merge requests. Star a label to make it a priority label. Order the prioritized labels to change their relative priority, by dragging. | ||||
| 
 | ||||
|     .nav-controls | ||||
|       .nav-controls | ||||
|         - if can?(current_user, :admin_label, @project) | ||||
|           = link_to new_namespace_project_label_path(@project.namespace, @project), class: "btn btn-new" do | ||||
|             New label | ||||
| 
 | ||||
|     .labels | ||||
|       - if can?(current_user, :admin_label, @project) | ||||
|         = link_to new_namespace_project_label_path(@project.namespace, @project), class: "btn btn-new" do | ||||
|           New label | ||||
|         -# Only show it in the first page | ||||
|         - hide = @available_labels.empty? || (params[:page].present? && params[:page] != '1') | ||||
|         .prioritized-labels{ class: ('hide' if hide) } | ||||
|           %h5 Prioritized Labels | ||||
|           %ul.content-list.manage-labels-list.js-prioritized-labels{ "data-url" => set_priorities_namespace_project_labels_path(@project.namespace, @project) } | ||||
|             #js-priority-labels-empty-state{ class: "#{'hidden' unless @prioritized_labels.empty?}" } | ||||
|               = render 'shared/empty_states/priority_labels' | ||||
|             - if @prioritized_labels.present? | ||||
|               = render partial: 'shared/label', subject: @project, collection: @prioritized_labels, as: :label | ||||
| 
 | ||||
|   .labels | ||||
|     - if can?(current_user, :admin_label, @project) | ||||
|       -# Only show it in the first page | ||||
|       - hide = @available_labels.empty? || (params[:page].present? && params[:page] != '1') | ||||
|       .prioritized-labels{ class: ('hide' if hide) } | ||||
|         %h5 Prioritized Labels | ||||
|         %ul.content-list.manage-labels-list.js-prioritized-labels{ "data-url" => set_priorities_namespace_project_labels_path(@project.namespace, @project) } | ||||
|           %p.empty-message{ class: ('hidden' unless @prioritized_labels.empty?) } No prioritized labels yet | ||||
|           - if @prioritized_labels.present? | ||||
|             = render partial: 'shared/label', subject: @project, collection: @prioritized_labels, as: :label | ||||
| 
 | ||||
|     .other-labels | ||||
|       - if can?(current_user, :admin_label, @project) | ||||
|         %h5{ class: ('hide' if hide) } Other Labels | ||||
|       %ul.content-list.manage-labels-list.js-other-labels | ||||
|         - if @labels.present? | ||||
|           = render partial: 'shared/label', subject: @project, collection: @labels, as: :label | ||||
|         = paginate @labels, theme: 'gitlab' | ||||
|       - if @labels.blank? | ||||
|         .nothing-here-block | ||||
|       - if @labels.present? | ||||
|         .other-labels | ||||
|           - if can?(current_user, :admin_label, @project) | ||||
|             Create a label or #{link_to 'generate a default set of labels', generate_namespace_project_labels_path(@project.namespace, @project), method: :post}. | ||||
|           - else | ||||
|             No labels created | ||||
|             %h5{ class: ('hide' if hide) } Other Labels | ||||
|           %ul.content-list.manage-labels-list.js-other-labels | ||||
|             = render partial: 'shared/label', subject: @project, collection: @labels, as: :label | ||||
|             = paginate @labels, theme: 'gitlab' | ||||
| - else | ||||
|   = render 'shared/empty_states/labels' | ||||
|  |  | |||
|  | @ -36,7 +36,7 @@ | |||
|           %li | ||||
|             = link_to 'Edit', edit_label_path(label) | ||||
|           %li | ||||
|             = link_to 'Delete', destroy_label_path(label), title: 'Delete', method: :delete, remote: true, data: {confirm: 'Remove this label? Are you sure?'} | ||||
|             = link_to 'Delete', destroy_label_path(label), title: 'Delete', method: :delete, data: {confirm: 'Remove this label? Are you sure?'} | ||||
| 
 | ||||
|   .pull-right.hidden-xs.hidden-sm.hidden-md | ||||
|     = link_to_label(label, subject: subject, type: :merge_request, css_class: 'btn btn-transparent btn-action') do | ||||
|  | @ -70,7 +70,7 @@ | |||
|       = link_to edit_label_path(label), title: "Edit", class: 'btn btn-transparent btn-action', data: {toggle: "tooltip"} do | ||||
|         %span.sr-only Edit | ||||
|         = icon('pencil-square-o') | ||||
|       = link_to destroy_label_path(label), title: "Delete", class: 'btn btn-transparent btn-action remove-row', method: :delete, remote: true, data: {confirm: label_deletion_confirm_text(label), toggle: "tooltip"} do | ||||
|       = link_to destroy_label_path(label), title: "Delete", class: 'btn btn-transparent btn-action remove-row', method: :delete, data: {confirm: label_deletion_confirm_text(label), toggle: "tooltip"} do | ||||
|         %span.sr-only Delete | ||||
|         = icon('trash-o') | ||||
| 
 | ||||
|  |  | |||
|  | @ -0,0 +1,11 @@ | |||
| .row.empty-state.labels | ||||
|   .pull-right.col-xs-12.col-sm-6 | ||||
|     .svg-content | ||||
|       = render 'shared/empty_states/icons/labels.svg' | ||||
|   .col-xs-12.col-sm-6 | ||||
|     .text-content | ||||
|       %h4 Labels can be applied to issues and merge requests to categorize them. | ||||
|       %p You can also star label to make it a priority label. | ||||
|       - if can?(current_user, :admin_label, @project) | ||||
|         = link_to 'New label', new_namespace_project_label_path(@project.namespace, @project), class: 'btn btn-new', title: 'New label', id: 'new_label_link' | ||||
|         = link_to 'Generate a default set of labels', generate_namespace_project_labels_path(@project.namespace, @project), method: :post, class: 'btn btn-success btn-inverted', title: 'Generate a default set of labels', id: 'generate_labels_link' | ||||
|  | @ -0,0 +1,3 @@ | |||
| .text-center | ||||
|   = render 'shared/empty_states/icons/priority_labels.svg' | ||||
|   %p Star labels to start sorting by priority | ||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| After Width: | Height: | Size: 5.6 KiB | 
|  | @ -0,0 +1 @@ | |||
| <svg xmlns="http://www.w3.org/2000/svg" width="116" height="68" viewBox="181 0 116 68"><g fill="none" fill-rule="evenodd" transform="translate(182)"><rect width="78" height="34" x="37" y="34" fill="#FAFAFA" rx="3"/><rect width="78" height="34" x="31" y="28" fill="#FFF" stroke="#EEE" stroke-width="4" stroke-linecap="round" rx="3"/><path fill="#FFF" stroke="#FC6D26" stroke-width="3" d="M34 35.8c-.6 0-1.4 0-1.8.4L29 38.8c-1 .7-1.7.4-2-.7l-.6-4c0-.5-.5-1.2-1-1.5L22 30.2c-1-.6-1-1.5 0-2l3.7-2c.5-.2 1-.8 1.2-1.3l1-4.2c.3-1 1-1.3 2-.5l3 3c.3.3 1 .6 1.6.6l4.2-.3c1 0 1.5.7 1 1.7L38 29c-.3.6-.3 1.4 0 2l1.3 3.8c.4 1 0 1.8-1.2 1.6l-4-.6z" stroke-linecap="round"/><path fill="#FDE5D8" d="M51.6 14.3c-.2-.2-.8-.4-1-.3l-2.8.5c-.7 0-1-.4-.8-1l1-2.8V9.5L46.6 7c-.3-.7 0-1.2.8-1h2.7c.3 0 .8-.2 1-.5l2-2c.6-.5 1-.4 1.3.3l.7 2.8c0 .3.4.8.7 1l2.3 1.2c.7.3.7 1 0 1.3l-2.2 1.7-.6 1-.4 3c-.2.6-.7.8-1.3.4l-2-1.7zM5.4 43.2c-.2-.2-.5-.2-.7-.2l-1.8.3c-.6 0-1-.2-.7-.7l.7-1.8V40l-1-1.7c0-.4 0-.7.6-.7h1.8c.3 0 .6 0 .8-.2L6.5 36c.3-.3.7-.2.8.2l.5 2 .5.5 1.6.8c.3.2.3.7 0 1l-1.6 1c-.2 0-.4.4-.4.7l-.4 2c0 .3-.4.5-.8.2l-1.4-1.2zM10.4 9.2C10.2 9 10 9 9.7 9L8 9.3c-.6 0-1-.2-.7-.7L8 6.8V6L7 4.3c0-.4 0-.7.6-.7h1.8c.3 0 .6 0 .8-.2L11.5 2c.3-.3.7-.2.8.2l.5 2 .5.5 1.6.8c.3.2.3.7 0 1l-1.6 1c-.2 0-.4.4-.4.7l-.4 2c0 .3-.4.5-.8.2l-1.4-1.2z"/><rect width="52" height="4" x="43" y="38" fill="#EEE" rx="2"/><rect width="36" height="4" x="43" y="48" fill="#EEE" rx="2"/></g></svg> | ||||
| After Width: | Height: | Size: 1.4 KiB | 
|  | @ -0,0 +1,4 @@ | |||
| --- | ||||
| title: Added labels empty state | ||||
| merge_request: 7443 | ||||
| author:  | ||||
|  | @ -15,17 +15,16 @@ class Spinach::Features::ProjectIssuesLabels < Spinach::FeatureSteps | |||
| 
 | ||||
|   step 'I delete all labels' do | ||||
|     page.within '.labels' do | ||||
|       page.all('.remove-row').each do |remove| | ||||
|         remove.click | ||||
|         sleep 0.05 | ||||
|       page.all('.remove-row').each do | ||||
|         first('.remove-row').click | ||||
|       end | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|   step 'I should see labels help message' do | ||||
|     page.within '.labels' do | ||||
|       expect(page).to have_content 'Create a label or generate a default set '\ | ||||
|                                    'of labels' | ||||
|       expect(page).to have_content 'Generate a default set of labels' | ||||
|       expect(page).to have_content 'New label' | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|  |  | |||
|  | @ -20,7 +20,7 @@ feature 'Prioritize labels', feature: true do | |||
|     scenario 'user can prioritize a group label', js: true do | ||||
|       visit namespace_project_labels_path(project.namespace, project) | ||||
| 
 | ||||
|       expect(page).to have_content('No prioritized labels yet') | ||||
|       expect(page).to have_content('Star labels to start sorting by priority') | ||||
| 
 | ||||
|       page.within('.other-labels') do | ||||
|         all('.js-toggle-priority')[1].click | ||||
|  | @ -29,7 +29,7 @@ feature 'Prioritize labels', feature: true do | |||
|       end | ||||
| 
 | ||||
|       page.within('.prioritized-labels') do | ||||
|         expect(page).not_to have_content('No prioritized labels yet') | ||||
|         expect(page).not_to have_content('Star labels to start sorting by priority') | ||||
|         expect(page).to have_content('feature') | ||||
|       end | ||||
|     end | ||||
|  | @ -55,7 +55,7 @@ feature 'Prioritize labels', feature: true do | |||
|     scenario 'user can prioritize a project label', js: true do | ||||
|       visit namespace_project_labels_path(project.namespace, project) | ||||
| 
 | ||||
|       expect(page).to have_content('No prioritized labels yet') | ||||
|       expect(page).to have_content('Star labels to start sorting by priority') | ||||
| 
 | ||||
|       page.within('.other-labels') do | ||||
|         first('.js-toggle-priority').click | ||||
|  | @ -64,7 +64,7 @@ feature 'Prioritize labels', feature: true do | |||
|       end | ||||
| 
 | ||||
|       page.within('.prioritized-labels') do | ||||
|         expect(page).not_to have_content('No prioritized labels yet') | ||||
|         expect(page).not_to have_content('Star labels to start sorting by priority') | ||||
|         expect(page).to have_content('bug') | ||||
|       end | ||||
|     end | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue