_sidebar.html.haml 12.6 KB
Newer Older
Phil Hughes's avatar
Phil Hughes committed
1
- todo = issuable_todo(issuable)
2
- content_for :page_specific_javascripts do
3
  = page_specific_javascript_bundle_tag('common_vue')
4
  = page_specific_javascript_bundle_tag('sidebar')
5

6
%aside.right-sidebar.js-right-sidebar{ data: { "offset-top" => "102", "spy" => "affix" }, class: sidebar_gutter_collapsed_class, 'aria-live' => 'polite' }
7
  .issuable-sidebar{ data: { endpoint: "#{issuable_json_path(issuable)}" } }
8
    - can_edit_issuable = can?(current_user, :"admin_#{issuable.to_ability_name}", @project)
Phil Hughes's avatar
Phil Hughes committed
9
    .block.issuable-sidebar-header
10 11 12
      - if current_user
        %span.issuable-header-text.hide-collapsed.pull-left
          Todo
Filipa Lacerda's avatar
Filipa Lacerda committed
13
      %a.gutter-toggle.pull-right.js-sidebar-toggle{ role: "button", href: "#", "aria-label" => "Toggle sidebar" }
Phil Hughes's avatar
Phil Hughes committed
14
        = sidebar_gutter_toggle_icon
15
      - if current_user
Phil Hughes's avatar
Phil Hughes committed
16
        = render "shared/issuable/sidebar_todo", todo: todo, issuable: issuable
17

18
    = form_for [@project.namespace.becomes(Namespace), @project, issuable], remote: true, format: :json, html: { class: 'issuable-context-form inline-update js-issuable-update' } do |f|
19
      - if current_user
Phil Hughes's avatar
Phil Hughes committed
20 21
        .block.todo.hide-expanded
          = render "shared/issuable/sidebar_todo", todo: todo, issuable: issuable, is_collapsed: true
22
      .block.assignee
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
        - if issuable.instance_of?(Issue)
          #js-vue-sidebar-assignees{ data: { field: "#{issuable.to_ability_name}[assignee_ids]" } }
        - else
          .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
51

52
        .selectbox.hide-collapsed
53
<<<<<<< HEAD
54
          = f.hidden_field 'assignee_id', value: issuable.assignee_id, id: 'issue_assignee_id'
55
          = 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, null_user_default: true, selected: issuable.assignee_id } })
56 57 58 59
=======
          - issuable.assignees.each do |assignee|
            = hidden_field_tag "#{issuable.to_ability_name}[assignee_ids][]", assignee.id, id: nil
>>>>>>> b0a2435... Merge branch 'multiple_assignees_review_upstream' into ee_master
60

61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
          - 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 } }

          - if issuable.instance_of?(Issue)
            - if issuable.assignees.length == 0
              = hidden_field_tag "#{issuable.to_ability_name}[assignee_ids][]", 0, id: nil
            - title = 'Select assignee(s)'
            - options[:toggle_class] += ' js-multiselect js-save-user-data'
            - options[:data][:field_name] = "#{issuable.to_ability_name}[assignee_ids][]"
            - options[:data][:multi_select] = true
            - options[:data]['dropdown-title'] = title
            - options[:data]['dropdown-header'] = 'Assignee(s)'
          - else
            - title = 'Select assignee'

          = dropdown_tag(title, options: options)
76
      .block.milestone
Jacob Schatz's avatar
Jacob Schatz committed
77
        .sidebar-collapsed-icon
Filipa Lacerda's avatar
Filipa Lacerda committed
78
          = icon('clock-o', 'aria-hidden': 'true')
79 80
          %span
            - if issuable.milestone
81
              %span.has-tooltip{ title: milestone_remaining_days(issuable.milestone), data: { container: 'body', html: 1, placement: 'left' } }
82
                = issuable.milestone.title
83
            - else
Rémy Coutable's avatar
Rémy Coutable committed
84
              None
85
        .title.hide-collapsed
Phil Hughes's avatar
Phil Hughes committed
86
          Milestone
87
          = icon('spinner spin', class: 'hidden block-loading', 'aria-hidden': 'true')
88
          - if can_edit_issuable
Phil Hughes's avatar
Phil Hughes committed
89
            = link_to 'Edit', '#', class: 'edit-link pull-right'
90
        .value.hide-collapsed
91
          - if issuable.milestone
92
            = 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 }
93
          - else
94
            %span.no-value None
95

96
        .selectbox.hide-collapsed
97
          = f.hidden_field 'milestone_id', value: issuable.milestone_id, id: nil
Jacob Schatz's avatar
Jacob Schatz committed
98
          = 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 }})
99 100
      - if issuable.has_attribute?(:time_estimate)
        #issuable-time-tracker.block
101 102 103 104
          // Fallback while content is loading
          .title.hide-collapsed
            Time tracking
            = icon('spinner spin', 'aria-hidden': 'true')
Rémy Coutable's avatar
Rémy Coutable committed
105
      - if issuable.has_attribute?(:due_date)
106 107
        .block.due_date
          .sidebar-collapsed-icon
Filipa Lacerda's avatar
Filipa Lacerda committed
108
            = icon('calendar', 'aria-hidden': 'true')
Phil Hughes's avatar
Phil Hughes committed
109
            %span.js-due-date-sidebar-value
Rémy Coutable's avatar
Rémy Coutable committed
110
              = issuable.due_date.try(:to_s, :medium) || 'None'
111
          .title.hide-collapsed
Rémy Coutable's avatar
Rémy Coutable committed
112
            Due date
113
            = icon('spinner spin', class: 'hidden block-loading', 'aria-hidden': 'true')
114
            - if can?(current_user, :"admin_#{issuable.to_ability_name}", @project)
115
              = link_to 'Edit', '#', class: 'edit-link pull-right'
116
          .value.hide-collapsed
Phil Hughes's avatar
Phil Hughes committed
117 118
            %span.value-content
              - if issuable.due_date
119
                %span.bold= issuable.due_date.to_s(:medium)
Phil Hughes's avatar
Phil Hughes committed
120
              - else
121
                %span.no-value No due date
Phil Hughes's avatar
Phil Hughes committed
122
            - if can?(current_user, :"admin_#{issuable.to_ability_name}", @project)
123
              %span.no-value.js-remove-due-date-holder{ class: ("hidden" if issuable.due_date.nil?) }
Phil Hughes's avatar
Phil Hughes committed
124 125 126
                \-
                %a.js-remove-due-date{ href: "#", role: "button" }
                  remove due date
127 128
          - if can?(current_user, :"admin_#{issuable.to_ability_name}", @project)
            .selectbox.hide-collapsed
129
              = f.hidden_field :due_date, value: issuable.due_date.try(:strftime, 'yy-mm-dd')
130
              .dropdown
Rémy Coutable's avatar
Rémy Coutable committed
131 132
                %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
Filipa Lacerda's avatar
Filipa Lacerda committed
133
                  = icon('chevron-down', 'aria-hidden': 'true')
134
                .dropdown-menu.dropdown-menu-due-date
Rémy Coutable's avatar
Rémy Coutable committed
135
                  = dropdown_title('Due date')
136 137
                  = dropdown_content do
                    .js-due-date-calendar
138

139
      - if @labels && @labels.any?
140
        - selected_labels = issuable.labels
Jacob Schatz's avatar
Jacob Schatz committed
141
        .block.labels
142
          .sidebar-collapsed-icon.js-sidebar-labels-tooltip{ title: issuable_labels_tooltip(issuable.labels_array), data: { placement: "left", container: "body" } }
143
            = icon('tags', 'aria-hidden': 'true')
144
            %span
145
              = selected_labels.size
146
          .title.hide-collapsed
Phil Hughes's avatar
Phil Hughes committed
147
            Labels
148
            = icon('spinner spin', class: 'hidden block-loading', 'aria-hidden': 'true')
149
            - if can_edit_issuable
Phil Hughes's avatar
Phil Hughes committed
150
              = link_to 'Edit', '#', class: 'edit-link pull-right'
151
          .value.issuable-show-labels.hide-collapsed{ class: ("has-labels" if selected_labels.any?) }
152 153
            - if selected_labels.any?
              - selected_labels.each do |label|
154
                = link_to_label(label, subject: issuable.project, type: issuable.to_ability_name)
155
            - else
156
              %span.no-value None
157
          .selectbox.hide-collapsed
158
            - selected_labels.each do |label|
159
              = hidden_field_tag "#{issuable.to_ability_name}[label_names][]", label.id, id: nil
160
            .dropdown
161
              %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(:full_path), project_path: @project.try(:path), issue_update: issuable_json_path(issuable), labels: (namespace_project_labels_path(@project.namespace, @project, :json) if @project) } }
162
                %span.dropdown-toggle-text{ class: ("is-default" if selected_labels.empty?) }
163
                  = multi_label_name(selected_labels, "Labels")
Filipa Lacerda's avatar
Filipa Lacerda committed
164
                = icon('chevron-down', 'aria-hidden': 'true')
165
              .dropdown-menu.dropdown-select.dropdown-menu-paging.dropdown-menu-labels.dropdown-menu-selectable
166
                = render partial: "shared/issuable/label_page_default"
167
                - if can? current_user, :admin_label, @project and @project
Alfredo Sumaran's avatar
Alfredo Sumaran committed
168
                  = render partial: "shared/issuable/label_page_create"
169

170 171
      = render "shared/issuable/participants", participants: issuable.participants(current_user)
      - if current_user
172
        - subscribed = issuable.subscribed?(current_user, @project)
173
        .block.light.subscription{ data: { url: toggle_subscription_path(issuable) } }
174
          .sidebar-collapsed-icon
Filipa Lacerda's avatar
Filipa Lacerda committed
175
            = icon('rss', 'aria-hidden': 'true')
176
          %span.issuable-header-text.hide-collapsed.pull-left
Phil Hughes's avatar
Phil Hughes committed
177
            Notifications
178
          - subscribtion_status = subscribed ? 'subscribed' : 'unsubscribed'
179
          %button.btn.btn-default.pull-right.js-subscribe-button.issuable-subscribe-button.hide-collapsed{ type: "button" }
180 181 182
            %span= subscribed ? 'Unsubscribe' : 'Subscribe'

      - project_ref = cross_project_reference(@project, issuable)
Jacob Schatz's avatar
Jacob Schatz committed
183
      .block.project-reference
184
        .sidebar-collapsed-icon.dont-change-state
Douwe Maan's avatar
Douwe Maan committed
185
          = clipboard_button(text: project_ref, title: "Copy reference to clipboard", placement: "left")
186
        .cross-project-reference.hide-collapsed
187 188
          %span
            Reference:
189
            %cite{ title: project_ref }
190
              = project_ref
Douwe Maan's avatar
Douwe Maan committed
191
          = clipboard_button(text: project_ref, title: "Copy reference to clipboard", placement: "left")
192

193
    :javascript
194 195 196 197 198 199 200
      gl.sidebarOptions = {
        endpoint: "#{issuable_json_path(issuable)}",
        editable: #{can_edit_issuable ? true : false},
        currentUser: #{current_user.to_json(only: [:username, :id, :name], methods: :avatar_url)},
        rootPath: "#{root_path}"
      };

201
      new MilestoneSelect('{"full_path":"#{@project.full_path}"}');
202
      new LabelsSelect();
203
      new IssuableContext('#{escape_javascript(current_user.to_json(only: [:username, :id, :name]))}');
204
      gl.Subscription.bindAll('.subscription');
205
      new gl.DueDateSelectors();
206
      window.sidebar = new Sidebar();