From 9d668750698558ce7864c370e34a06c7a710ff00 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 7 May 2013 17:57:29 +0300 Subject: [PATCH] Add generate action to labels controller which allow creation of default labels set for project --- app/controllers/labels_controller.rb | 6 ++++++ app/views/labels/index.html.haml | 7 ++++--- config/routes.rb | 8 +++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/controllers/labels_controller.rb b/app/controllers/labels_controller.rb index 999351e..cb332a4 100644 --- a/app/controllers/labels_controller.rb +++ b/app/controllers/labels_controller.rb @@ -10,6 +10,12 @@ class LabelsController < ProjectResourceController @labels = @project.issues_labels.order('count DESC') end + def generate + Gitlab::Labels.generate(@project) + + redirect_to project_labels_path(@project) + end + protected def module_enabled diff --git a/app/views/labels/index.html.haml b/app/views/labels/index.html.haml index 6eb2c00..895ba43 100644 --- a/app/views/labels/index.html.haml +++ b/app/views/labels/index.html.haml @@ -3,12 +3,13 @@ %h3.page_title Labels %br -%div.ui-box - %ul.well-list.labels-table + +.light-well + %ul.bordered-list.labels-table - @labels.each do |label| = render 'label', label: label - unless @labels.present? %li - %h3.nothing_here_message Nothing to show here + %h3.nothing_here_message Add first label to your issues or #{link_to 'generate', generate_project_labels_path(@project), method: :post} default set of labels diff --git a/config/routes.rb b/config/routes.rb index f8881af..a3258c9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -269,7 +269,13 @@ Gitlab::Application.routes.draw do resources :team, controller: 'team_members', only: [:index] resources :milestones, except: [:destroy] - resources :labels, only: [:index] + + resources :labels, only: [:index] do + collection do + post :generate + end + end + resources :issues, except: [:destroy] do collection do post :bulk_update -- libgit2 0.21.2