Class: Projects::LabelsController

Inherits:
ApplicationController show all
Includes:
ToggleSubscriptionAction
Defined in:
app/controllers/projects/labels_controller.rb

Instance Method Summary collapse

Methods included from ToggleSubscriptionAction

#toggle_subscription

Methods inherited from ApplicationController

#redirect_back_or_default

Methods included from PageLayoutHelper

#blank_container, #container_class, #fluid_layout, #header_title, #nav, #page_card_attributes, #page_card_meta_tags, #page_description, #page_image, #page_title, #sidebar

Methods included from GitlabRoutingHelper

#activity_project_path, #edit_project_path, #edit_project_url, #issue_path, #issue_url, #merge_request_path, #merge_request_url, #milestone_path, #project_builds_path, #project_commits_path, #project_files_path, #project_path, #project_pipelines_path, #project_snippet_url, #project_url, #runner_path, #runners_path, #toggle_subscription_path

Methods included from Gitlab::GonHelper

#add_gon_variables

Methods included from Gitlab::CurrentSettings

#current_application_settings, #fake_application_settings

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Projects::ApplicationController

Instance Method Details

#createObject


28
29
30
31
32
33
34
35
36
# File 'app/controllers/projects/labels_controller.rb', line 28

def create
  @label = @project.labels.create(label_params)

  if @label.valid?
    redirect_to namespace_project_labels_path(@project.namespace, @project)
  else
    render 'new'
  end
end

#destroyObject


62
63
64
65
66
67
68
69
70
71
72
# File 'app/controllers/projects/labels_controller.rb', line 62

def destroy
  @label.destroy

  respond_to do |format|
    format.html do
      redirect_to(namespace_project_labels_path(@project.namespace, @project),
                  notice: 'Label was removed')
    end
    format.js
  end
end

#editObject


38
39
# File 'app/controllers/projects/labels_controller.rb', line 38

def edit
end

#generateObject


49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/controllers/projects/labels_controller.rb', line 49

def generate
  Gitlab::IssuesLabels.generate(@project)

  if params[:redirect] == 'issues'
    redirect_to namespace_project_issues_path(@project.namespace, @project)
  elsif params[:redirect] == 'merge_requests'
    redirect_to namespace_project_merge_requests_path(@project.namespace,
                                                      @project)
  else
    redirect_to namespace_project_labels_path(@project.namespace, @project)
  end
end

#indexObject


13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/projects/labels_controller.rb', line 13

def index
  @labels = @project.labels.page(params[:page])

  respond_to do |format|
    format.html
    format.json do
      render json: @project.labels
    end
  end
end

#newObject


24
25
26
# File 'app/controllers/projects/labels_controller.rb', line 24

def new
  @label = @project.labels.new
end

#updateObject


41
42
43
44
45
46
47
# File 'app/controllers/projects/labels_controller.rb', line 41

def update
  if @label.update_attributes(label_params)
    redirect_to namespace_project_labels_path(@project.namespace, @project)
  else
    render 'edit'
  end
end