_sidebar.html.haml 10.3 KB
Newer Older
P
Phil Hughes 已提交
1
- todo = issuable_todo(issuable)
2
%aside.right-sidebar{ class: sidebar_gutter_collapsed_class }
J
Jacob Schatz 已提交
3
  .issuable-sidebar
4
    - can_edit_issuable = can?(current_user, :"admin_#{issuable.to_ability_name}", @project)
P
Phil Hughes 已提交
5
    .block.issuable-sidebar-header
6 7 8
      - if current_user
        %span.issuable-header-text.hide-collapsed.pull-left
          Todo
9
      %a.gutter-toggle.pull-right.js-sidebar-toggle{ role: "button", href: "#", aria: { label: "Toggle sidebar" } }
P
Phil Hughes 已提交
10
        = sidebar_gutter_toggle_icon
11
      - if current_user
12
        %button.btn.btn-default.issuable-header-btn.pull-right.js-issuable-todo{ type: "button", aria: { label: (todo.nil? ? "Add todo" : "Mark done") }, data: { todo_text: "Add todo", mark_text: "Mark done", issuable_id: issuable.id, issuable_type: issuable.class.name.underscore, url: namespace_project_todos_path(@project.namespace, @project), delete_path: (dashboard_todo_path(todo) if todo) } }
P
Phil Hughes 已提交
13
          %span.js-issuable-todo-text
P
Phil Hughes 已提交
14
            - if todo
15
              Mark done
P
Phil Hughes 已提交
16
            - else
17
              Add todo
18
          = icon('spin spinner', class: 'hidden js-issuable-todo-loading')
19

P
Phil Hughes 已提交
20
    = form_for [@project.namespace.becomes(Namespace), @project, issuable], remote: true, format: :json, html: {class: 'issuable-context-form inline-update js-issuable-update'} do |f|
J
Jacob Schatz 已提交
21
      .block.assignee
22
        .sidebar-collapsed-icon.sidebar-collapsed-user{data: {toggle: "tooltip", placement: "left", container: "body"}, title: (issuable.assignee.name if issuable.assignee)}
J
Jacob Schatz 已提交
23
          - if issuable.assignee
24
            = link_to_member(@project, issuable.assignee, size: 24)
J
Jacob Schatz 已提交
25 26
          - else
            = icon('user')
27
        .title.hide-collapsed
P
Phil Hughes 已提交
28
          Assignee
J
Jacob Schatz 已提交
29
          = icon('spinner spin', class: 'block-loading')
30
          - if can_edit_issuable
P
Phil Hughes 已提交
31
            = link_to 'Edit', '#', class: 'edit-link pull-right'
32
        .value.hide-collapsed
J
Jacob Schatz 已提交
33
          - if issuable.assignee
34
            = link_to_member(@project, issuable.assignee, size: 32, extra_class: 'bold') do
35 36 37
              - 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')
P
Phil Hughes 已提交
38 39
              %span.username
                = issuable.assignee.to_reference
J
Jacob Schatz 已提交
40
          - else
41
            %span.assign-yourself.no-value
42
              No assignee
43
              - if can_edit_issuable
44
                \-
45
                %a.js-assign-yourself{ href: '#' }
46
                  assign yourself
47

48
        .selectbox.hide-collapsed
49
          = f.hidden_field 'assignee_id', value: issuable.assignee_id, id: 'issue_assignee_id'
50
          = 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 } })
51

J
Jacob Schatz 已提交
52
      .block.milestone
J
Jacob Schatz 已提交
53
        .sidebar-collapsed-icon
J
Jacob Schatz 已提交
54
          = icon('clock-o')
J
Jacob Schatz 已提交
55 56
          %span
            - if issuable.milestone
57
              %span.has-tooltip{title: milestone_remaining_days(issuable.milestone), data: {container: 'body', html: 1, placement: 'left'}}
58
                = issuable.milestone.title
J
Jacob Schatz 已提交
59
            - else
R
Rémy Coutable 已提交
60
              None
61
        .title.hide-collapsed
P
Phil Hughes 已提交
62
          Milestone
J
Jacob Schatz 已提交
63
          = icon('spinner spin', class: 'block-loading')
64
          - if can_edit_issuable
P
Phil Hughes 已提交
65
            = link_to 'Edit', '#', class: 'edit-link pull-right'
66
        .value.hide-collapsed
J
Jacob Schatz 已提交
67
          - if issuable.milestone
68
            = 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 }
69
          - else
70
            %span.no-value None
71

72
        .selectbox.hide-collapsed
73
          = f.hidden_field 'milestone_id', value: issuable.milestone_id, id: nil
J
Jacob Schatz 已提交
74
          = 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 }})
75

R
Rémy Coutable 已提交
76
      - if issuable.has_attribute?(:due_date)
77 78 79
        .block.due_date
          .sidebar-collapsed-icon
            = icon('calendar')
P
Phil Hughes 已提交
80
            %span.js-due-date-sidebar-value
R
Rémy Coutable 已提交
81
              = issuable.due_date.try(:to_s, :medium) || 'None'
82
          .title.hide-collapsed
R
Rémy Coutable 已提交
83
            Due date
P
Phil Hughes 已提交
84
            = icon('spinner spin', class: 'block-loading')
85
            - if can?(current_user, :"admin_#{issuable.to_ability_name}", @project)
P
Phil Hughes 已提交
86
              = link_to 'Edit', '#', class: 'edit-link pull-right'
87
          .value.hide-collapsed
P
Phil Hughes 已提交
88 89
            %span.value-content
              - if issuable.due_date
90
                %span.bold= issuable.due_date.to_s(:medium)
P
Phil Hughes 已提交
91
              - else
92
                %span.no-value No due date
P
Phil Hughes 已提交
93
            - if can?(current_user, :"admin_#{issuable.to_ability_name}", @project)
94
              %span.no-value.js-remove-due-date-holder{ class: ("hidden" if issuable.due_date.nil?) }
P
Phil Hughes 已提交
95 96 97
                \-
                %a.js-remove-due-date{ href: "#", role: "button" }
                  remove due date
P
Phil Hughes 已提交
98 99
          - if can?(current_user, :"admin_#{issuable.to_ability_name}", @project)
            .selectbox.hide-collapsed
R
Rémy Coutable 已提交
100
              = f.hidden_field :due_date, value: issuable.due_date
P
Phil Hughes 已提交
101
              .dropdown
R
Rémy Coutable 已提交
102 103 104
                %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')
P
Phil Hughes 已提交
105
                .dropdown-menu.dropdown-menu-due-date
R
Rémy Coutable 已提交
106
                  = dropdown_title('Due date')
P
Phil Hughes 已提交
107 108
                  = dropdown_content do
                    .js-due-date-calendar
109

110
      - if @labels && @labels.any?
111
        - selected_labels = issuable.labels
J
Jacob Schatz 已提交
112
        .block.labels
P
Phil Hughes 已提交
113
          .sidebar-collapsed-icon.js-sidebar-labels-tooltip{ title: issuable_labels_tooltip(issuable.labels_array), data: { placement: "left", container: "body" } }
114
            = icon('tags')
J
Jacob Schatz 已提交
115
            %span
116
              = selected_labels.size
117
          .title.hide-collapsed
P
Phil Hughes 已提交
118
            Labels
J
Jacob Schatz 已提交
119
            = icon('spinner spin', class: 'block-loading')
120
            - if can_edit_issuable
P
Phil Hughes 已提交
121
              = link_to 'Edit', '#', class: 'edit-link pull-right'
122
          .value.issuable-show-labels.hide-collapsed{ class: ("has-labels" if selected_labels.any?) }
123 124
            - if selected_labels.any?
              - selected_labels.each do |label|
125
                = link_to_label(label, type: issuable.to_ability_name)
J
Jacob Schatz 已提交
126
            - else
127
              %span.no-value None
128
          .selectbox.hide-collapsed
129
            - selected_labels.each do |label|
130
              = hidden_field_tag "#{issuable.to_ability_name}[label_names][]", label.id, id: nil
131
            .dropdown
132
              %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)}}
133
                %span.dropdown-toggle-text{ class: ("is-default" if selected_labels.empty?)}
134
                  = multi_label_name(selected_labels, "Labels")
135 136
                = icon('chevron-down')
              .dropdown-menu.dropdown-select.dropdown-menu-paging.dropdown-menu-labels.dropdown-menu-selectable
A
Alfredo Sumaran 已提交
137
                = render partial: "shared/issuable/label_page_default"
138
                - if can? current_user, :admin_label, @project and @project
A
Alfredo Sumaran 已提交
139
                  = render partial: "shared/issuable/label_page_create"
140

J
Jacob Schatz 已提交
141 142
      = render "shared/issuable/participants", participants: issuable.participants(current_user)
      - if current_user
143
        - subscribed = issuable.subscribed?(current_user, @project)
144
        .block.light.subscription{data: {url: toggle_subscription_path(issuable)}}
145 146
          .sidebar-collapsed-icon
            = icon('rss')
147
          .title.hide-collapsed
P
Phil Hughes 已提交
148
            Notifications
J
Jacob Schatz 已提交
149
          - subscribtion_status = subscribed ? 'subscribed' : 'unsubscribed'
150
          %button.btn.btn-block.btn-default.js-subscribe-button.issuable-subscribe-button.hide-collapsed{ type: "button" }
J
Jacob Schatz 已提交
151
            %span= subscribed ? 'Unsubscribe' : 'Subscribe'
152
          .subscription-status.hide-collapsed{data: {status: subscribtion_status}}
J
Jacob Schatz 已提交
153 154 155 156 157 158
            .unsubscribed{class: ( 'hidden' if subscribed )}
              You're not receiving notifications from this thread.
            .subscribed{class: ( 'hidden' unless subscribed )}
              You're receiving notifications because you're subscribed to this thread.

      - project_ref = cross_project_reference(@project, issuable)
J
Jacob Schatz 已提交
159
      .block.project-reference
160
        .sidebar-collapsed-icon.dont-change-state
161
          = clipboard_button(clipboard_text: project_ref)
162
        .cross-project-reference.hide-collapsed
J
Jacob Schatz 已提交
163 164 165 166 167
          %span
            Reference:
            %cite{title: project_ref}
              = project_ref
          = clipboard_button(clipboard_text: project_ref)
168

J
Jacob Schatz 已提交
169
    :javascript
J
Jacob Schatz 已提交
170
      new MilestoneSelect('{"namespace":"#{@project.namespace.path}","path":"#{@project.path}"}');
171
      new LabelsSelect();
172
      new IssuableContext('#{escape_javascript(current_user.to_json(only: [:username, :id, :name]))}');
P
Phil Hughes 已提交
173
      new Subscription('.subscription')
174
      new gl.DueDateSelectors();
175
      sidebar = new Sidebar();