From bd2355191fa45ec04ba7b79b7fcb2b26088abc16 Mon Sep 17 00:00:00 2001 From: Robert Schilling <rschilling@student.tugraz.at> Date: Mon, 1 Sep 2014 11:09:07 +0200 Subject: [PATCH] Show labels help message if last label is deleted --- app/controllers/projects/labels_controller.rb | 2 +- app/views/projects/labels/destroy.js.haml | 2 ++ app/views/projects/labels/index.html.haml | 16 ++++++++-------- features/project/issues/labels.feature | 5 +++++ features/steps/project/labels.rb | 16 ++++++++++++++++ 5 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 app/views/projects/labels/destroy.js.haml diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb index 87d1c942034..6c7bde9c5d5 100644 --- a/app/controllers/projects/labels_controller.rb +++ b/app/controllers/projects/labels_controller.rb @@ -52,7 +52,7 @@ class Projects::LabelsController < Projects::ApplicationController respond_to do |format| format.html { redirect_to project_labels_path(@project), notice: 'Label was removed' } - format.js { render nothing: true } + format.js end end diff --git a/app/views/projects/labels/destroy.js.haml b/app/views/projects/labels/destroy.js.haml new file mode 100644 index 00000000000..1b4c83ab097 --- /dev/null +++ b/app/views/projects/labels/destroy.js.haml @@ -0,0 +1,2 @@ +- if @project.labels.size == 0 + $('.labels').load(document.URL + ' .light-well').hide().fadeIn(1000) diff --git a/app/views/projects/labels/index.html.haml b/app/views/projects/labels/index.html.haml index 075779a9c88..06568278de8 100644 --- a/app/views/projects/labels/index.html.haml +++ b/app/views/projects/labels/index.html.haml @@ -7,11 +7,11 @@ Labels %hr -- if @labels.present? - %ul.bordered-list.manage-labels-list - = render @labels - = paginate @labels, theme: 'gitlab' - -- else - .light-well - .nothing-here-block Create first label or #{link_to 'generate', generate_project_labels_path(@project), method: :post} default set of labels +.labels + - if @labels.present? + %ul.bordered-list.manage-labels-list + = render @labels + = paginate @labels, theme: 'gitlab' + - else + .light-well + .nothing-here-block Create first label or #{link_to 'generate', generate_project_labels_path(@project), method: :post} default set of labels diff --git a/features/project/issues/labels.feature b/features/project/issues/labels.feature index 29cf5307271..77ee5d8a686 100644 --- a/features/project/issues/labels.feature +++ b/features/project/issues/labels.feature @@ -24,6 +24,11 @@ Feature: Project Labels When I remove label 'bug' Then I should not see label 'bug' + @javascript + Scenario: I remove all labels + When I delete all labels + Then I should see labels help message + Scenario: I create a label with invalid color Given I visit project "Shop" new label page When I submit new label with invalid color diff --git a/features/steps/project/labels.rb b/features/steps/project/labels.rb index 8320405e096..6dd4df8a1ad 100644 --- a/features/steps/project/labels.rb +++ b/features/steps/project/labels.rb @@ -25,6 +25,22 @@ class ProjectLabels < Spinach::FeatureSteps end end + step 'I delete all labels' do + within '.labels' do + all('.btn-remove').each do |remove| + remove.click + sleep 0.05 + end + end + end + + step 'I should see labels help message' do + within '.labels' do + page.should have_content 'Create first label or generate default set of '\ + 'labels' + end + end + step 'I submit new label \'support\'' do fill_in 'Title', with: 'support' fill_in 'Background Color', with: '#F95610' -- GitLab