<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
        <template id="runbot.bundle">
            <t t-call='runbot.layout'>
                <div class="container-fluid">
                    <div class="row">
                        <div class='col-md-12'>
                            <div class="navbar navbar-default">
                                <span class="text-center" style="font-size: 18px;">
                                    <t t-out="bundle.name"/>
                                    <i t-if="bundle.sticky" class="fa fa-star" style="color: #f0ad4e" />
                                    <div class="btn-group" role="group">
                                        <a groups="runbot.group_runbot_advanced_user"
                                            t-attf-href="/odoo/runbot.bundle/{{bundle.id}}?menu_id={{env['ir.model.data']._xmlid_to_res_id('runbot.runbot_menu_root')}}" class="btn btn-default" target="_blank" title="View in Backend">
                                          <i class="fa fa-list"/>
                                        </a>
                                        <a groups="runbot.group_runbot_advanced_user" class="btn btn-default" t-attf-href="/runbot/bundle/{{bundle.id}}/force" title="Force A New Batch">
                                            <i class="fa fa-play"/>
                                        </a>
                                        <a t-if="bundle.env.user.has_group('runbot.group_runbot_advanced_user') or (bundle.env.user.has_group('runbot.group_user') and ':' in bundle.name)" class="btn btn-default" t-attf-href="/runbot/bundle/{{bundle.id}}/force?auto_rebase=1" title="Force A New Batch with automatic rebase">
                                            <i class="fa fa-fast-forward"/>
                                        </a>
                                        <a groups="runbot.group_runbot_advanced_user" class="btn btn-default" t-attf-href="/runbot/bundle/{{bundle.id}}/force?use_base_commits=1" title="Force A New Batch using base commits">
                                            <i class="fa fa-fast-backward"/>
                                        </a>
                                        <t t-call="runbot.branch_copy_button">
                                            <t t-set="btn_size" t-value="'btn'"/>
                                        </t>
                                        <t t-call="runbot.bundle_stats_dropdown"/>
                                    </div>
                                </span>
                                <span class="pull-right">
                                    <t t-call="website.pager" />
                                </span>
                            </div>
                            <div>
                                <table class="table table-condensed table-responsive table-stripped">
                                    <tr groups="base.group_user" t-if="not bundle.sticky and not bundle.is_base">
                                        <t t-if="bundle.no_build">
                                            <td class="text-danger">Build disabled</td>
                                            <td>
                                                <a class="btn btn-primary btn-ssm"
                                                   t-attf-href="/runbot/bundle/toggle_no_build/{{bundle.id}}/0">
                                                Enable builds
                                                </a>
                                            </td>
                                        </t>
                                        <t t-else="">
                                            <td>Build enabled</td>
                                            <td>
                                                <a class="btn btn-secondary btn-ssm"
                                                   t-attf-href="/runbot/bundle/toggle_no_build/{{bundle.id}}/1">
                                                Disable builds
                                                </a>
                                            </td>
                                        </t>
                                    </tr>
                                    <tr>
                                        <td>Version</td>
                                        <td>
                                            <t t-out="bundle.version_id.name"/>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>Branches</td>
                                        <td>
                                            <t t-foreach="bundle._branch_groups().items()" t-as="group">
                                                <t t-foreach="group[1]" t-as="branch">
                                                    <small>
                                                        <div class="btn-toolbar mb-1" role="toolbar">
                                                            <div class="btn-group btn-group-ssm" role="group">
                                                                <a t-att-href="branch.branch_url" class="btn btn-default text-start" title="View Branch on Github"><i class="fa fa-github"/></a>
                                                                <a groups="runbot.group_runbot_admin" class="btn btn-default 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"/>
                                                                <a href="#" t-out="branch.remote_id.short_name" class="btn btn-default disabled text-start"/>
                                                                <a t-attf-href="/runbot/branch/{{branch.id}}" class="btn btn-default text-start" title="View Branch Details"><span t-att-class="'' if branch.alive else 'line-through'" t-out="branch.name"/> <i t-if="not branch.alive" title="deleted/closed" class="fa fa-ban text-danger"/></a>
                                                                <t t-if="not any (b.is_pr and b.alive for b in group[1]) and not branch.is_pr">
                                                                    <a t-attf-href="https://{{group[0].main_remote_id.base_url}}/compare/{{bundle.version_id.name}}...{{branch.remote_id.owner}}:{{branch.name}}?expand=1" class="btn btn-default text-start" title="Create pr"><i class="fa fa-code-fork"/> Create pr</a>
                                                                </t>
                                                            </div>
                                                        </div>
                                                    </small>
                                                </t>
                                            </t>
                                        </td>
                                    </tr>

                                    <tr t-if="more">
                                        <td>Project</td>
                                        <td t-out="bundle.project_id.name"/>
                                    </tr>
                                    <tr t-if="more">
                                        <td>New build enabled</td>
                                        <td>
                                            <i t-attf-class="fa fa-{{'times' if bundle.no_build else 'check'}}"/>
                                        </td>
                                    </tr>
                                    <tr t-if="more">
                                        <td>Modules</td>
                                        <td t-out="bundle.modules or '/'"/>
                                    </tr>
                                </table>
                            </div>
                            <div t-foreach="bundle._consistency_warning()" t-as="warning" t-out="warning[1]" t-attf-class="alert alert-{{warning[0]}}"/>
                            <div class="batch_row" t-foreach="batchs" t-as="batch">
                                <t t-call="runbot.batch_tile"/>
                            </div>
                        </div>
                    </div>
                </div>
            </t>
        </template>
    </data>
</odoo>
