_label.html.haml 4.7 KB
Newer Older
1
- label_css_id = dom_id(label)
2
- status = label_subscription_status(label, @project).inquiry if current_user
3
- subject = local_assigns[:subject]
4
- use_label_priority = local_assigns.fetch(:use_label_priority, false)
L
Luke Bennett 已提交
5
- force_priority = local_assigns.fetch(:force_priority, use_label_priority ? label.priority.present? : false)
6
- toggle_subscription_path = toggle_subscription_label_path(label, @project) if current_user
7 8
- show_label_merge_requests_link = show_label_issuables_link?(label, :merge_requests, project: @project)
- show_label_issues_link = show_label_issuables_link?(label, :issues, project: @project)
9
- tooltip_title = label_status_tooltip(label, status) if status
10

L
Luke Bennett 已提交
11
%li.label-list-item{ id: label_css_id, data: { id: label.id } }
12
  = render "shared/label_row", label: label, subject: subject, force_priority: force_priority
13
  %ul.label-actions-list
L
Luke Bennett 已提交
14
    - if @project
15 16
      %li.inline
        .label-badge.label-badge-gray= label.model_name.human.capitalize
L
Luke Bennett 已提交
17 18 19 20 21 22 23
    - if can?(current_user, :admin_label, @project)
      %li.inline.js-toggle-priority{ data: { url: remove_priority_project_label_path(@project, label),
        dom_id: dom_id(label), type: label.type } }
        %button.label-action.add-priority.btn.btn-transparent.has-tooltip{ title: _('Prioritize'), type: 'button', data: { placement: 'top' }, aria_label: _('Prioritize label') }
          = sprite_icon('star-o')
        %button.label-action.remove-priority.btn.btn-transparent.has-tooltip{ title: _('Remove priority'), type: 'button', data: { placement: 'top' }, aria_label: _('Deprioritize label') }
          = sprite_icon('star')
24
    - if can?(current_user, :admin_label, label)
L
Luke Bennett 已提交
25
      %li.inline
26
        = link_to edit_label_path(label), class: 'btn btn-transparent label-action edit', aria_label: 'Edit label' do
L
Luke Bennett 已提交
27
          = sprite_icon('pencil')
L
Luke Bennett 已提交
28 29
    %li.inline
      .dropdown
L
Luke Bennett 已提交
30
        %button{ type: 'button', class: 'btn btn-transparent js-label-options-dropdown label-action', data: { toggle: 'dropdown' }, aria_label: _('Label actions dropdown') }
L
Luke Bennett 已提交
31
          = sprite_icon('ellipsis_v')
32
        .dropdown-menu.dropdown-open-left
L
Luke Bennett 已提交
33 34 35
          %ul
            - if label.is_a?(ProjectLabel) && label.project.group && can?(current_user, :admin_label, label.project.group)
              %li
L
Luke Bennett 已提交
36
                %button.js-promote-project-label-button.btn.btn-transparent.btn-action{ disabled: true, type: 'button',
L
Luke Bennett 已提交
37 38 39 40 41 42 43 44
                  data: { url: promote_project_label_path(label.project, label),
                          label_title: label.title,
                          label_color: label.color,
                          label_text_color: label.text_color,
                          group_name: label.project.group.name,
                          target: '#promote-label-modal',
                          container: 'body',
                          toggle: 'modal' } }
L
i18n  
Luke Bennett 已提交
45
                  = _('Promote to group label')
46 47 48 49
            - if can?(current_user, :admin_label, label)
              %li
                %span{ data: { toggle: 'modal', target: "#modal-delete-label-#{label.id}" } }
                  %button.text-danger.remove-row{ type: 'button' }= _('Delete')
50
    - if current_user
L
Luke Bennett 已提交
51
      %li.inline.label-subscription
52
        - if can_subscribe_to_label_in_different_levels?(label)
L
Luke Bennett 已提交
53
          %button.js-unsubscribe-button.label-subscribe-button.btn.btn-default{ class: ('hidden' if status.unsubscribed?), data: { url: toggle_subscription_path, toggle: 'tooltip' }, title: tooltip_title }
L
i18n  
Luke Bennett 已提交
54
            %span= _('Unsubscribe')
L
Luke Bennett 已提交
55
          .dropdown.dropdown-group-label{ class: ('hidden' unless status.unsubscribed?) }
L
Luke Bennett 已提交
56 57
            %button.label-subscribe-button.btn.btn-default{ data: { toggle: 'dropdown' } }
              %span
L
i18n  
Luke Bennett 已提交
58
                = _('Subscribe')
L
Luke Bennett 已提交
59
                = sprite_icon('chevron-down')
60
            .dropdown-menu.dropdown-open-left
L
Luke Bennett 已提交
61 62
              %ul
                %li
L
Luke Bennett 已提交
63
                  %button.js-subscribe-button.label-subscribe-button.btn.btn-default{ class: ('hidden' unless status.unsubscribed?), data: { status: status, url: toggle_subscription_project_label_path(@project, label) } }
L
i18n  
Luke Bennett 已提交
64
                    %span= _('Subscribe at project level')
L
Luke Bennett 已提交
65
                %li
L
Luke Bennett 已提交
66
                  %button.js-subscribe-button.js-group-level.label-subscribe-button.btn.btn-default{ class: ('hidden' unless status.unsubscribed?), data: { status: status, url: toggle_subscription_group_label_path(label.group, label) } }
L
i18n  
Luke Bennett 已提交
67
                    %span= _('Subscribe at group level')
68
        - else
L
Luke Bennett 已提交
69
          %button.js-subscribe-button.label-subscribe-button.btn.btn-default{ data: { status: status, url: toggle_subscription_path, toggle: 'tooltip' }, title: tooltip_title }
70
            %span= label_subscription_toggle_button_text(label, @project)
71 72

= render 'shared/delete_label_modal', label: label