{# -*- coding: utf-8 -*-

  This file is part of Invenio.
  Copyright (C) 2016-2023 CERN.

  Invenio is free software; you can redistribute it and/or modify it
  under the terms of the MIT License; see LICENSE file for more details.
#}

{#
  Renders the request details page when publishing a draft and including it in a community.
#}

{% extends "invenio_requests/details/index.html" %}

{% set active_dashboard_menu_item = 'requests' %}
{% set active_community_header_menu_item = 'requests' %}

{%- block request_header %}
  {% if is_user_dashboard %}
    {% set back_button_url = url_for("invenio_app_rdm_users.requests") %}
  {% else %}
    {% set back_button_url = url_for("invenio_communities.communities_requests", pid_value=community.id) %}
  {% endif %}
  {% from "invenio_requests/macros/request_header.html" import inclusion_request_header %}
  {{ inclusion_request_header(
      request=invenio_request,
      record=record,
      accepted=request_is_accepted,
      back_button_url=back_button_url,
      back_button_text=_("Back to requests")
    ) }}
{%- endblock request_header %}

{% block request_timeline %}
  <div
    class="ui container rdm-tab-container fluid rel-pt-2 ml-0-mobile mr-0-mobile"
    id="request-community-submission-tab-container"
  >
    {% if record %}
      <div
        class="ui secondary pointing menu rdm-tab-menu"
        id="request-community-submission-tab"
      >
        <a
          class="active item"
          data-tab="conversation"
          role="tab"
          aria-selected="true"
          aria-controls="conversation-tab-panel"
          id="conversation-tab"
        >
          {{ _("Conversation") }}
        </a>


        <a
          role="tab"
          class="item"
          data-tab="record"
          aria-selected="false"
          aria-controls="record-tab-panel"
          id="record-tab"
        >
          {{ _("Record") }}
        </a>
      </div>
    {% endif %}


    <div
      class="ui bottom attached tab segment active borderless p-0"
      data-tab="conversation"
      role="tabpanel"
      aria-labelledby="conversation-tab"
      id="conversation-tab-panel"
    >
      {{ super() }}
    </div>

    {% if record %}
      <div
        class="ui bottom attached tab segment borderless"
        data-tab="record"
        role="tabpanel"
        aria-labelledby="record-tab"
        id="record-tab-panel"
        hidden="hidden"
      >
        {% set use_theme_basic_template = false %}
        {% set preview_submission_request = true %}
        {% include "invenio_app_rdm/records/detail.html" %}
      </div>
    {% endif %}
  </div>
{% endblock request_timeline %}
