<?xml version="1.0" encoding="utf-8"?>
<odoo>
  <data>
    <template id="runbot.branch">
      <t t-call='runbot.layout'>
        <div class="container-fluid">
          <div class="row">
            <div class='col-md-12'>
              <div class="navbar navbar-default">
                <h3>
                  <span class="text-muted"><t t-out="branch.remote_id.short_name"/>:</span><t t-out="branch.name"/> <i t-if="not branch.alive" title="deleted/closed" class="fa fa-ban text-danger"/>
                  <div class="btn-group" role="group">
                    <a t-att-href="branch.branch_url" class="btn btn-sm text-start" title="View Branch on Github"><i class="fa fa-github"/></a>
                    <a groups="runbot.group_runbot_admin" class="btn btn-sm fa fa-list text-start"
                      t-attf-href="/odoo/runbot.branch/{{branch.id}}?menu_id={{env['ir.model.data']._xmlid_to_res_id('runbot.runbot_menu_root')}}" target="_blank" title="View Branch in Backend"/>
                  </div>
                </h3>
              </div>
              <table class="table table-condensed table-responsive table-stripped">
                <tr>
                  <td>Remote:</td>
                  <td t-out="branch.remote_id.name"></td>
                </tr>
                <tr>
                  <td>Head:</td>
                  <td t-out="branch.head_name"></td>
                </tr>
                <tr>
                  <td>Bundle:</td>
                  <td>
                    <small>
                      <div class="btn-toolbar mb-1" role="toolbar">
                        <div class="btn-group btn-group-ssm w-100" role="group">
                            <a t-attf-href="/runbot/bundle/{{branch.bundle_id.id}}" t-out="branch.bundle_id.name" class="btn btn-default text-start" title="View Bundle Details"/>
                        </div>
                    </div>
                    </small>
                  </td>
                </tr>
                <t t-if="branch.is_pr">
                  <tr t-if="pr_branch">
                    <td>Pull Head Name</td>
                    <td><a t-attf-href="/runbot/branch/{{pr_branch.id}}" t-out="branch.pull_head_name" title="View PR Details"/></td>
                  </tr>
                  <tr>
                    <td>Target Branch</td>
                    <td t-out="branch.target_branch_name"></td>
                  </tr>
                  <tr>
                    <td>Pr title</td>
                    <td t-out="branch.pr_title"/>
                  </tr>
                </t>
                <t t-elif="branch_pr">
                  <tr>
                    <td>Pull Request:</td>
                    <td><a t-attf-href="/runbot/branch/{{branch_pr.id}}" t-out="branch_pr.name" title="View Branch Details"/></td>
                  </tr>
                </t>
              </table>
                <table t-if="branch.reflog_ids" class="table table-condensed table-stripped" style="table-layout: initial;">
                  <thead>
                      <tr>
                          <th>Ref Date</th>
                          <th>SHA</th>
                          <th>Commit Date</th>
                          <th>Author</th>
                          <th>Subject</th>
                      </tr>
                  </thead>
                  <tr t-foreach='branch.reflog_ids' t-as='reflog'>
                    <td t-out="reflog.date"/>
                    <td><a t-attf-href="/runbot/commit/{{reflog.commit_id.id}}" t-out="reflog.commit_id.name"/></td>
                    <td t-out="reflog.commit_id.date"/>
                    <td t-out="reflog.commit_id.author"/>
                    <td t-out="reflog.commit_id.subject"/>
                  </tr>
                </table>
                <h4 t-else="">No Reflogs Found</h4>
            </div>
          </div>
        </div>
      </t>
    </template>
  </data>
</odoo>
