<odoo>
  <data>
    <record id="dockerfile_form" model="ir.ui.view">
        <field name="name">runbot.dockerfile.form</field>
        <field name="model">runbot.dockerfile</field>
        <field name="arch" type="xml">
          <form string="Dockerfile">
            <sheet>
              <widget name="web_ribbon" title="Empty" bg_color="bg-warning" invisible="dockerfile != ''"/>
              <widget name="web_ribbon" title="Archived" bg_color="bg-danger" invisible="active"/>
              <group>
                <field name="active" invisible="1"/>
                <field name="name"/>
                <field name="image_tag"/>
                <field name="to_build"/>
                <field name="always_pull"/>
                <field name="version_ids" widget="many2many_tags"/>
                <field name="project_ids" widget="many2many_tags"/>
                <field name="template_id"/>
                <field name="public_visibility"/>
              </group>
              <group>
                <field name="description"/>
              </group>
              <notebook>
                <page string="Layers">
                  <field name="layer_ids">
                    <list default_order="sequence,id">
                      <field name="sequence" widget="handle"/>
                      <field name="rendered" decoration-it="layer_type in ('reference_layer', 'reference_file')" decoration-bg-info="layer_type == 'template' or (layer_type == 'reference_layer' and (packages or values))" decoration-bg-success="layer_type == 'raw'"/>
                      <field name="reference_count" string="#" decoration="True" decoration-bg-danger="referencing_dockerlayer_ids" decoration-bg-warning="reference_count != 0"/>
                      <field name="referencing_dockerlayer_ids" column_invisible="True"/>
                      <field name="layer_type" column_invisible="True"/>
                      <field name="packages" column_invisible="True"/>
                      <field name="values" column_invisible="True"/>
                    </list>
                  </field>
                </page>
                <page string="Dockerfile">
                  <field name="dockerfile"/>
                </page>
                <page string="Template">
                  <field name="arch_base" widget="ace" options="{'mode': 'xml'}" readonly="0"/>
                </page>
                <page string="Views" groups="runbot.group_runbot_admin">
                  <field name="view_ids" widget="one2many">
                    <list>
                      <field name="id"/>
                      <field name="key"/>
                    </list>
                  </field>
                </page>
                <page string="Used in ">
                  <field name="bundle_ids" widget="one2many">
                    <list>
                      <field name="project_id"/>
                      <field name="name"/>
                    </list>
                  </field>
                  <field name="project_ids" widget="one2many">
                    <list>
                      <field name="name"/>
                    </list>
                  </field>
                  <field name="version_ids" widget="one2many">
                    <list>
                      <field name="name"/>
                    </list>
                  </field>
                  <field name="referencing_dockerlayer_ids" widget="one2many">
                    <list>
                      <field name="name"/>
                    </list>
                  </field>
                </page>
                <page string="Build results">
                  <field name="build_results">
                    <list>
                      <field name="dockerfile_id"/>
                      <field name="host_id"/>
                      <field name="duration"/>
                      <field name="result" decoration-bg-danger="result != 'success'" decoration-bg-success="result == 'success'"/>
                      <field name="identifier"/>
                      <field name="create_date"/>
                      <field name="summary"/>
                    </list>
                  </field>
                </page>
              </notebook>
            </sheet>
            <chatter/>
          </form>
        </field>
    </record>

    <record id="dockerfile_view_tree" model="ir.ui.view">
        <field name="name">runbot.dockerfile.list</field>
        <field name="model">runbot.dockerfile</field>
        <field name="arch" type="xml">
          <list string="Dockerfile" decoration-danger="dockerfile == ''" decoration-warning="to_build == False">
            <field name="name"/>
            <field name="image_tag"/>
            <field name="to_build" groups="!runbot.group_runbot_admin"/>
            <field name="to_build" widget="boolean_toggle" groups="runbot.group_runbot_admin"/>
            <field name="always_pull" groups="!runbot.group_runbot_admin"/>
            <field name="always_pull" widget="boolean_toggle" groups="runbot.group_runbot_admin"/>
            <field name="version_ids" widget="many2many_tags"/>
            <field name="project_ids" widget="many2many_tags"/>
            <field name="use_count"/>
            <field name="dockerfile" invisible="True"/>
            <field name="public_visibility"/>
          </list>
        </field>
    </record>
    <record id="docker_layer_form" model="ir.ui.view">
      <field name="name">runbot.docker_layer.form</field>
      <field name="model">runbot.docker_layer</field>
      <field name="arch" type="xml">
        <form string="Docker layer">
          <sheet>
            <div class="alert alert-warning" role="alert" invisible="not has_xml_id">This layer is part of the master data and should not be modified.</div>
            <div class="alert alert-warning" role="alert" invisible="not reference_count">This layer is Used by another layer.</div>
            <group>
              <field name="has_xml_id" invisible="1"/>
              <field name="reference_count" invisible="1"/>
              <field name="name" readonly="has_xml_id"/>
              <field name="dockerfile_id" invisible="dockerfile_id" readonly="has_xml_id"/>
              <field name="layer_type" readonly="has_xml_id"/>
              <field name="content" widget="ace" invisible="layer_type not in ('raw', 'template')" readonly="has_xml_id"/>
              <field name="reference_docker_layer_id" invisible="layer_type not in ('reference_layer')" readonly="has_xml_id"/>
              <field name="reference_dockerfile_id"  invisible="layer_type != 'reference_file'" readonly="has_xml_id"/>
              <field name="values" widget="runbotjsonb" invisible="layer_type not in ('template', 'reference_layer', 'reference_file')" readonly="has_xml_id"/>
              <field name="packages" widget="ace" invisible="layer_type not in ('template', 'reference_layer', 'reference_file')" readonly="has_xml_id"/>
              <field name="all_referencing_dockerlayer_ids"  widget="many2many_tags" readonly="1"/>
            </group>
            <group>
              <field name="rendered"/>
            </group>
          </sheet>
          <chatter/>
        </form>
      </field>
    </record>

    <record id="docker_layer_tree" model="ir.ui.view">
      <field name="name">runbot.docker_layer.list</field>
      <field name="model">runbot.docker_layer</field>
      <field name="arch" type="xml">
        <list string="Docker Layer">
          <field name="name"/>
          <field name="dockerfile_id"/>
          <field name="layer_type"/>
          <field name="referencing_dockerlayer_ids" column_invisible="True"/>
          <field name="packages" column_invisible="True"/>
          <field name="values" column_invisible="True"/>
          <field name="reference_count" string="#refs" decoration-danger="referencing_dockerlayer_ids" decoration-warning="reference_count != 0"/>
          <field name="all_referencing_dockerlayer_ids" string="#referencing" widget="many2many_tags"/>
          <field name="rendered" decoration-warning="layer_type in ('reference_layer', 'reference_file')" decoration-info="layer_type == 'template' or (layer_type == 'reference_layer' and (packages or values))" decoration-success="layer_type == 'raw'"/>
        </list>
      </field>
    </record>

    <record id="docker_build_result_form" model="ir.ui.view">
      <field name="name">runbot.docker_build_result.form</field>
      <field name="model">runbot.docker_build_result</field>
      <field name="arch" type="xml">
        <form string="Docker build result">
          <sheet>
            <group>
              <field name="dockerfile_id"/>
              <field name="host_id"/>
              <field name="duration"/>
              <field name="result"/>
              <field name="identifier"/>
              <field name="summary"/>
            </group>
            <notebook>
              <page string="Output">
                <field name="output"/>
              </page>
              <page string="Content">
                <field name="content"/>
              </page>
              <page string="Metadata">
                <field name="metadata"/>
              </page>
            </notebook>
          </sheet>
        </form>
      </field>
    </record>

    <record id="docker_build_result_tree" model="ir.ui.view">
      <field name="name">runbot.docker_build_result.list</field>
      <field name="model">runbot.docker_build_result</field>
      <field name="arch" type="xml">
        <list string="Docker build result">
          <field name="dockerfile_id"/>
          <field name="host_id"/>
          <field name="duration"/>
          <field name="result"/>
          <field name="identifier"/>
          <field name="summary"/>
        </list>
      </field>
    </record>

  <record id="open_view_dockerfile_tree" model="ir.actions.act_window">
    <field name="name">Dockerfiles</field>
    <field name="res_model">runbot.dockerfile</field>
    <field name="view_mode">list,form</field>
  </record>

  <record id="open_view_docker_result_tree" model="ir.actions.act_window">
    <field name="name">Docker build results</field>
    <field name="res_model">runbot.docker_build_result</field>
    <field name="view_mode">list,form</field>
  </record>

  <record id="open_view_docker_layer_tree" model="ir.actions.act_window">
    <field name="name">Docker Layers</field>
    <field name="res_model">runbot.docker_layer</field>
    <field name="view_mode">list,form</field>
  </record>

  </data>
</odoo>
