Class: LabelPresenter

Inherits:
Gitlab::View::Presenter::Delegated show all
Defined in:
app/presenters/label_presenter.rb

Instance Attribute Summary

Attributes included from Gitlab::View::Presenter::Base

#subject

Instance Method Summary collapse

Methods inherited from Gitlab::View::Presenter::Delegated

#initialize

Methods included from Gitlab::View::Presenter::Base

#can?, #declarative_policy_delegate, #is_a?, #present, #url_builder, #web_path, #web_url

Methods included from Gitlab::Allowable

#can?

Methods included from Gitlab::Routing

add_helpers, includes_helpers, redirect_legacy_paths, url_helpers

Constructor Details

This class inherits a constructor from Gitlab::View::Presenter::Delegated

Instance Method Details

#can_subscribe_to_label_in_different_levels?Boolean

Returns:

  • (Boolean)

34
35
36
# File 'app/presenters/label_presenter.rb', line 34

def can_subscribe_to_label_in_different_levels?
  issuable_subject.is_a?(Project) && label.is_a?(GroupLabel)
end

#destroy_pathObject


13
14
15
16
17
18
# File 'app/presenters/label_presenter.rb', line 13

def destroy_path
  case label
  when GroupLabel then group_label_path(label.group, label)
  when ProjectLabel then project_label_path(label.project, label)
  end
end

#edit_pathObject


6
7
8
9
10
11
# File 'app/presenters/label_presenter.rb', line 6

def edit_path
  case label
  when GroupLabel then edit_group_label_path(label.group, label)
  when ProjectLabel then edit_project_label_path(label.project, label)
  end
end

#filter_path(type: :issue) ⇒ Object


20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/presenters/label_presenter.rb', line 20

def filter_path(type: :issue)
  case context_subject
  when Group
    send("#{type.to_s.pluralize}_group_path", # rubocop:disable GitlabSecurity/PublicSend
                context_subject,
                label_name: [label.name])
  when Project
    send("namespace_project_#{type.to_s.pluralize}_path", # rubocop:disable GitlabSecurity/PublicSend
                context_subject.namespace,
                context_subject,
                label_name: [label.name])
  end
end

#project_label?Boolean

Returns:

  • (Boolean)

38
39
40
# File 'app/presenters/label_presenter.rb', line 38

def project_label?
  label.is_a?(ProjectLabel)
end

#subject_nameObject


42
43
44
# File 'app/presenters/label_presenter.rb', line 42

def subject_name
  label.subject.name
end