- page_title "#{@issue.title} (##{@issue.iid})", "Issues"
= render "header_title"

.issue
  .issue-details.issuable-details
    .page-title
      .issue-box{ class: issue_box_class(@issue) }
        - if @issue.closed?
          Closed
        - else
          Open
      %span.issue-id Issue ##{@issue.iid}
      %span.creator
        &middot; created by #{link_to_member(@project, @issue.author, size: 24)}
        &middot;
        = time_ago_with_tooltip(@issue.created_at, placement: 'bottom', html_class: 'issue_created_ago')
        - if @issue.updated_at != @issue.created_at
          %span
            &middot;
            = icon('edit', title: 'edited')
            = time_ago_with_tooltip(@issue.updated_at, placement: 'bottom', html_class: 'issue_edited_ago')

      .pull-right
        - if can?(current_user, :create_issue, @project)
          = link_to new_namespace_project_issue_path(@project.namespace, @project), class: 'btn btn-grouped new-issue-link', title: 'New Issue', id: 'new_issue_link' do
            = icon('plus')
            New Issue
        - if can?(current_user, :update_issue, @issue)
          - if @issue.closed?
            = link_to 'Reopen', issue_path(@issue, issue: {state_event: :reopen}, status_only: true), method: :put, class: 'btn btn-grouped btn-reopen'
          - else
            = link_to 'Close', issue_path(@issue, issue: {state_event: :close}, status_only: true), method: :put, class: 'btn btn-grouped btn-close', title: 'Close Issue'

          = link_to edit_namespace_project_issue_path(@project.namespace, @project, @issue), class: 'btn btn-grouped issuable-edit' do
            = icon('pencil-square-o')
            Edit

    .gray-content-block.middle-block
      %h2.issue-title
        = gfm escape_once(@issue.title)
      %div
        - if @issue.description.present?
          .description{class: can?(current_user, :update_issue, @issue) ? 'js-task-list-container' : ''}
            .wiki
              = preserve do
                = markdown(@issue.description)
            %textarea.hidden.js-task-list-field
              = @issue.description

  .issue-discussion
    = render 'projects/issues/discussion'
