-# haml-lint:disable ViewLength
:ruby
  @pagetitle = "Request #{@bs_request.number}"
  @pagetitle += ": #{@action.name}"
  render partial: 'webui/request/show_actions', locals: { bs_request: @bs_request }

.card
  .card-body.p-0
    = render partial: 'request_header',
        locals: { bs_request: @bs_request, staging_status: @staging_status, action: @action,
                  prev_action: @prev_action, next_action: @next_action, actions: @actions,
                  diff_to_superseded_id: @diff_to_superseded_id, page_name: '',
                  current_notification: @current_notification }
    = render partial: 'request_tabs',
        locals: { bs_request: @bs_request, action: @action, issues: @issues,
                  actions_count: @actions.count, active_tab: @active_tab }
    .container.p-4
      .row
        .col-md-4.order-md-2.order-sm-1.mb-4
          = render partial: 'webui/request/beta_show_tabs/conversation_aside',
                  locals: { bs_request: @bs_request,
                    my_open_reviews: @my_open_reviews,
                    request_reviews: @request_reviews,
                    package_maintainers: @package_maintainers,
                    project_maintainers: @project_maintainers,
                    history_elements: @history_elements }

        .col-md-8.order-md-1.order-sm-2
          .row
            .card.p-4
              #description-text
                - if @bs_request.description.present?
                  %h4.mb-3 Description
                  = render partial: 'webui/shared/collapsible_text', locals: { text: @bs_request.description, extra_css_classes: 'full-width' }
                - else
                  %i No description set
              - if @bs_request.bs_request_actions.exists?(source_package: 'patchinfo')
                = render partial: 'patchinfo_details', locals: { bs_request: @bs_request }
            #comments-list
              .timeline.pb-2.ms-3{ data: { comment_counter: local_assigns[:comment_counter_id] } }
                %h4.list-group.mb-4.ms-3.pt-3 Comments & History
                .timeline-item.mb-3
                  .d-flex.align-items-start
                    %i.fas.fa-lg.fa-code-commit
                    .ms-2
                      %span.small
                        - creator = User.find_by_login(@bs_request.creator) || User.nobody
                        = link_to(realname_with_login(creator), user_path(creator))
                        created this request
                        = link_to('#request-creation', title: I18n.l(@bs_request.created_at.utc), name: 'request-creation') do
                          = render TimeComponent.new(time: @bs_request.created_at)
                        - if @bs_request.superseding.any?
                          superseding
                          - @bs_request.superseding.each do |superseded_request|
                            = link_to("request ##{superseded_request.number}", request_show_path(superseded_request.number, anchor: 'overview'))

                - @bs_request.superseding.each do |superseding_request|
                  .timeline-item.pb-4
                    = link_to('#collapse-superseding', class: 'd-flex align-items-center',
                        data: { 'bs-toggle': 'collapse' },
                        aria: { expanded: false, controls: 'collapse-superseding' }) do
                      %i.timeline-break.expander>
                      %i.timeline-offset.collapser>

                      %i.fas.fa-fw.fa-chevron-right.expander.me-1{ title: 'Show history' }>
                      %i.fas.fa-fw.fa-chevron-down.collapser.me-1{ title: 'Hide history' }>
                      %span.expander
                        Expand history from superseded request ##{superseding_request.number}
                      %span.collapser
                        Collapse history from superseded request ##{superseding_request.number}
                  .collapse.mb-4#collapse-superseding
                    = render BsRequestActivityTimelineComponent.new(bs_request: superseding_request,
                                                                    history_elements: @history_elements,
                                                                    request_reviews_for_non_staging_projects: @request_reviews,
                                                                    timeline_for_superseeded: true)
                = render BsRequestActivityTimelineComponent.new(bs_request: @bs_request,
                                                                history_elements: @history_elements,
                                                                request_reviews_for_non_staging_projects: @request_reviews)

              - if !policy(@bs_request).revoke_request? && !policy(@bs_request).reopen_request? && !policy(@bs_request).accept_request?
                .comment_new
                  = render partial: 'webui/comment/new', locals: { commentable: @bs_request }
              %hr

              - if @bs_request.accept_at.present?
                .alert.alert-warning.p-2
                  %i.fas.fa-exclamation-triangle
                  %span The current request
                  - if BsRequest::FINAL_REQUEST_STATES.include?(@bs_request.state)
                    %span
                      was
                      %strong auto-accepted
                      at
                      %span{ title: "#{I18n.l @bs_request.accept_at}" }
                      = succeed '.' do
                        = I18n.l @bs_request.accept_at, format: :only_date
                  - elsif @bs_request.accept_at.past?
                    %span
                      will be
                      %strong auto-accepted
                      after all the reviews are submitted.
                  - else
                    will be
                    %strong auto-accepted
                    = render TimeComponent.new(time: @bs_request.accept_at)
              // rendering the chart for a bs_request with a lot of bs_request_actions can cause performance issues on the backend,
              // we need to skip those
              - if User.session && @actions.count <= 300
                .chart_build_results_wrapper{ data: { url: request_chart_build_results_path } }
                :javascript
                  updateChartBuildResults();

              - if policy(@bs_request).handle_request? && @bs_request.can_be_reopened?
                = render partial: 'accordion_reviews', locals: { accepted_reviews: @request_reviews.accepted,
                                                                 pending_reviews: @request_reviews.opened,
                                                                 declined_reviews: @request_reviews.declined }
              = render RequestDecisionComponent.new(bs_request: @bs_request,
                                                    package_maintainers: @package_maintainers,
                                                    show_project_maintainer_hint: @show_project_maintainer_hint)
  = render DeleteConfirmationDialogComponent.new(modal_id: 'delete-comment-modal',
                                                 method: :delete,
                                                 options: { modal_title: 'Delete comment?', remote: true })
  - if CommentLockPolicy.new(User.possibly_nobody, @bs_request).create?
    = render partial: 'webui/shared/locking_dialog', locals: { commentable: @bs_request, entity_type: 'request' }
  - if Flipper.enabled?(:content_moderation, User.possibly_nobody)
    = render partial: 'webui/shared/report_modal'
-# haml-lint:enable ViewLength
