* [PATCH 01/10] toaster: Reorganise and lint tests
2015-10-07 13:20 [PATCH 00/10] toaster: Implement UI changes for "command line builds" project Ed Bartosh
@ 2015-10-07 13:20 ` Ed Bartosh
2015-10-07 13:20 ` [PATCH 02/10] toaster: Replace "Run again" button with help text for cli builds Ed Bartosh
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Ed Bartosh @ 2015-10-07 13:20 UTC (permalink / raw)
To: bitbake-devel
From: Elliot Smith <elliot.smith@intel.com>
Get test suite ready to accommodate new tests for how command line
builds are shown on various pages.
Signed-off-by: Elliot Smith <elliot.smith@intel.com>
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
lib/toaster/toastergui/tests.py | 83 ++++++++++++++++++++++++-----------------
1 file changed, 49 insertions(+), 34 deletions(-)
diff --git a/lib/toaster/toastergui/tests.py b/lib/toaster/toastergui/tests.py
index 95790a2..7b1f9b5 100644
--- a/lib/toaster/toastergui/tests.py
+++ b/lib/toaster/toastergui/tests.py
@@ -21,23 +21,20 @@
"""Test cases for Toaster GUI and ReST."""
-import re
-
from django.test import TestCase
from django.test.client import RequestFactory
from django.core.urlresolvers import reverse
from django.utils import timezone
-from orm.models import Project, Release, BitbakeVersion, Build, Package
+from orm.models import Project, Release, BitbakeVersion, Package
from orm.models import ReleaseLayerSourcePriority, LayerSource, Layer, Build
from orm.models import Layer_Version, Recipe, Machine, ProjectLayer, Target
from orm.models import CustomImageRecipe
from orm.models import Branch
from toastergui.tables import SoftwareRecipesTable
-from django.utils import timezone
-import json
from bs4 import BeautifulSoup
+import json
import re
PROJECT_NAME = "test project"
@@ -72,11 +69,11 @@ class ViewTests(TestCase):
up_branch=branch)
self.recipe1 = Recipe.objects.create(layer_source=layersrc,
- name="base-recipe",
- version="1.2",
- summary="one recipe",
- description="recipe",
- layer_version=lver)
+ name="base-recipe",
+ version="1.2",
+ summary="one recipe",
+ description="recipe",
+ layer_version=lver)
Machine.objects.create(layer_version=lver, name="wisk",
description="wisking machine")
@@ -337,11 +334,7 @@ class ViewTests(TestCase):
rows = data['rows']
row1 = next(x for x in rows if x['name'] == self.recipe1.name)
- row1_btns = row1['static:add-del-layers']
- row1_btns_data = row1['add-del-layers']
row2 = next(x for x in rows if x['name'] == self.recipe2.name)
- row2_btns = row2['static:add-del-layers']
- row2_btns_data = row2['add-del-layers']
self.assertEqual(response.status_code, 200, 'should be 200 OK status')
self.assertEqual(len(rows), 2, 'should be 2 recipes')
@@ -472,7 +465,7 @@ class ProjectsPageTests(TestCase):
self.assertTrue(self.PROJECT_NAME in response.content,
'default project "cli builds" should be in page')
-class ProjectBuildsDisplayTest(TestCase):
+class ProjectBuildsPageTests(TestCase):
""" Test data at /project/X/builds is displayed correctly """
def setUp(self):
@@ -517,6 +510,7 @@ class ProjectBuildsDisplayTest(TestCase):
}
def _get_rows_for_project(self, project_id):
+ """ Helper to retrieve HTML rows for a project """
url = reverse("projectbuilds", args=(project_id,))
response = self.client.get(url, follow=True)
soup = BeautifulSoup(response.content)
@@ -524,52 +518,73 @@ class ProjectBuildsDisplayTest(TestCase):
def test_show_builds_for_project(self):
""" Builds for a project should be displayed """
- build1a = Build.objects.create(**self.project1_build_success)
- build1b = Build.objects.create(**self.project1_build_success)
+ Build.objects.create(**self.project1_build_success)
+ Build.objects.create(**self.project1_build_success)
build_rows = self._get_rows_for_project(self.project1.id)
self.assertEqual(len(build_rows), 2)
- def test_show_builds_for_project_only(self):
+ def test_show_builds_project_only(self):
""" Builds for other projects should be excluded """
- build1a = Build.objects.create(**self.project1_build_success)
- build1b = Build.objects.create(**self.project1_build_success)
- build1c = Build.objects.create(**self.project1_build_success)
+ Build.objects.create(**self.project1_build_success)
+ Build.objects.create(**self.project1_build_success)
+ Build.objects.create(**self.project1_build_success)
# shouldn't see these two
- build2a = Build.objects.create(**self.project2_build_success)
- build2b = Build.objects.create(**self.project2_build_in_progress)
+ Build.objects.create(**self.project2_build_success)
+ Build.objects.create(**self.project2_build_in_progress)
build_rows = self._get_rows_for_project(self.project1.id)
self.assertEqual(len(build_rows), 3)
- def test_show_builds_exclude_in_progress(self):
+ def test_builds_exclude_in_progress(self):
""" "in progress" builds should not be shown """
- build1a = Build.objects.create(**self.project1_build_success)
- build1b = Build.objects.create(**self.project1_build_success)
+ Build.objects.create(**self.project1_build_success)
+ Build.objects.create(**self.project1_build_success)
# shouldn't see this one
- build1c = Build.objects.create(**self.project1_build_in_progress)
+ Build.objects.create(**self.project1_build_in_progress)
# shouldn't see these two either, as they belong to a different project
- build2a = Build.objects.create(**self.project2_build_success)
- build2b = Build.objects.create(**self.project2_build_in_progress)
+ Build.objects.create(**self.project2_build_success)
+ Build.objects.create(**self.project2_build_in_progress)
build_rows = self._get_rows_for_project(self.project1.id)
self.assertEqual(len(build_rows), 2)
- def test_show_tasks_in_projectbuilds(self):
+ def test_tasks_in_projectbuilds(self):
+ """ Task should be shown as suffix on build name """
build = Build.objects.create(**self.project1_build_success)
- target = Target.objects.create(build=build, target='bash',
- task='clean')
+ Target.objects.create(build=build, target='bash', task='clean')
url = reverse("projectbuilds", args=(self.project1.id,))
response = self.client.get(url, follow=True)
result = re.findall('^ +bash:clean$', response.content, re.MULTILINE)
self.assertEqual(len(result), 2)
+class AllBuildsPageTests(TestCase):
+ """ Tests for all builds page """
+
+ def setUp(self):
+ bbv = BitbakeVersion.objects.create(name="bbv1", giturl="/tmp/",
+ branch="master", dirpath="")
+ release = Release.objects.create(name="release1",
+ bitbake_version=bbv)
+ self.project1 = Project.objects.create_project(name=PROJECT_NAME,
+ release=release)
+
+ # parameters for builds to associate with the projects
+ now = timezone.now()
+
+ self.project1_build_success = {
+ "project": self.project1,
+ "started_on": now,
+ "completed_on": now,
+ "outcome": Build.SUCCEEDED
+ }
+
def test_show_tasks_in_allbuilds(self):
+ """ Task should be shown as suffix on build name """
build = Build.objects.create(**self.project1_build_success)
- target = Target.objects.create(build=build, target='bash',
- task='clean')
+ Target.objects.create(build=build, target='bash', task='clean')
url = reverse("all-builds")
response = self.client.get(url, follow=True)
result = re.findall('bash:clean', response.content, re.MULTILINE)
--
2.1.4
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 02/10] toaster: Replace "Run again" button with help text for cli builds
2015-10-07 13:20 [PATCH 00/10] toaster: Implement UI changes for "command line builds" project Ed Bartosh
2015-10-07 13:20 ` [PATCH 01/10] toaster: Reorganise and lint tests Ed Bartosh
@ 2015-10-07 13:20 ` Ed Bartosh
2015-10-07 13:20 ` [PATCH 03/10] toaster: Show 'not applicable' for default project machine and release Ed Bartosh
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Ed Bartosh @ 2015-10-07 13:20 UTC (permalink / raw)
To: bitbake-devel
From: Elliot Smith <elliot.smith@intel.com>
It's not possible to run a command-line build again, as Toaster
doesn't have access to the data used for that build.
Replace the "Run again" button with an icon which pops up some
help text to that effect.
Add test to check that the run again button is hidden and the
help icon displayed instead for command-line builds.
[YOCTO #8231]
Signed-off-by: Elliot Smith <elliot.smith@intel.com>
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
lib/toaster/toastergui/static/css/default.css | 5 +++
lib/toaster/toastergui/templates/mrb_section.html | 41 +++++++++++++++--------
lib/toaster/toastergui/tests.py | 32 ++++++++++++++++++
3 files changed, 64 insertions(+), 14 deletions(-)
diff --git a/lib/toaster/toastergui/static/css/default.css b/lib/toaster/toastergui/static/css/default.css
index cce3e31..336a407 100644
--- a/lib/toaster/toastergui/static/css/default.css
+++ b/lib/toaster/toastergui/static/css/default.css
@@ -15,6 +15,8 @@
/* Styles for the help information */
.get-help { color: #CCCCCC; }
.get-help:hover, .icon-plus-sign:hover { color: #999999; cursor: pointer; }
+.get-help-green { color: #468847; }
+.get-help-green:hover { color: #347132; cursor: pointer; }
.get-help-blue { color: #3A87AD; }
.get-help-blue:hover { color: #005580; cursor: pointer; }
.get-help-yellow { color: #C09853; }
@@ -161,6 +163,9 @@ table { table-layout: fixed; word-wrap: break-word; }
.project-name .label { font-weight: normal; margin-bottom: 5px; margin-left: -15px; padding: 5px; }
.project-name .label > a { color: #fff; font-weight: normal; }
+/* styles for showing help icons next to command-line builds */
+.build-result .get-help-green, .build-result .get-help-red, .build-result .get-help-blue { margin-right: 35px; margin-top: 8px; font-size: 16px; }
+
/* Remove bottom margin for forms inside modal dialogs */
#dependencies-modal-form { margin-bottom: 0px; }
diff --git a/lib/toaster/toastergui/templates/mrb_section.html b/lib/toaster/toastergui/templates/mrb_section.html
index ad90e82..5e96b39 100644
--- a/lib/toaster/toastergui/templates/mrb_section.html
+++ b/lib/toaster/toastergui/templates/mrb_section.html
@@ -18,7 +18,7 @@
{% endif %}
<div id="latest-builds">
{% for build in mru %}
- <div class="alert {%if build.outcome == build.SUCCEEDED%}alert-success{%elif build.outcome == build.FAILED%}alert-error{%else%}alert-info{%endif%}
+ <div id="build-result-{{ build.id }}" class="alert build-result {%if build.outcome == build.SUCCEEDED%}alert-success{%elif build.outcome == build.FAILED%}alert-error{%else%}alert-info{%endif%}
{% if mrb_type != 'project' %}
project-name">
<span class="label {%if build.outcome == build.SUCCEEDED%}label-success{%elif build.outcome == build.FAILED%}label-important{%else%}label-info{%endif%}">
@@ -81,24 +81,37 @@
</div>
<div class="lead ">
<span class="lead">
- Build time: <a href="{% url 'buildtime' build.pk %}">{{ build.timespent_seconds|sectohms }}</a>
+ Build time: <a href="{% url 'buildtime' build.pk %}">{{ build.timespent_seconds|sectohms }}</a>
</span>
- <button class="btn
+ {% if build.project.is_default %}
+ <i class="pull-right icon-question-sign get-help
{% if build.outcome == build.SUCCEEDED %}
- btn-success
+ get-help-green
{% elif build.outcome == build.FAILED %}
- btn-danger
+ get-help-red
{% else %}
- btn-info
- {%endif%}
- pull-right"
- onclick='scheduleBuild({% url 'projectbuilds' build.project.id as bpi %}{{bpi|json}},
- {{build.project.name|json}},
- {% url 'project' build.project.id as bpurl %}{{bpurl|json}},
- {{build.target_set.all|get_tasks|json}})'>
+ get-help-blue
+ {% endif %}
+ " title="Builds in this project cannot be started from Toaster: they are started from the command line">
+ </i>
+ {% else %}
+ <button class="btn
+ {% if build.outcome == build.SUCCEEDED %}
+ btn-success
+ {% elif build.outcome == build.FAILED %}
+ btn-danger
+ {% else %}
+ btn-info
+ {%endif%}
+ pull-right"
+ onclick='scheduleBuild({% url 'projectbuilds' build.project.id as bpi %}{{bpi|json}},
+ {{build.project.name|json}},
+ {% url 'project' build.project.id as bpurl %}{{bpurl|json}},
+ {{build.target_set.all|get_tasks|json}})'>
- Run again
- </button>
+ Run again
+ </button>
+ {% endif %}
</div>
{%endif%}
{%if build.outcome == build.IN_PROGRESS %}
diff --git a/lib/toaster/toastergui/tests.py b/lib/toaster/toastergui/tests.py
index 7b1f9b5..00ae9d4 100644
--- a/lib/toaster/toastergui/tests.py
+++ b/lib/toaster/toastergui/tests.py
@@ -38,6 +38,7 @@ import json
import re
PROJECT_NAME = "test project"
+CLI_BUILDS_PROJECT_NAME = 'Command line builds'
class ViewTests(TestCase):
"""Tests to verify view APIs."""
@@ -570,6 +571,12 @@ class AllBuildsPageTests(TestCase):
bitbake_version=bbv)
self.project1 = Project.objects.create_project(name=PROJECT_NAME,
release=release)
+ self.default_project = Project.objects.create_project(
+ name=CLI_BUILDS_PROJECT_NAME,
+ release=release
+ )
+ self.default_project.is_default = True
+ self.default_project.save()
# parameters for builds to associate with the projects
now = timezone.now()
@@ -581,6 +588,13 @@ class AllBuildsPageTests(TestCase):
"outcome": Build.SUCCEEDED
}
+ self.default_project_build_success = {
+ "project": self.default_project,
+ "started_on": now,
+ "completed_on": now,
+ "outcome": Build.SUCCEEDED
+ }
+
def test_show_tasks_in_allbuilds(self):
""" Task should be shown as suffix on build name """
build = Build.objects.create(**self.project1_build_success)
@@ -589,3 +603,21 @@ class AllBuildsPageTests(TestCase):
response = self.client.get(url, follow=True)
result = re.findall('bash:clean', response.content, re.MULTILINE)
self.assertEqual(len(result), 3)
+
+ def test_no_run_again_for_cli_build(self):
+ """ "Run again" button should not be shown for command-line builds """
+ build = Build.objects.create(**self.default_project_build_success)
+ url = reverse("all-builds")
+ response = self.client.get(url, follow=True)
+ soup = BeautifulSoup(response.content)
+
+ element_id = 'build-result-%d' % build.id
+
+ # shouldn't see a run again button for command-line builds
+ run_again_button = soup.select('#%s button' % element_id)
+ self.assertEqual(len(run_again_button), 0)
+
+ # should see a help icon for command-line builds
+ help_icon = soup.select('#%s i.get-help-green' % element_id)
+ self.assertEqual(len(help_icon), 1)
+
--
2.1.4
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 03/10] toaster: Show 'not applicable' for default project machine and release
2015-10-07 13:20 [PATCH 00/10] toaster: Implement UI changes for "command line builds" project Ed Bartosh
2015-10-07 13:20 ` [PATCH 01/10] toaster: Reorganise and lint tests Ed Bartosh
2015-10-07 13:20 ` [PATCH 02/10] toaster: Replace "Run again" button with help text for cli builds Ed Bartosh
@ 2015-10-07 13:20 ` Ed Bartosh
2015-10-07 13:20 ` [PATCH 04/10] toaster: Make the builds view the project page for "command line builds" Ed Bartosh
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Ed Bartosh @ 2015-10-07 13:20 UTC (permalink / raw)
To: bitbake-devel
From: Elliot Smith <elliot.smith@intel.com>
The machine and release for the default project should show as
'not applicable' on the all projects page, as that information
isn't available for command-line builds.
Modify the templates with some conditionals to check for the
default project row, plus some data-* attributes to mark
where that data is to make testing possible.
Add some tests for the all projects page to ensure that
the correct machine/release are still shown for non-default projects,
and 'not applicable' for the default project.
[YOCTO #8231]
Signed-off-by: Elliot Smith <elliot.smith@intel.com>
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
lib/toaster/toastergui/templates/projects.html | 16 +++-
lib/toaster/toastergui/tests.py | 108 ++++++++++++++++++++++---
2 files changed, 111 insertions(+), 13 deletions(-)
diff --git a/lib/toaster/toastergui/templates/projects.html b/lib/toaster/toastergui/templates/projects.html
index c2d77b5..a7192c2 100644
--- a/lib/toaster/toastergui/templates/projects.html
+++ b/lib/toaster/toastergui/templates/projects.html
@@ -36,17 +36,27 @@
{% else %} {# We have builds to display #}
{% include "basetable_top.html" %}
{% for o in objects %}
- <tr class="data">
+ <tr class="data" data-project="{{ o.id }}">
<td><a href="{% url 'project' o.id %}">{{o.name}}</a></td>
<td class="updated"><a href="{% url 'project' o.id %}">{{o.updated|date:"d/m/y H:i"}}</a></td>
- <td>
+ <td data-project-field="release">
{% if o.release %}
<a href="{% url 'project' o.id %}#project-details">{{o.release.name}}</a>
+ {% elif o.is_default %}
+ <span class="muted">Not applicable</span>
+ <i class="icon-question-sign get-help hover-help" title="" data-original-title="This project does not have a release set. It simply collects information about the builds you start from the command line while Toaster is running" style="visibility: hidden;"></i>
{% else %}
No release available
{% endif %}
</td>
- <td><a href="{% url 'project' o.id %}#machine-distro">{{o.get_current_machine_name}}</a></td>
+ <td data-project-field="machine">
+ {% if o.is_default %}
+ <span class="muted">Not applicable</span>
+ <i class="icon-question-sign get-help hover-help" title="" data-original-title="This project does not have a machine set. It simply collects information about the builds you start from the command line while Toaster is running" style="visibility: hidden;"></i>
+ {% else %}
+ <a href="{% url 'project' o.id %}#machine-distro">{{o.get_current_machine_name}}</a>
+ {% endif %}
+ </td>
{% if o.get_number_of_builds == 0 %}
<td class="muted">{{o.get_number_of_builds}}</td>
<td class="loutcome"></td>
diff --git a/lib/toaster/toastergui/tests.py b/lib/toaster/toastergui/tests.py
index 00ae9d4..0b85d4f 100644
--- a/lib/toaster/toastergui/tests.py
+++ b/lib/toaster/toastergui/tests.py
@@ -29,7 +29,7 @@ from django.utils import timezone
from orm.models import Project, Release, BitbakeVersion, Package
from orm.models import ReleaseLayerSourcePriority, LayerSource, Layer, Build
from orm.models import Layer_Version, Recipe, Machine, ProjectLayer, Target
-from orm.models import CustomImageRecipe
+from orm.models import CustomImageRecipe, ProjectVariable
from orm.models import Branch
from toastergui.tables import SoftwareRecipesTable
@@ -431,15 +431,43 @@ class LandingPageTests(TestCase):
class ProjectsPageTests(TestCase):
""" Tests for projects page """
- PROJECT_NAME = 'cli builds'
+ MACHINE_NAME = 'delorean'
+
+ def _add_build_to_default_project(self):
+ """ Add a build to the default project (not used in all tests) """
+ now = timezone.now()
+ build = Build.objects.create(project=self.default_project,
+ started_on=now,
+ completed_on=now)
+ build.save()
+
+ def _add_non_default_project(self):
+ """ Add another project """
+ bbv = BitbakeVersion.objects.create(name="test bbv", giturl="/tmp/",
+ branch="master", dirpath="")
+ self.release = Release.objects.create(name="test release",
+ branch_name="master",
+ bitbake_version=bbv)
+ self.project = Project.objects.create_project(PROJECT_NAME, self.release)
+ self.project.is_default = False
+ self.project.save()
+
+ # fake the MACHINE variable
+ project_var = ProjectVariable.objects.create(project=self.project,
+ name='MACHINE',
+ value=self.MACHINE_NAME)
+ project_var.save()
def setUp(self):
""" Add default project manually """
- project = Project.objects.create_project(self.PROJECT_NAME, None)
+ project = Project.objects.create_project(CLI_BUILDS_PROJECT_NAME, None)
self.default_project = project
self.default_project.is_default = True
self.default_project.save()
+ # this project is only set for some of the tests
+ self.project = None
+
def test_default_project_hidden(self):
""" The default project should be hidden if it has no builds """
params = {"count": 10, "orderby": "updated:-", "page": 1}
@@ -447,25 +475,85 @@ class ProjectsPageTests(TestCase):
self.assertTrue(not('tr class="data"' in response.content),
'should be no project rows in the page')
- self.assertTrue(not(self.PROJECT_NAME in response.content),
+ self.assertTrue(not(CLI_BUILDS_PROJECT_NAME in response.content),
'default project "cli builds" should not be in page')
def test_default_project_has_build(self):
""" The default project should be shown if it has builds """
- now = timezone.now()
- build = Build.objects.create(project=self.default_project,
- started_on=now,
- completed_on=now)
- build.save()
+ self._add_build_to_default_project()
params = {"count": 10, "orderby": "updated:-", "page": 1}
response = self.client.get(reverse('all-projects'), params)
self.assertTrue('tr class="data"' in response.content,
'should be a project row in the page')
- self.assertTrue(self.PROJECT_NAME in response.content,
+ self.assertTrue(CLI_BUILDS_PROJECT_NAME in response.content,
'default project "cli builds" should be in page')
+ def test_default_project_release(self):
+ """
+ The release for the default project should display as
+ 'Not applicable'
+ """
+ # need a build, otherwise project doesn't display at all
+ self._add_build_to_default_project()
+
+ # another project to test, which should show release
+ self._add_non_default_project()
+
+ response = self.client.get(reverse('all-projects'), follow=True)
+ soup = BeautifulSoup(response.content)
+
+ # check the release cell for the default project
+ attrs = {'data-project': str(self.default_project.id)}
+ rows = soup.find_all('tr', attrs=attrs)
+ self.assertEqual(len(rows), 1, 'should be one row for default project')
+ cells = rows[0].find_all('td', attrs={'data-project-field': 'release'})
+ self.assertEqual(len(cells), 1, 'should be one release cell')
+ text = cells[0].select('span.muted')[0].text
+ self.assertEqual(text, 'Not applicable',
+ 'release should be not applicable for default project')
+
+ # check the link in the release cell for the other project
+ attrs = {'data-project': str(self.project.id)}
+ rows = soup.find_all('tr', attrs=attrs)
+ cells = rows[0].find_all('td', attrs={'data-project-field': 'release'})
+ text = cells[0].select('a')[0].text
+ self.assertEqual(text, self.release.name,
+ 'release name should be shown for non-default project')
+
+ def test_default_project_machine(self):
+ """
+ The machine for the default project should display as
+ 'Not applicable'
+ """
+ # need a build, otherwise project doesn't display at all
+ self._add_build_to_default_project()
+
+ # another project to test, which should show machine
+ self._add_non_default_project()
+
+ response = self.client.get(reverse('all-projects'), follow=True)
+ soup = BeautifulSoup(response.content)
+
+ # check the machine cell for the default project
+ attrs = {'data-project': str(self.default_project.id)}
+ rows = soup.find_all('tr', attrs=attrs)
+ self.assertEqual(len(rows), 1, 'should be one row for default project')
+ cells = rows[0].find_all('td', attrs={'data-project-field': 'machine'})
+ self.assertEqual(len(cells), 1, 'should be one machine cell')
+ text = cells[0].select('span.muted')[0].text
+ self.assertEqual(text, 'Not applicable',
+ 'machine should be not applicable for default project')
+
+ # check the link in the machine cell for the other project
+ attrs = {'data-project': str(self.project.id)}
+ rows = soup.find_all('tr', attrs=attrs)
+ cells = rows[0].find_all('td', attrs={'data-project-field': 'machine'})
+ text = cells[0].select('a')[0].text
+ self.assertEqual(text, self.MACHINE_NAME,
+ 'machine name should be shown for non-default project')
+
class ProjectBuildsPageTests(TestCase):
""" Test data at /project/X/builds is displayed correctly """
--
2.1.4
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 04/10] toaster: Make the builds view the project page for "command line builds"
2015-10-07 13:20 [PATCH 00/10] toaster: Implement UI changes for "command line builds" project Ed Bartosh
` (2 preceding siblings ...)
2015-10-07 13:20 ` [PATCH 03/10] toaster: Show 'not applicable' for default project machine and release Ed Bartosh
@ 2015-10-07 13:20 ` Ed Bartosh
2015-10-07 13:20 ` [PATCH 05/10] toaster: Hide tabs and add info popups for command line builds Ed Bartosh
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Ed Bartosh @ 2015-10-07 13:20 UTC (permalink / raw)
To: bitbake-devel
From: Elliot Smith <elliot.smith@intel.com>
Command line builds don't have configuration or layers which can
be manipulated in Toaster, so these pages shouldn't be visible.
However, the configuration page is the default page for the
project view (/project/X/), which isn't correct for the
command line builds project.
Modify all project page links across the application so that
the command line builds project (aka the "default" project)
always displays the builds tab.
Add a project_url tag for templates which contains the logic
determining where the URL for a project links to, based on
whether it is the default project or not.
[YOCTO #8231]
Signed-off-by: Elliot Smith <elliot.smith@intel.com>
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
lib/toaster/toastergui/templates/base.html | 5 +--
lib/toaster/toastergui/templates/builds.html | 3 +-
lib/toaster/toastergui/templates/mrb_section.html | 6 ++--
lib/toaster/toastergui/templates/projects.html | 7 ++--
.../toastergui/templatetags/project_url_tag.py | 34 +++++++++++++++++++
lib/toaster/toastergui/tests.py | 38 ++++++++++++++++++++--
6 files changed, 82 insertions(+), 11 deletions(-)
create mode 100644 bitbake/lib/toaster/toastergui/templatetags/project_url_tag.py
diff --git a/lib/toaster/toastergui/templates/base.html b/lib/toaster/toastergui/templates/base.html
index 640bc47..3f27790 100644
--- a/lib/toaster/toastergui/templates/base.html
+++ b/lib/toaster/toastergui/templates/base.html
@@ -1,6 +1,7 @@
<!DOCTYPE html>
{% load static %}
{% load projecttags %}
+{% load project_url_tag %}
<html lang="en">
<head>
<title>{% if objectname %} {{objectname|title}} - {% endif %}Toaster</title>
@@ -35,7 +36,7 @@
projectsTypeAheadUrl: {% url 'xhr_projectstypeahead' as prjurl%}{{prjurl|json}},
{% if project.id %}
projectId : {{project.id}},
- projectPageUrl : {% url 'project' project.id as purl%}{{purl|json}},
+ projectPageUrl : {% url 'project' project.id as purl %}{{purl|json}},
projectName : {{project.name|json}},
recipesTypeAheadUrl: {% url 'xhr_recipestypeahead' project.id as paturl%}{{paturl|json}},
layersTypeAheadUrl: {% url 'xhr_layerstypeahead' project.id as paturl%}{{paturl|json}},
@@ -133,7 +134,7 @@
<h6>Project:</h6>
<span id="project">
{% if project.id %}
- <a class="lead" href="{% url 'project' project.id %}">{{project.name}}</a>
+ <a class="lead" href="{% project_url project %}">{{project.name}}</a>
{% else %}
<a class="lead" href="#"></a>
{% endif %}
diff --git a/lib/toaster/toastergui/templates/builds.html b/lib/toaster/toastergui/templates/builds.html
index 2b35b01..6fbaf98 100644
--- a/lib/toaster/toastergui/templates/builds.html
+++ b/lib/toaster/toastergui/templates/builds.html
@@ -2,6 +2,7 @@
{% load static %}
{% load projecttags %}
+{% load project_url_tag %}
{% load humanize %}
{% block extraheadcontent %}
@@ -104,7 +105,7 @@
{% endif %}
</td>
<td>
- <a href="{% url 'project' build.project.id %}">{{build.project.name}}</a>
+ <a href="{% project_url build.project %}">{{build.project.name}}</a>
</td>
</tr>
diff --git a/lib/toaster/toastergui/templates/mrb_section.html b/lib/toaster/toastergui/templates/mrb_section.html
index 5e96b39..b29f650 100644
--- a/lib/toaster/toastergui/templates/mrb_section.html
+++ b/lib/toaster/toastergui/templates/mrb_section.html
@@ -1,8 +1,8 @@
{% load static %}
{% load projecttags %}
+{% load project_url_tag %}
{% load humanize %}
-
{%if mru and mru.count > 0%}
{%if mrb_type == 'project' %}
@@ -22,7 +22,7 @@
{% if mrb_type != 'project' %}
project-name">
<span class="label {%if build.outcome == build.SUCCEEDED%}label-success{%elif build.outcome == build.FAILED%}label-important{%else%}label-info{%endif%}">
- <a href={% url 'project' build.project.pk %}>
+ <a href={% project_url build.project %}>
{{build.project.name}}
</a>
</span>
@@ -106,7 +106,7 @@
pull-right"
onclick='scheduleBuild({% url 'projectbuilds' build.project.id as bpi %}{{bpi|json}},
{{build.project.name|json}},
- {% url 'project' build.project.id as bpurl %}{{bpurl|json}},
+ {% url 'project' build.project.id as purl %}{{purl|json}},
{{build.target_set.all|get_tasks|json}})'>
Run again
diff --git a/lib/toaster/toastergui/templates/projects.html b/lib/toaster/toastergui/templates/projects.html
index a7192c2..7c612e8 100644
--- a/lib/toaster/toastergui/templates/projects.html
+++ b/lib/toaster/toastergui/templates/projects.html
@@ -2,6 +2,7 @@
{% load static %}
{% load projecttags %}
+{% load project_url_tag %}
{% load humanize %}
{% block pagecontent %}
@@ -37,8 +38,10 @@
{% include "basetable_top.html" %}
{% for o in objects %}
<tr class="data" data-project="{{ o.id }}">
- <td><a href="{% url 'project' o.id %}">{{o.name}}</a></td>
- <td class="updated"><a href="{% url 'project' o.id %}">{{o.updated|date:"d/m/y H:i"}}</a></td>
+ <td data-project-field="name">
+ <a href="{% project_url o %}">{{o.name}}</a>
+ </td>
+ <td class="updated"><a href="{% project_url o %}">{{o.updated|date:"d/m/y H:i"}}</a></td>
<td data-project-field="release">
{% if o.release %}
<a href="{% url 'project' o.id %}#project-details">{{o.release.name}}</a>
diff --git a/lib/toaster/toastergui/templatetags/project_url_tag.py b/lib/toaster/toastergui/templatetags/project_url_tag.py
new file mode 100644
index 0000000..04770ac
--- /dev/null
+++ b/lib/toaster/toastergui/templatetags/project_url_tag.py
@@ -0,0 +1,34 @@
+from django import template
+from django.core.urlresolvers import reverse
+
+register = template.Library()
+
+def project_url(parser, token):
+ """
+ Create a URL for a project's main page;
+ for non-default projects, this is the configuration page;
+ for the default project, this is the project builds page
+ """
+ try:
+ tag_name, project = token.split_contents()
+ except ValueError:
+ raise template.TemplateSyntaxError(
+ "%s tag requires exactly one argument" % tag_name
+ )
+ return ProjectUrlNode(project)
+
+class ProjectUrlNode(template.Node):
+ def __init__(self, project):
+ self.project = template.Variable(project)
+
+ def render(self, context):
+ try:
+ project = self.project.resolve(context)
+ if project.is_default:
+ return reverse('projectbuilds', args=(project.id,))
+ else:
+ return reverse('project', args=(project.id,))
+ except template.VariableDoesNotExist:
+ return ''
+
+register.tag('project_url', project_url)
diff --git a/lib/toaster/toastergui/tests.py b/lib/toaster/toastergui/tests.py
index 0b85d4f..12a91c3 100644
--- a/lib/toaster/toastergui/tests.py
+++ b/lib/toaster/toastergui/tests.py
@@ -428,8 +428,8 @@ class LandingPageTests(TestCase):
self.assertTrue('/builds' in response.url,
'should redirect to builds')
-class ProjectsPageTests(TestCase):
- """ Tests for projects page """
+class AllProjectsPageTests(TestCase):
+ """ Tests for projects page /projects/ """
MACHINE_NAME = 'delorean'
@@ -554,6 +554,38 @@ class ProjectsPageTests(TestCase):
self.assertEqual(text, self.MACHINE_NAME,
'machine name should be shown for non-default project')
+ def test_project_page_links(self):
+ """
+ Test that links for the default project point to the builds
+ page /projects/X/builds for that project, and that links for
+ other projects point to their configuration pages /projects/X/
+ """
+
+ # need a build, otherwise project doesn't display at all
+ self._add_build_to_default_project()
+
+ # another project to test, which should show machine
+ self._add_non_default_project()
+
+ response = self.client.get(reverse('all-projects'), follow=True)
+ soup = BeautifulSoup(response.content)
+
+ # link for default project
+ row = soup.find('tr', attrs={'data-project': self.default_project.id})
+ cell = row.find('td', attrs={'data-project-field': 'name'})
+ url = cell.find('a')['href']
+ expected_url = reverse('projectbuilds', args=(self.default_project.id,))
+ self.assertEqual(url, expected_url,
+ 'link on default project name should point to builds')
+
+ # link for other project
+ row = soup.find('tr', attrs={'data-project': self.project.id})
+ cell = row.find('td', attrs={'data-project-field': 'name'})
+ url = cell.find('a')['href']
+ expected_url = reverse('project', args=(self.project.id,))
+ self.assertEqual(url, expected_url,
+ 'link on project name should point to configuration')
+
class ProjectBuildsPageTests(TestCase):
""" Test data at /project/X/builds is displayed correctly """
@@ -650,7 +682,7 @@ class ProjectBuildsPageTests(TestCase):
self.assertEqual(len(result), 2)
class AllBuildsPageTests(TestCase):
- """ Tests for all builds page """
+ """ Tests for all builds page /builds/ """
def setUp(self):
bbv = BitbakeVersion.objects.create(name="bbv1", giturl="/tmp/",
--
2.1.4
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 05/10] toaster: Hide tabs and add info popups for command line builds
2015-10-07 13:20 [PATCH 00/10] toaster: Implement UI changes for "command line builds" project Ed Bartosh
` (3 preceding siblings ...)
2015-10-07 13:20 ` [PATCH 04/10] toaster: Make the builds view the project page for "command line builds" Ed Bartosh
@ 2015-10-07 13:20 ` Ed Bartosh
2015-10-07 13:20 ` [PATCH 06/10] toaster: Show tooltip next to cli builds project name in all builds Ed Bartosh
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Ed Bartosh @ 2015-10-07 13:20 UTC (permalink / raw)
To: bitbake-devel
From: Elliot Smith <elliot.smith@intel.com>
Command line builds don't have a configuration or
layers which can be modified through Toaster.
Change the project builds page for the command line builds project,
to hide the tabs and add some info popups in appropriate places on
that page.
[YOCTO #8231]
Signed-off-by: Elliot Smith <elliot.smith@intel.com>
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
lib/toaster/toastergui/static/js/base.js | 12 ++--
lib/toaster/toastergui/templates/mrb_section.html | 4 ++
.../toastergui/templates/projecttopbar.html | 80 ++++++++++++----------
lib/toaster/toastergui/tests.py | 41 +++++++++++
4 files changed, 94 insertions(+), 43 deletions(-)
diff --git a/lib/toaster/toastergui/static/js/base.js b/lib/toaster/toastergui/static/js/base.js
index 895e61b..6042a96 100644
--- a/lib/toaster/toastergui/static/js/base.js
+++ b/lib/toaster/toastergui/static/js/base.js
@@ -6,6 +6,7 @@ function basePageInit(ctx) {
var newBuildTargetInput;
var newBuildTargetBuildBtn;
var projectNameForm = $("#project-name-change-form");
+ var projectNameContainer = $("#project-name-container");
var projectName = $("#project-name");
var projectNameFormToggle = $("#project-change-form-toggle");
var projectNameChangeCancel = $("#project-name-change-cancel");
@@ -23,24 +24,21 @@ function basePageInit(ctx) {
/* Project name change functionality */
projectNameFormToggle.click(function(e){
e.preventDefault();
-
- $(this).add(projectName).hide();
+ projectNameContainer.hide();
projectNameForm.fadeIn();
});
projectNameChangeCancel.click(function(e){
e.preventDefault();
-
projectNameForm.hide();
- projectName.add(projectNameFormToggle).fadeIn();
+ projectNameContainer.fadeIn();
});
$("#project-name-change-btn").click(function(e){
var newProjectName = $("#project-name-change-input").val();
- libtoaster.editCurrentProject({ projectName: newProjectName },function (){
-
- projectName.text(newProjectName);
+ libtoaster.editCurrentProject({ projectName: newProjectName }, function (){
+ projectName.html(newProjectName);
libtoaster.ctx.projectName = newProjectName;
projectNameChangeCancel.click();
});
diff --git a/lib/toaster/toastergui/templates/mrb_section.html b/lib/toaster/toastergui/templates/mrb_section.html
index b29f650..53f40d0 100644
--- a/lib/toaster/toastergui/templates/mrb_section.html
+++ b/lib/toaster/toastergui/templates/mrb_section.html
@@ -8,6 +8,10 @@
{%if mrb_type == 'project' %}
<h2>
Latest project builds
+
+ {% if project.is_default %}
+ <i class="icon-question-sign get-help heading-help" title="" data-original-title="Builds in this project cannot be started from Toaster: they are started from the command line"></i>
+ {% endif %}
</h2>
{% else %}
<div class="page-header">
diff --git a/lib/toaster/toastergui/templates/projecttopbar.html b/lib/toaster/toastergui/templates/projecttopbar.html
index a3d1b88..ee86b54 100644
--- a/lib/toaster/toastergui/templates/projecttopbar.html
+++ b/lib/toaster/toastergui/templates/projecttopbar.html
@@ -5,8 +5,14 @@
<!-- project name -->
<div class="page-header">
- <h1><span id="project-name">{{project.name}}</span>
+ <h1 id="project-name-container">
+ <span id="project-name">{{project.name}}</span>
+
<i class="icon-pencil" data-original-title="" id="project-change-form-toggle" title=""></i>
+
+ {% if project.is_default %}
+ <i class="icon-question-sign get-help heading-help" title="" data-original-title="This project shows information about the builds you start from the command line while Toaster is running"></i>
+ {% endif %}
</h1>
<form id="project-name-change-form" style="margin-bottom: 0px; display: none;">
<div class="input-append">
@@ -17,38 +23,40 @@
</form>
</div>
-<div id="project-topbar">
- <ul class="nav nav-pills">
- <li>
- <a href="{% url 'projectbuilds' project.id %}">
- Builds (<span class="total-builds">0</span>)
- </a>
- </li>
- <li id="topbar-configuration-tab">
- <a href="{% url 'project' project.id %}">
- Configuration
- </a>
- </li>
- <li>
- <a href="{% url 'importlayer' project.id %}">
- Import layer
- </a>
- </li>
- {% if CUSTOM_IMAGE %}
- <li>
- <a href="{% url 'newcustomimage' project.id %}">
- New custom image
- </a>
- </li>
- {% endif %}
- <li class="pull-right">
- <form class="form-inline" style="margin-bottom:0px;">
- <i class="icon-question-sign get-help heading-help" data-placement="left" title="" data-original-title="Type the name of one or more recipes you want to build, separated by a space. You can also specify a task by appending a semicolon and a task name to the recipe name, like so: <code>busybox:clean</code>"></i>
- <div class="input-append">
- <input id="build-input" type="text" class="input-xlarge input-lg build-target-input" placeholder="Type the recipe you want to build" autocomplete="off" disabled>
- <button id="build-button" class="btn btn-primary btn-large build-button" data-project-id="{{project.id}}" disabled>Build</button>
- </div>
- </form>
- </li>
- </ul>
-</div>
+{% if not project.is_default %}
+ <div id="project-topbar">
+ <ul class="nav nav-pills">
+ <li>
+ <a href="{% url 'projectbuilds' project.id %}">
+ Builds (<span class="total-builds">0</span>)
+ </a>
+ </li>
+ <li id="topbar-configuration-tab">
+ <a href="{% url 'project' project.id %}">
+ Configuration
+ </a>
+ </li>
+ <li>
+ <a href="{% url 'importlayer' project.id %}">
+ Import layer
+ </a>
+ </li>
+ {% if CUSTOM_IMAGE %}
+ <li>
+ <a href="{% url 'newcustomimage' project.id %}">
+ New custom image
+ </a>
+ </li>
+ {% endif %}
+ <li class="pull-right">
+ <form class="form-inline" style="margin-bottom:0px;">
+ <i class="icon-question-sign get-help heading-help" data-placement="left" title="" data-original-title="Type the name of one or more recipes you want to build, separated by a space. You can also specify a task by appending a semicolon and a task name to the recipe name, like so: <code>busybox:clean</code>"></i>
+ <div class="input-append">
+ <input id="build-input" type="text" class="input-xlarge input-lg build-target-input" placeholder="Type the recipe you want to build" autocomplete="off" disabled>
+ <button id="build-button" class="btn btn-primary btn-large build-button" data-project-id="{{project.id}}" disabled>Build</button>
+ </div>
+ </form>
+ </li>
+ </ul>
+ </div>
+{% endif %}
diff --git a/lib/toaster/toastergui/tests.py b/lib/toaster/toastergui/tests.py
index 12a91c3..0d56ab2 100644
--- a/lib/toaster/toastergui/tests.py
+++ b/lib/toaster/toastergui/tests.py
@@ -596,8 +596,18 @@ class ProjectBuildsPageTests(TestCase):
bitbake_version=bbv)
self.project1 = Project.objects.create_project(name=PROJECT_NAME,
release=release)
+ self.project1.save()
+
self.project2 = Project.objects.create_project(name=PROJECT_NAME,
release=release)
+ self.project2.save()
+
+ self.default_project = Project.objects.create_project(
+ name=CLI_BUILDS_PROJECT_NAME,
+ release=release
+ )
+ self.default_project.is_default = True
+ self.default_project.save()
# parameters for builds to associate with the projects
now = timezone.now()
@@ -630,6 +640,13 @@ class ProjectBuildsPageTests(TestCase):
"outcome": Build.IN_PROGRESS
}
+ self.default_project_build_success = {
+ "project": self.default_project,
+ "started_on": now,
+ "completed_on": now,
+ "outcome": Build.SUCCEEDED
+ }
+
def _get_rows_for_project(self, project_id):
""" Helper to retrieve HTML rows for a project """
url = reverse("projectbuilds", args=(project_id,))
@@ -681,6 +698,30 @@ class ProjectBuildsPageTests(TestCase):
result = re.findall('^ +bash:clean$', response.content, re.MULTILINE)
self.assertEqual(len(result), 2)
+ def test_cli_builds_hides_tabs(self):
+ """
+ Display for command line builds should hide tabs;
+ note that the latest builds section is already tested in
+ AllBuildsPageTests, as the template is the same
+ """
+ url = reverse("projectbuilds", args=(self.default_project.id,))
+ response = self.client.get(url, follow=True)
+ soup = BeautifulSoup(response.content)
+ tabs = soup.select('#project-topbar')
+ self.assertEqual(len(tabs), 0,
+ 'should be no top bar shown for command line builds')
+
+ def test_non_cli_builds_has_tabs(self):
+ """
+ Non-command-line builds projects should show the tabs
+ """
+ url = reverse("projectbuilds", args=(self.project1.id,))
+ response = self.client.get(url, follow=True)
+ soup = BeautifulSoup(response.content)
+ tabs = soup.select('#project-topbar')
+ self.assertEqual(len(tabs), 1,
+ 'should be a top bar shown for non-command-line builds')
+
class AllBuildsPageTests(TestCase):
""" Tests for all builds page /builds/ """
--
2.1.4
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 06/10] toaster: Show tooltip next to cli builds project name in all builds
2015-10-07 13:20 [PATCH 00/10] toaster: Implement UI changes for "command line builds" project Ed Bartosh
` (4 preceding siblings ...)
2015-10-07 13:20 ` [PATCH 05/10] toaster: Hide tabs and add info popups for command line builds Ed Bartosh
@ 2015-10-07 13:20 ` Ed Bartosh
2015-10-07 13:20 ` [PATCH 07/10] toaster: More linting of tests Ed Bartosh
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Ed Bartosh @ 2015-10-07 13:20 UTC (permalink / raw)
To: bitbake-devel
From: Elliot Smith <elliot.smith@intel.com>
In the all builds page, show an icon with tooltip next to the
command line builds project name.
[YOCTO #8231]
Signed-off-by: Elliot Smith <elliot.smith@intel.com>
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
lib/toaster/toastergui/templates/builds.html | 11 ++++---
lib/toaster/toastergui/templates/mrb_section.html | 2 +-
lib/toaster/toastergui/tests.py | 37 ++++++++++++++++++++---
3 files changed, 40 insertions(+), 10 deletions(-)
diff --git a/lib/toaster/toastergui/templates/builds.html b/lib/toaster/toastergui/templates/builds.html
index 6fbaf98..566c279 100644
--- a/lib/toaster/toastergui/templates/builds.html
+++ b/lib/toaster/toastergui/templates/builds.html
@@ -63,10 +63,10 @@
{% include "basetable_top.html" %}
<!-- Table data rows; the order needs to match the order of "tablecols" definitions; and the <td class value needs to match the tablecols clclass value for show/hide buttons to work -->
{% for build in objects %}
- <tr class="data">
+ <tr class="data" data-table-build-result="{{ build.id }}">
<td class="outcome">
- <a href="{% url "builddashboard" build.id %}">{%if build.outcome == build.SUCCEEDED%}<i class="icon-ok-sign success"></i>{%elif build.outcome == build.FAILED%}<i class="icon-minus-sign error"></i>{%else%}{%endif%}</a>
- </td>
+ <a href="{% url "builddashboard" build.id %}">{%if build.outcome == build.SUCCEEDED%}<i class="icon-ok-sign success"></i>{%elif build.outcome == build.FAILED%}<i class="icon-minus-sign error"></i>{%else%}{%endif%}</a>
+ </td>
<td class="target">
{% for t in build.target_set.all %}
<a href="{% url "builddashboard" build.id %}">
@@ -104,8 +104,11 @@
<a href="{%url "builddashboard" build.id%}#images">{{fstypes|get_dict_value:build.id}}</a>
{% endif %}
</td>
- <td>
+ <td class="project-name">
<a href="{% project_url build.project %}">{{build.project.name}}</a>
+ {% if build.project.is_default %}
+ <i class="icon-question-sign get-help hover-help" title="" data-original-title="This project shows information about the builds you start from the command line while Toaster is running" style="visibility: hidden;"></i>
+ {% endif %}
</td>
</tr>
diff --git a/lib/toaster/toastergui/templates/mrb_section.html b/lib/toaster/toastergui/templates/mrb_section.html
index 53f40d0..55687a1 100644
--- a/lib/toaster/toastergui/templates/mrb_section.html
+++ b/lib/toaster/toastergui/templates/mrb_section.html
@@ -22,7 +22,7 @@
{% endif %}
<div id="latest-builds">
{% for build in mru %}
- <div id="build-result-{{ build.id }}" class="alert build-result {%if build.outcome == build.SUCCEEDED%}alert-success{%elif build.outcome == build.FAILED%}alert-error{%else%}alert-info{%endif%}
+ <div data-latest-build-result="{{ build.id }}" class="alert build-result {%if build.outcome == build.SUCCEEDED%}alert-success{%elif build.outcome == build.FAILED%}alert-error{%else%}alert-info{%endif%}
{% if mrb_type != 'project' %}
project-name">
<span class="label {%if build.outcome == build.SUCCEEDED%}label-success{%elif build.outcome == build.FAILED%}label-important{%else%}label-info{%endif%}">
diff --git a/lib/toaster/toastergui/tests.py b/lib/toaster/toastergui/tests.py
index 0d56ab2..1e67d1a 100644
--- a/lib/toaster/toastergui/tests.py
+++ b/lib/toaster/toastergui/tests.py
@@ -760,7 +760,7 @@ class AllBuildsPageTests(TestCase):
""" Task should be shown as suffix on build name """
build = Build.objects.create(**self.project1_build_success)
Target.objects.create(build=build, target='bash', task='clean')
- url = reverse("all-builds")
+ url = reverse('all-builds')
response = self.client.get(url, follow=True)
result = re.findall('bash:clean', response.content, re.MULTILINE)
self.assertEqual(len(result), 3)
@@ -768,17 +768,44 @@ class AllBuildsPageTests(TestCase):
def test_no_run_again_for_cli_build(self):
""" "Run again" button should not be shown for command-line builds """
build = Build.objects.create(**self.default_project_build_success)
- url = reverse("all-builds")
+ url = reverse('all-builds')
response = self.client.get(url, follow=True)
soup = BeautifulSoup(response.content)
- element_id = 'build-result-%d' % build.id
+ attrs = {'data-latest-build-result': build.id}
+ result = soup.find('div', attrs=attrs)
# shouldn't see a run again button for command-line builds
- run_again_button = soup.select('#%s button' % element_id)
+ run_again_button = result.select('button')
self.assertEqual(len(run_again_button), 0)
# should see a help icon for command-line builds
- help_icon = soup.select('#%s i.get-help-green' % element_id)
+ help_icon = result.select('i.get-help-green')
self.assertEqual(len(help_icon), 1)
+ def test_tooltips_on_project_name(self):
+ """
+ A tooltip should be present next to the command line
+ builds project name in the all builds page, but not for
+ other projects
+ """
+ build1 = Build.objects.create(**self.project1_build_success)
+ default_build = Build.objects.create(**self.default_project_build_success)
+
+ url = reverse('all-builds')
+ response = self.client.get(url, follow=True)
+ soup = BeautifulSoup(response.content)
+
+ # no help icon on non-default project name
+ result = soup.find('tr', attrs={'data-table-build-result': build1.id})
+ name = result.select('td.project-name')[0]
+ icons = name.select('i.get-help')
+ self.assertEqual(len(icons), 0,
+ 'should not be a help icon for non-cli builds name')
+
+ # help icon on default project name
+ result = soup.find('tr', attrs={'data-table-build-result': default_build.id})
+ name = result.select('td.project-name')[0]
+ icons = name.select('i.get-help')
+ self.assertEqual(len(icons), 1,
+ 'should be a help icon for cli builds name')
--
2.1.4
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 07/10] toaster: More linting of tests
2015-10-07 13:20 [PATCH 00/10] toaster: Implement UI changes for "command line builds" project Ed Bartosh
` (5 preceding siblings ...)
2015-10-07 13:20 ` [PATCH 06/10] toaster: Show tooltip next to cli builds project name in all builds Ed Bartosh
@ 2015-10-07 13:20 ` Ed Bartosh
2015-10-07 13:20 ` [PATCH 08/10] toaster: Clean up template code Ed Bartosh
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Ed Bartosh @ 2015-10-07 13:20 UTC (permalink / raw)
To: bitbake-devel
From: Elliot Smith <elliot.smith@intel.com>
Fix some more lint errors on the tests for toastergui.
Signed-off-by: Elliot Smith <elliot.smith@intel.com>
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
lib/toaster/toastergui/tests.py | 35 ++++++++++++++---------------------
1 file changed, 14 insertions(+), 21 deletions(-)
diff --git a/lib/toaster/toastergui/tests.py b/lib/toaster/toastergui/tests.py
index 1e67d1a..7078c9a 100644
--- a/lib/toaster/toastergui/tests.py
+++ b/lib/toaster/toastergui/tests.py
@@ -433,6 +433,18 @@ class AllProjectsPageTests(TestCase):
MACHINE_NAME = 'delorean'
+ def setUp(self):
+ """ Add default project manually """
+ project = Project.objects.create_project(CLI_BUILDS_PROJECT_NAME, None)
+ self.default_project = project
+ self.default_project.is_default = True
+ self.default_project.save()
+
+ # this project is only set for some of the tests
+ self.project = None
+
+ self.release = None
+
def _add_build_to_default_project(self):
""" Add a build to the default project (not used in all tests) """
now = timezone.now()
@@ -458,16 +470,6 @@ class AllProjectsPageTests(TestCase):
value=self.MACHINE_NAME)
project_var.save()
- def setUp(self):
- """ Add default project manually """
- project = Project.objects.create_project(CLI_BUILDS_PROJECT_NAME, None)
- self.default_project = project
- self.default_project.is_default = True
- self.default_project.save()
-
- # this project is only set for some of the tests
- self.project = None
-
def test_default_project_hidden(self):
""" The default project should be hidden if it has no builds """
params = {"count": 10, "orderby": "updated:-", "page": 1}
@@ -573,17 +575,15 @@ class AllProjectsPageTests(TestCase):
# link for default project
row = soup.find('tr', attrs={'data-project': self.default_project.id})
cell = row.find('td', attrs={'data-project-field': 'name'})
- url = cell.find('a')['href']
expected_url = reverse('projectbuilds', args=(self.default_project.id,))
- self.assertEqual(url, expected_url,
+ self.assertEqual(cell.find('a')['href'], expected_url,
'link on default project name should point to builds')
# link for other project
row = soup.find('tr', attrs={'data-project': self.project.id})
cell = row.find('td', attrs={'data-project-field': 'name'})
- url = cell.find('a')['href']
expected_url = reverse('project', args=(self.project.id,))
- self.assertEqual(url, expected_url,
+ self.assertEqual(cell.find('a')['href'], expected_url,
'link on project name should point to configuration')
class ProjectBuildsPageTests(TestCase):
@@ -640,13 +640,6 @@ class ProjectBuildsPageTests(TestCase):
"outcome": Build.IN_PROGRESS
}
- self.default_project_build_success = {
- "project": self.default_project,
- "started_on": now,
- "completed_on": now,
- "outcome": Build.SUCCEEDED
- }
-
def _get_rows_for_project(self, project_id):
""" Helper to retrieve HTML rows for a project """
url = reverse("projectbuilds", args=(project_id,))
--
2.1.4
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 08/10] toaster: Clean up template code
2015-10-07 13:20 [PATCH 00/10] toaster: Implement UI changes for "command line builds" project Ed Bartosh
` (6 preceding siblings ...)
2015-10-07 13:20 ` [PATCH 07/10] toaster: More linting of tests Ed Bartosh
@ 2015-10-07 13:20 ` Ed Bartosh
2015-10-07 13:20 ` [PATCH 09/10] toaster: Exclude "command line builds" project from projects typeahead Ed Bartosh
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Ed Bartosh @ 2015-10-07 13:20 UTC (permalink / raw)
To: bitbake-devel
From: Elliot Smith <elliot.smith@intel.com>
Some errors in the HTML template didn't show up until
they were rendering command line builds.
One useless conditional was lingering in another template.
Clean up these issues to display the latest builds section
correctly.
Signed-off-by: Elliot Smith <elliot.smith@intel.com>
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
lib/toaster/toastergui/templates/builds.html | 5 -----
lib/toaster/toastergui/templates/mrb_section.html | 21 ++++++++++-----------
2 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/lib/toaster/toastergui/templates/builds.html b/lib/toaster/toastergui/templates/builds.html
index 566c279..459fcb0 100644
--- a/lib/toaster/toastergui/templates/builds.html
+++ b/lib/toaster/toastergui/templates/builds.html
@@ -29,8 +29,6 @@
{% include "mrb_section.html" %}
-
- {% if 1 %}
<div class="page-header top-air">
<h1>
{% if request.GET.filter and objects.paginator.count > 0 or request.GET.search and objects.paginator.count > 0 %}
@@ -57,8 +55,6 @@
</form>
</div>
</div>
-
-
{% else %}
{% include "basetable_top.html" %}
<!-- Table data rows; the order needs to match the order of "tablecols" definitions; and the <td class value needs to match the tablecols clclass value for show/hide buttons to work -->
@@ -117,7 +113,6 @@
{% include "basetable_bottom.html" %}
{% endif %} {# objects.paginator.count #}
-{% endif %} {# empty #}
</div><!-- end row-fluid-->
{% endblock %}
diff --git a/lib/toaster/toastergui/templates/mrb_section.html b/lib/toaster/toastergui/templates/mrb_section.html
index 55687a1..bd8f991 100644
--- a/lib/toaster/toastergui/templates/mrb_section.html
+++ b/lib/toaster/toastergui/templates/mrb_section.html
@@ -22,19 +22,18 @@
{% endif %}
<div id="latest-builds">
{% for build in mru %}
- <div data-latest-build-result="{{ build.id }}" class="alert build-result {%if build.outcome == build.SUCCEEDED%}alert-success{%elif build.outcome == build.FAILED%}alert-error{%else%}alert-info{%endif%}
- {% if mrb_type != 'project' %}
- project-name">
- <span class="label {%if build.outcome == build.SUCCEEDED%}label-success{%elif build.outcome == build.FAILED%}label-important{%else%}label-info{%endif%}">
- <a href={% project_url build.project %}>
- {{build.project.name}}
- </a>
- </span>
- {% endif %}
+ <div data-latest-build-result="{{ build.id }}" class="alert build-result {%if build.outcome == build.SUCCEEDED%}alert-success{%elif build.outcome == build.FAILED%}alert-error{%else%}alert-info{%endif%}{% if mrb_type != 'project' %} project-name{% endif %}">
+ {% if mrb_type != 'project' %}
+ <span class="label {%if build.outcome == build.SUCCEEDED%}label-success{%elif build.outcome == build.FAILED%}label-important{%else%}label-info{%endif%}">
+ <a href={% project_url build.project %}>
+ {{build.project.name}}
+ </a>
+ </span>
+ {% endif %}
<div class="row-fluid">
- <div class="span3 lead">
+ <div class="span3 lead">
{%if build.outcome == build.SUCCEEDED or build.outcome == build.FAILED %}
- <a href="{%url 'builddashboard' build.pk%}" class="{%if build.outcome == build.SUCCEEDED %}success{%else%}error{%endif%}">
+ <a href="{%url 'builddashboard' build.pk%}" class="{%if build.outcome == build.SUCCEEDED %}success{%else%}error{%endif%}">
{% endif %}
{% if build.target_set.all.count > 0 %}
<span data-toggle="tooltip"
--
2.1.4
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 09/10] toaster: Exclude "command line builds" project from projects typeahead
2015-10-07 13:20 [PATCH 00/10] toaster: Implement UI changes for "command line builds" project Ed Bartosh
` (7 preceding siblings ...)
2015-10-07 13:20 ` [PATCH 08/10] toaster: Clean up template code Ed Bartosh
@ 2015-10-07 13:20 ` Ed Bartosh
2015-10-07 13:20 ` [PATCH 10/10] toaster: Modify "New build" button behaviour for cli builds project Ed Bartosh
2015-10-11 7:15 ` [PATCH 00/10] toaster: Implement UI changes for "command line builds" project Richard Purdie
10 siblings, 0 replies; 12+ messages in thread
From: Ed Bartosh @ 2015-10-07 13:20 UTC (permalink / raw)
To: bitbake-devel
From: Elliot Smith <elliot.smith@intel.com>
The "New build" drop-down provides autocomplete for Toaster projects.
However, it should not include the default project (for command
line builds), as it should not be possible for the user to
select this project as the container for a Toaster build.
[YOCTO #8231]
Signed-off-by: Elliot Smith <elliot.smith@intel.com>
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
lib/toaster/toastergui/typeaheads.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/toaster/toastergui/typeaheads.py b/lib/toaster/toastergui/typeaheads.py
index 9db3182..dd4b7f5 100644
--- a/lib/toaster/toastergui/typeaheads.py
+++ b/lib/toaster/toastergui/typeaheads.py
@@ -121,12 +121,12 @@ class RecipesTypeAhead(ToasterTypeAhead):
return results
class ProjectsTypeAhead(ToasterTypeAhead):
- """ Typeahead for all the projects """
+ """ Typeahead for all the projects, except for command line builds """
def __init__(self):
super(ProjectsTypeAhead, self).__init__()
def apply_search(self, search_term, prj, request):
- projects = Project.objects.all().order_by("name")
+ projects = Project.objects.exclude(is_default=True).order_by("name")
primary_results = projects.filter(name__istartswith=search_term)
secondary_results = projects.filter(name__icontains=search_term).exclude(pk__in=primary_results)
--
2.1.4
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 10/10] toaster: Modify "New build" button behaviour for cli builds project
2015-10-07 13:20 [PATCH 00/10] toaster: Implement UI changes for "command line builds" project Ed Bartosh
` (8 preceding siblings ...)
2015-10-07 13:20 ` [PATCH 09/10] toaster: Exclude "command line builds" project from projects typeahead Ed Bartosh
@ 2015-10-07 13:20 ` Ed Bartosh
2015-10-11 7:15 ` [PATCH 00/10] toaster: Implement UI changes for "command line builds" project Richard Purdie
10 siblings, 0 replies; 12+ messages in thread
From: Ed Bartosh @ 2015-10-07 13:20 UTC (permalink / raw)
To: bitbake-devel
From: Elliot Smith <elliot.smith@intel.com>
The "New build" button should only be displayed if there are
user-generated projects, not if there is only the command-line
builds project. (Toaster can't run builds on behalf of the
command-line builds project.)
The "New build" form should also display as if no project has
been set (i.e. show the project and recipe text entries).
Add a variable which tracks the number of non-command-line projects,
then use this to hide the button when appropriate.
Also track whether the current project is the default one, and
use this to add extra conditions to when the "New build" text
entries are shown.
[YOCTO #8231]
Signed-off-by: Elliot Smith <elliot.smith@intel.com>
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
lib/toaster/toastergui/static/js/base.js | 6 +-
lib/toaster/toastergui/templates/base.html | 95 +++++++++++++++---------------
lib/toaster/toastergui/views.py | 9 ++-
3 files changed, 59 insertions(+), 51 deletions(-)
diff --git a/lib/toaster/toastergui/static/js/base.js b/lib/toaster/toastergui/static/js/base.js
index 6042a96..ed22a4e 100644
--- a/lib/toaster/toastergui/static/js/base.js
+++ b/lib/toaster/toastergui/static/js/base.js
@@ -121,14 +121,14 @@ function basePageInit(ctx) {
});
function _checkProjectBuildable() {
- if (selectedProject.projectId === undefined) {
+ if (selectedProject.projectId === undefined || selectedProject.projectIsDefault) {
return;
}
libtoaster.getProjectInfo(selectedProject.projectPageUrl,
function (data) {
if (data.machine === null || data.machine.name === undefined || data.layers.length === 0) {
- /* we can't build anything with out a machine and some layers */
+ /* we can't build anything without a machine and some layers */
$("#new-build-button #targets-form").hide();
$("#new-build-button .alert").show();
} else {
@@ -147,7 +147,7 @@ function basePageInit(ctx) {
/* If we don't have a current project then present the set project
* form.
*/
- if (selectedProject.projectId === undefined) {
+ if (selectedProject.projectId === undefined || selectedProject.projectIsDefault) {
$('#change-project-form').show();
$('#project .icon-pencil').hide();
}
diff --git a/lib/toaster/toastergui/templates/base.html b/lib/toaster/toastergui/templates/base.html
index 3f27790..c1d0693 100644
--- a/lib/toaster/toastergui/templates/base.html
+++ b/lib/toaster/toastergui/templates/base.html
@@ -38,6 +38,7 @@
projectId : {{project.id}},
projectPageUrl : {% url 'project' project.id as purl %}{{purl|json}},
projectName : {{project.name|json}},
+ projectIsDefault: {% if project.is_default %}true{% else %}false{% endif %},
recipesTypeAheadUrl: {% url 'xhr_recipestypeahead' project.id as paturl%}{{paturl|json}},
layersTypeAheadUrl: {% url 'xhr_layerstypeahead' project.id as paturl%}{{paturl|json}},
machinesTypeAheadUrl: {% url 'xhr_machinestypeahead' project.id as paturl%}{{paturl|json}},
@@ -48,7 +49,7 @@
projectId : undefined,
projectPageUrl : undefined,
projectName : undefined,
- projectId : undefined,
+ projectIsDefault: false,
{% endif %}
};
</script>
@@ -122,52 +123,54 @@
<div class="btn-group pull-right">
<a class="btn" id="new-project-button" href="{% url 'newproject' %}">New project</a>
</div>
- <!-- New build popover -->
- <div class="btn-group pull-right" id="new-build-button" style="display:none">
- <button class="btn dropdown-toggle" data-toggle="dropdown">
- New build
- <i class="icon-caret-down"></i>
- </button>
- <ul class="dropdown-menu new-build multi-select">
- <li>
- <h3>New build</h3>
- <h6>Project:</h6>
- <span id="project">
- {% if project.id %}
- <a class="lead" href="{% project_url project %}">{{project.name}}</a>
- {% else %}
- <a class="lead" href="#"></a>
- {% endif %}
- <i class="icon-pencil"></i>
- </span>
- <form id="change-project-form" style="display:none;">
- <div class="input-append">
- <input type="text" class="input-medium" id="project-name-input" placeholder="Type a project name" autocomplete="off" data-minLength="1" data-autocomplete="off" data-provide="typeahead"/>
- <button id="save-project-button" class="btn" type="button">Save</button>
- <a href="#" id="cancel-change-project" class="btn btn-link" style="display: none">Cancel</a>
- </div>
- <p><a id="view-all-projects" href="{% url 'all-projects' %}">View all projects</a></p>
- </form>
- </li>
- <li>
- <div class="alert" style="display:none;">
- <p>This project configuration is incomplete, so you cannot run builds.</p>
- <p><a href="{% if project.id %}{% url 'project' project.id %}{% endif %}">View project configuration</a></p>
- </div>
- </li>
- <li id="targets-form">
- <h6>Recipe(s):</h6>
- <form>
- <input type="text" class="input-xlarge build-target-input" placeholder="Type a recipe name" autocomplete="off" data-minLength="1" data-autocomplete="off" data-provide="typeahead" disabled/>
- <div class="row-fluid">
- <button class="btn btn-primary build-button" disabled>Build</button>
+ <!-- New build popover; only shown if there is at least one user-created project -->
+ {% if non_cli_projects.count > 0 %}
+ <div class="btn-group pull-right" id="new-build-button" style="display:none">
+ <button class="btn dropdown-toggle" data-toggle="dropdown">
+ New build
+ <i class="icon-caret-down"></i>
+ </button>
+ <ul class="dropdown-menu new-build multi-select">
+ <li>
+ <h3>New build</h3>
+ <h6>
+ Project:
+ <span id="project">
+ {% if project.id and not project.is_default %}
+ <a class="lead" href="{% project_url project %}">{{project.name}}</a>
+ {% else %}
+ <a class="lead" href="#"></a>
+ {% endif %}
+ <i class="icon-pencil"></i>
+ </span>
+ </h6>
+ <form id="change-project-form" style="display:none;">
+ <div class="input-append">
+ <input type="text" class="input-medium" id="project-name-input" placeholder="Type a project name" autocomplete="off" data-minLength="1" data-autocomplete="off" data-provide="typeahead"/>
+ <button id="save-project-button" class="btn" type="button">Save</button>
+ <a href="#" id="cancel-change-project" class="btn btn-link" style="display: none">Cancel</a>
+ </div>
+ <p><a id="view-all-projects" href="{% url 'all-projects' %}">View all projects</a></p>
+ </form>
+ </li>
+ <li>
+ <div class="alert" style="display:none;">
+ <p>This project configuration is incomplete, so you cannot run builds.</p>
+ <p><a href="{% if project.id %}{% url 'project' project.id %}{% endif %}">View project configuration</a></p>
</div>
- </form>
- </li>
- </ul>
- </div>
-
-
+ </li>
+ <li id="targets-form">
+ <h6>Recipe(s):</h6>
+ <form>
+ <input type="text" class="input-xlarge build-target-input" placeholder="Type a recipe name" autocomplete="off" data-minLength="1" data-autocomplete="off" data-provide="typeahead" disabled/>
+ <div class="row-fluid">
+ <button class="btn btn-primary build-button" disabled>Build</button>
+ </div>
+ </form>
+ </li>
+ </ul>
+ </div>
+ {% endif %}
</div>
</div>
</div>
diff --git a/lib/toaster/toastergui/views.py b/lib/toaster/toastergui/views.py
index 468cce3..fe13ddf 100755
--- a/lib/toaster/toastergui/views.py
+++ b/lib/toaster/toastergui/views.py
@@ -1870,10 +1870,15 @@ def image_information_dir(request, build_id, target_id, packagefile_id):
return redirect(builds)
# the context processor that supplies data used across all the pages
-
+# a context processor which runs on every request; this provides the
+# projects and non_cli_projects (i.e. projects created by the user)
+# variables referred to in templates, which used to determine the
+# visibility of UI elements like the "New build" button
def managedcontextprocessor(request):
+ projects = Project.objects.all()
ret = {
- "projects": Project.objects.all(),
+ "projects": projects,
+ "non_cli_projects": projects.exclude(is_default=True),
"DEBUG" : toastermain.settings.DEBUG,
"CUSTOM_IMAGE" : toastermain.settings.CUSTOM_IMAGE,
"TOASTER_BRANCH": toastermain.settings.TOASTER_BRANCH,
--
2.1.4
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH 00/10] toaster: Implement UI changes for "command line builds" project
2015-10-07 13:20 [PATCH 00/10] toaster: Implement UI changes for "command line builds" project Ed Bartosh
` (9 preceding siblings ...)
2015-10-07 13:20 ` [PATCH 10/10] toaster: Modify "New build" button behaviour for cli builds project Ed Bartosh
@ 2015-10-11 7:15 ` Richard Purdie
10 siblings, 0 replies; 12+ messages in thread
From: Richard Purdie @ 2015-10-11 7:15 UTC (permalink / raw)
To: Ed Bartosh; +Cc: bitbake-devel
On Wed, 2015-10-07 at 16:20 +0300, Ed Bartosh wrote:
> This implements changes across the UI to hide irrelevant options
> for command-line builds, and show additional help icons explaining
> why those options are hidden.
>
> It also modifies the behaviour of the "New build" button to take
> account of the special status of the command-line builds project.
>
> For UI details, see the document attached to bug 8231
> at https://bugzilla.yoctoproject.org/attachment.cgi?id=2760.
Sadly this patch set is applied over patches which have not been sent to
the bitbake list, so they don't apply. Can you send a patch series which
applies on top of master please (or send the other patches if that makes
more sense).
Cheers,
Richard
^ permalink raw reply [flat|nested] 12+ messages in thread