[IMP] runbot: use build database_ids to generate connect links

aka: make it clean

This build database_ids field was generated a few months, waiting for the database to update with
this new sceme before using it.

It is still a little early to use it in cleanup methods, but this can be used to
generate the connect links dynamicaly.

To follow al specs introduced in previous commit, main fa-sign-in button should link to the -all.
It will almost always be the first one in database_ids in alphabetic order.
Then, in the dropdown, all other database are listed.

This will fix the previously broken design_theme connect link (no base nor all).

For this purpose nginx regex needs to be adapted to accept database name with underscore.
This commit is contained in:
Xavier-Do 2021-03-01 15:49:23 +01:00
parent 26ad74051f
commit c538bd17f8
2 changed files with 11 additions and 9 deletions

View File

@ -54,7 +54,7 @@ server {
<t t-foreach="builds" t-as="build">
server {
listen 8080;
server_name ~^<t t-raw="re_escape(build.dest)"/>(-[a-z0-9]+)?\.<t t-raw="re_escape(fqdn)"/>$;
server_name ~^<t t-raw="re_escape(build.dest)"/>(-[a-z0-9_]+)?\.<t t-raw="re_escape(fqdn)"/>$;
location / { proxy_pass http://127.0.0.1:<t t-esc="build.port"/>; }
location /longpolling { proxy_pass http://127.0.0.1:<t t-esc="build.port + 1"/>; }
}

View File

@ -164,7 +164,7 @@
<span t-else="" t-attf-class="btn btn-default disabled slot_name">
<span t-esc="slot.trigger_id.name"/>
</span>
<a t-if="bu.local_state == 'running'" t-attf-href="http://{{bu.dest}}-all.{{bu.host}}" class="fa fa-sign-in btn btn-info"/>
<a t-if="bu.local_state == 'running' and bu.database_ids" t-attf-href="http://{{sorted(bu.mapped('database_ids.name'))[0]}}.{{bu.host}}" class="fa fa-sign-in btn btn-info"/>
<t t-if="bu" t-call="runbot.build_menu"/>
<a t-if="not bu" class="btn btn-default" title="Create build" t-attf-href="/runbot/batch/slot/{{slot.id}}/build">
<i class="fa fa-play fa-fw"/>
@ -175,7 +175,7 @@
<template id="runbot.build_button">
<div t-attf-class="pull-right">
<div t-attf-class="btn-group {{klass}}">
<a t-if="bu.local_state=='running'" t-attf-href="http://{{bu.dest}}-all.{{bu.host}}" class="btn btn-primary" title="Sign in on this build" aria-label="Sign in on this build">
<a t-if="bu.local_state == 'running' and bu.database_ids" t-attf-href="http://{{sorted(bu.mapped('database_ids.name'))[0]}}.{{bu.host}}" class="btn btn-primary" title="Sign in on this build" aria-label="Sign in on this build">
<i class="fa fa-sign-in"/>
</a>
<a t-if="bu.local_state=='done' and bu.requested_action != 'wake_up'" href="#" data-runbot="wakeup" t-att-data-runbot-build="bu.id" class="btn btn-default" title="Wake up this build" aria-label="Wake up this build">
@ -223,13 +223,15 @@
Force Build
</a>
<t t-if="bu.local_state=='running'">
<a class="dropdown-item" t-attf-href="http://{{bu.dest}}-base.{{bu.host}}/">
<t t-foreach="bu.database_ids.sorted('name')[1:]" t-as="db">
<a class="dropdown-item" t-attf-href="http://{{db.name}}.{{bu.host}}/">
<i class="fa fa-sign-in"/>
Connect <t t-esc="db.db_suffix"></t>
</a>
</t>
<a class="dropdown-item" t-attf-href="http://{{bu.domain}}/web/database/selector">
<i class="fa fa-sign-in"/>
Connect base
</a>
<a class="dropdown-item" t-attf-href="http://{{bu.domain}}/">
<i class="fa fa-sign-in"/>
Connect
Database selector
</a>
</t>
<a class="dropdown-item" t-if="bu.global_state in ['done','running'] or requested_action == 'deathrow'" groups="base.group_user" href="#" data-runbot="rebuild" t-att-data-runbot-build="bu['id']" title="Retry this build, usefull for false positive">