@@ -334,6 +334,17 @@ class LayerBranch(models.Model):
def test_file_url(self):
return self.file_url('conf/layer.conf')
+ def updates_disabled_reason(self):
+ """Why the update script no longer updates this layer branch, if it
+ doesn't"""
+ if self.layer.status == 'X':
+ return 'Updates are disabled for this layer'
+ if not self.branch.updates_enabled:
+ return 'Updates are disabled for the %s branch' % self.branch.name
+ if not self.updates_enabled:
+ return 'Updates are disabled for this layer on the %s branch' % self.branch.name
+ return ''
+
def get_checkout_branch(self):
"""Get the branch that we actually need to check out in the repo"""
if self.actual_branch:
@@ -321,3 +321,11 @@ td.info {
height: 400px;
overflow-y: scroll;
}
+
+/* "not updated" label: lighter than label-default, still readable. It also
+ has label-default, so a browser with an older copy of this file still
+ shows it. */
+.label-default.label-not-updated {
+ background-color: #e8e8e8;
+ color: #555;
+}
@@ -443,7 +443,7 @@ class LayerListView(ListView):
def get_queryset(self):
_check_url_branch(self.kwargs)
- return LayerBranch.objects.filter(branch__name=self.kwargs['branch']).filter(layer__status__in=['P', 'X']).order_by('layer__layer_type', '-layer__index_preference', 'layer__name')
+ return LayerBranch.objects.filter(branch__name=self.kwargs['branch']).filter(layer__status__in=['P', 'X']).select_related('branch').order_by('layer__layer_type', '-layer__index_preference', 'layer__name')
def get_context_data(self, **kwargs):
context = super(LayerListView, self).get_context_data(**kwargs)
@@ -125,6 +125,13 @@
<span class="text-muted"><small>Last commit: {{ layerbranch.vcs_last_commit|timesince }} ago ({{ layerbranch.get_checkout_branch }} branch)</small></span>
</p>
{% endif %}
+ {% with reason=layerbranch.updates_disabled_reason %}
+ {% if reason %}
+ <p>
+ <span class="label label-default label-not-updated">not updated</span> <small class="text-muted">{{ reason }}, so the information here may be out of date.</small>
+ </p>
+ {% endif %}
+ {% endwith %}
{% if layerbranch.active_maintainers.count > 0 %}
<h3>{% if layerbranch.active_maintainers|length == 1 %}Maintainer{% else %}Maintainers{% endif %}</h3>
@@ -75,6 +75,7 @@
{% for layerbranch in layerbranch_list %}
<tr class="layertype_{{ layerbranch.layer.layer_type }}">
<td><a href="{% url 'layer_item' url_branch layerbranch.layer.name %}">{{ layerbranch.layer.name }}</a>
+ {% with reason=layerbranch.updates_disabled_reason %}{% if reason %}<span class="label label-default label-not-updated" title="{{ reason }}">not updated</span>{% endif %}{% endwith %}
{% if layerbranch.yp_compatible_version %}
<a href="{{layerbranch.yp_compatible_version.link_url}}"><img src="{{layerbranch.yp_compatible_version.image_url}}" alt="{{layerbranch.yp_compatible_version.description}}" class="yp-icon" title="{{layerbranch.yp_compatible_version.description}}" ></a>
{% endif %}
new file mode 100644
@@ -0,0 +1,45 @@
+# layerindex-web - test the indication that a layer branch is no longer updated
+#
+# Licensed under the MIT license, see COPYING.MIT for details
+#
+# SPDX-License-Identifier: MIT
+
+import pytest
+from django.urls import reverse
+
+from layerindex.models import Branch, LayerBranch, LayerItem
+
+
+def make(name, status='P'):
+ master, _ = Branch.objects.get_or_create(name='master', defaults={'bitbake_branch': 'master'})
+ layer = LayerItem.objects.create(name=name, status=status, layer_type='A', summary=name,
+ description=name, vcs_url='git://example.com/%s.git' % name)
+ return LayerBranch.objects.create(layer=layer, branch=master)
+
+
+@pytest.mark.django_db
+def test_updates_disabled_reason():
+ # [YOCTO #14781] updates can be off for the layer, the branch or the layer branch
+ lb = make('meta-a')
+ assert lb.updates_disabled_reason() == ''
+ lb.updates_enabled = False
+ assert lb.updates_disabled_reason() == 'Updates are disabled for this layer on the master branch'
+ lb.branch.updates_enabled = False
+ assert lb.updates_disabled_reason() == 'Updates are disabled for the master branch'
+ lb.layer.status = 'X'
+ assert lb.updates_disabled_reason() == 'Updates are disabled for this layer'
+
+
+@pytest.mark.django_db
+def test_not_updated_label_on_layer_pages(client):
+ make('meta-updated')
+ make('meta-stale', status='X')
+ layers = client.get(reverse('layer_list', args=('master',))).content.decode()
+ assert layers.count('>not updated</span>') == 1
+ assert 'title="Updates are disabled for this layer"' in layers
+
+ page = client.get(reverse('layer_item', args=('master', 'meta-stale'))).content.decode()
+ assert 'not updated</span>' in page
+ assert 'Updates are disabled for this layer, so the information here may be out of date.' in page
+ page = client.get(reverse('layer_item', args=('master', 'meta-updated'))).content.decode()
+ assert 'not updated</span>' not in page
Updates can be turned off for a layer, a branch or a layer branch, but only the admin interface showed it, so the layer list and layer pages gave no hint that the information may be out of date. Show a "not updated" label with the reason next to the layer in the layer list and on the layer page. [YOCTO #14781] AI-Generated: Claude Opus 5.5 Signed-off-by: Tim Orling <tim.orling@konsulko.com> --- v2: use a lighter grey for the "not updated" label (light grey with dark grey text instead of Bootstrap's label-default), which was too bold with 171 of them in the master layer list. The label keeps label-default, so a browser with an older copy of additional.css still shows it. layerindex/models.py | 11 +++++++ layerindex/static/css/additional.css | 8 +++++ layerindex/views.py | 2 +- templates/layerindex/detail.html | 7 +++++ templates/layerindex/layers.html | 1 + tests/test_updates_disabled.py | 45 ++++++++++++++++++++++++++++ 6 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 tests/test_updates_disabled.py base-commit: 08e58cdece30019a6f9e5d14af16ebe20afa6177