summaryrefslogtreecommitdiff
path: root/app/views/shared/issuable/_sidebar.html.haml
blob: 2e0d6a129fb2539e61cbc53556ea51b7c62055fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
- todo = issuable_todo(issuable)
- content_for :page_specific_javascripts do
  = page_specific_javascript_bundle_tag('common_vue')
  = page_specific_javascript_bundle_tag('issuable')

%aside.right-sidebar.js-right-sidebar{ data: { "offset-top" => "102", "spy" => "affix" }, class: sidebar_gutter_collapsed_class, 'aria-live' => 'polite' }
  .issuable-sidebar
    - can_edit_issuable = can?(current_user, :"admin_#{issuable.to_ability_name}", @project)
    .block.issuable-sidebar-header
      - if current_user
        %span.issuable-header-text.hide-collapsed.pull-left
          Todo
      %a.gutter-toggle.pull-right.js-sidebar-toggle{ role: "button", href: "#", "aria-label" => "Toggle sidebar" }
        = sidebar_gutter_toggle_icon
      - if current_user
        = render "shared/issuable/sidebar_todo", todo: todo, issuable: issuable

    = form_for [@project.namespace.becomes(Namespace), @project, issuable], remote: true, format: :json, html: { class: 'issuable-context-form inline-update js-issuable-update' } do |f|
      - if current_user
        .block.todo.hide-expanded
          = render "shared/issuable/sidebar_todo", todo: todo, issuable: issuable, is_collapsed: true
      .block.assignee
        .sidebar-collapsed-icon.sidebar-collapsed-user{ data: { toggle: "tooltip", placement: "left", container: "body" }, title: (issuable.assignee.name if issuable.assignee) }
          - if issuable.assignee
            = link_to_member(@project, issuable.assignee, size: 24)
          - else
            = icon('user', 'aria-hidden': 'true')
        .title.hide-collapsed
          Assignee
          = icon('spinner spin', class: 'hidden block-loading', 'aria-hidden': 'true')
          - if can_edit_issuable
            = link_to 'Edit', '#', class: 'edit-link pull-right'
        .value.hide-collapsed
          - if issuable.assignee
            = link_to_member(@project, issuable.assignee, size: 32, extra_class: 'bold') do
              - if issuable.instance_of?(MergeRequest) && !issuable.can_be_merged_by?(issuable.assignee)
                %span.pull-right.cannot-be-merged{ data: { toggle: 'tooltip', placement: 'left' }, title: 'Not allowed to merge' }
                  = icon('exclamation-triangle', 'aria-hidden': 'true')
              %span.username
                = issuable.assignee.to_reference
          - else
            %span.assign-yourself.no-value
              No assignee
              - if can_edit_issuable
                \-
                %a.js-assign-yourself{ href: '#' }
                  assign yourself

        .selectbox.hide-collapsed
          = f.hidden_field 'assignee_id', value: issuable.assignee_id, id: 'issue_assignee_id'
          = dropdown_tag('Select assignee', options: { toggle_class: 'js-user-search js-author-search', title: 'Assign to', filter: true, dropdown_class: 'dropdown-menu-user dropdown-menu-selectable dropdown-menu-author', placeholder: 'Search users', data: { first_user: (current_user.username if current_user), current_user: true, project_id: (@project.id if @project), author_id: issuable.author_id, field_name: "#{issuable.to_ability_name}[assignee_id]", issue_update: issuable_json_path(issuable), ability_name: issuable.to_ability_name, null_user: true } })

      .block.milestone
        .sidebar-collapsed-icon
          = icon('clock-o', 'aria-hidden': 'true')
          %span
            - if issuable.milestone
              %span.has-tooltip{ title: milestone_remaining_days(issuable.milestone), data: { container: 'body', html: 1, placement: 'left' } }
                = issuable.milestone.title
            - else
              None
        .title.hide-collapsed
          Milestone
          = icon('spinner spin', class: 'hidden block-loading', 'aria-hidden': 'true')
          - if can_edit_issuable
            = link_to 'Edit', '#', class: 'edit-link pull-right'
        .value.hide-collapsed
          - if issuable.milestone
            = link_to issuable.milestone.title, namespace_project_milestone_path(@project.namespace, @project, issuable.milestone), class: "bold has-tooltip", title: milestone_remaining_days(issuable.milestone), data: { container: "body", html: 1 }
          - else
            %span.no-value None

        .selectbox.hide-collapsed
          = f.hidden_field 'milestone_id', value: issuable.milestone_id, id: nil
          = dropdown_tag('Milestone', options: { title: 'Assign milestone', toggle_class: 'js-milestone-select js-extra-options', filter: true, dropdown_class: 'dropdown-menu-selectable', placeholder: 'Search milestones', data: { show_no: true, field_name: "#{issuable.to_ability_name}[milestone_id]", project_id: @project.id, issuable_id: issuable.id, milestones: namespace_project_milestones_path(@project.namespace, @project, :json), ability_name: issuable.to_ability_name, issue_update: issuable_json_path(issuable), use_id: true }})
      - if issuable.has_attribute?(:time_estimate)
        #issuable-time-tracker.block
          %issuable-time-tracker{ ':time_estimate' => 'issuable.time_estimate', ':time_spent' => 'issuable.total_time_spent', ':human_time_estimate' => 'issuable.human_time_estimate', ':human_time_spent' => 'issuable.human_total_time_spent', 'docs-url' => help_page_path('workflow/time_tracking.md') }
            // Fallback while content is loading
            .title.hide-collapsed
              Time tracking
              = icon('spinner spin', 'aria-hidden': 'true')
      - if issuable.has_attribute?(:due_date)
        .block.due_date
          .sidebar-collapsed-icon
            = icon('calendar', 'aria-hidden': 'true')
            %span.js-due-date-sidebar-value
              = issuable.due_date.try(:to_s, :medium) || 'None'
          .title.hide-collapsed
            Due date
            = icon('spinner spin', class: 'hidden block-loading', 'aria-hidden': 'true')
            - if can?(current_user, :"admin_#{issuable.to_ability_name}", @project)
              = link_to 'Edit', '#', class: 'edit-link pull-right'
          .value.hide-collapsed
            %span.value-content
              - if issuable.due_date
                %span.bold= issuable.due_date.to_s(:medium)
              - else
                %span.no-value No due date
            - if can?(current_user, :"admin_#{issuable.to_ability_name}", @project)
              %span.no-value.js-remove-due-date-holder{ class: ("hidden" if issuable.due_date.nil?) }
                \-
                %a.js-remove-due-date{ href: "#", role: "button" }
                  remove due date
          - if can?(current_user, :"admin_#{issuable.to_ability_name}", @project)
            .selectbox.hide-collapsed
              = f.hidden_field :due_date, value: issuable.due_date.try(:strftime, 'yy-mm-dd')
              .dropdown
                %button.dropdown-menu-toggle.js-due-date-select{ type: 'button', data: { toggle: 'dropdown', field_name: "#{issuable.to_ability_name}[due_date]", ability_name: issuable.to_ability_name, issue_update: issuable_json_path(issuable) } }
                  %span.dropdown-toggle-text Due date
                  = icon('chevron-down', 'aria-hidden': 'true')
                .dropdown-menu.dropdown-menu-due-date
                  = dropdown_title('Due date')
                  = dropdown_content do
                    .js-due-date-calendar

      - if @labels && @labels.any?
        - selected_labels = issuable.labels
        .block.labels
          .sidebar-collapsed-icon.js-sidebar-labels-tooltip{ title: issuable_labels_tooltip(issuable.labels_array), data: { placement: "left", container: "body" } }
            = icon('tags', 'aria-hidden': 'true')
            %span
              = selected_labels.size
          .title.hide-collapsed
            Labels
            = icon('spinner spin', class: 'hidden block-loading', 'aria-hidden': 'true')
            - if can_edit_issuable
              = link_to 'Edit', '#', class: 'edit-link pull-right'
          .value.issuable-show-labels.hide-collapsed{ class: ("has-labels" if selected_labels.any?) }
            - if selected_labels.any?
              - selected_labels.each do |label|
                = link_to_label(label, subject: issuable.project, type: issuable.to_ability_name)
            - else
              %span.no-value None
          .selectbox.hide-collapsed
            - selected_labels.each do |label|
              = hidden_field_tag "#{issuable.to_ability_name}[label_names][]", label.id, id: nil
            .dropdown
              %button.dropdown-menu-toggle.js-label-select.js-multiselect.js-label-sidebar-dropdown{ type: "button", data: {toggle: "dropdown", default_label: "Labels", field_name: "#{issuable.to_ability_name}[label_names][]", ability_name: issuable.to_ability_name, show_no: "true", show_any: "true", namespace_path: @project.try(:namespace).try(:path), project_path: @project.try(:path), issue_update: issuable_json_path(issuable), labels: (namespace_project_labels_path(@project.namespace, @project, :json) if @project) } }
                %span.dropdown-toggle-text{ class: ("is-default" if selected_labels.empty?) }
                  = multi_label_name(selected_labels, "Labels")
                = icon('chevron-down', 'aria-hidden': 'true')
              .dropdown-menu.dropdown-select.dropdown-menu-paging.dropdown-menu-labels.dropdown-menu-selectable
                = render partial: "shared/issuable/label_page_default"
                - if can? current_user, :admin_label, @project and @project
                  = render partial: "shared/issuable/label_page_create"

      = render "shared/issuable/participants", participants: issuable.participants(current_user)
      - if current_user
        - subscribed = issuable.subscribed?(current_user, @project)
        .block.light.subscription{ data: { url: toggle_subscription_path(issuable) } }
          .sidebar-collapsed-icon
            = icon('rss', 'aria-hidden': 'true')
          %span.issuable-header-text.hide-collapsed.pull-left
            Notifications
          - subscribtion_status = subscribed ? 'subscribed' : 'unsubscribed'
          %button.btn.btn-default.pull-right.js-subscribe-button.issuable-subscribe-button.hide-collapsed{ type: "button" }
            %span= subscribed ? 'Unsubscribe' : 'Subscribe'

      - project_ref = cross_project_reference(@project, issuable)
      .block.project-reference
        .sidebar-collapsed-icon.dont-change-state
          = clipboard_button(text: project_ref, title: "Copy reference to clipboard", placement: "left")
        .cross-project-reference.hide-collapsed
          %span
            Reference:
            %cite{ title: project_ref }
              = project_ref
          = clipboard_button(text: project_ref, title: "Copy reference to clipboard", placement: "left")

    :javascript
      gl.IssuableResource = new gl.SubbableResource('#{issuable_json_path(issuable)}');
      new gl.IssuableTimeTracking("#{escape_javascript(serialize_issuable(issuable))}");
      new MilestoneSelect('{"full_path":"#{@project.full_path}"}');
      new LabelsSelect();
      new IssuableContext('#{escape_javascript(current_user.to_json(only: [:username, :id, :name]))}');
      gl.Subscription.bindAll('.subscription');
      new gl.DueDateSelectors();
      window.sidebar = new Sidebar();