Create an empty state for the "Project builds" page.
Signed-off-by: Michael Wood <[email protected]>
Signed-off-by: Belen Barros Pena <[email protected]>
---
bitbake/lib/toaster/toastergui/static/js/table.js | 24 ++++++++++++++--------
bitbake/lib/toaster/toastergui/tables.py | 8 ++++++++
.../templates/projectbuilds-toastertable.html | 15 +++++++++++---
.../toaster/toastergui/templates/toastertable.html | 4 ++++
bitbake/lib/toaster/toastergui/widgets.py | 3 ++-
5 files changed, 42 insertions(+), 12 deletions(-)
diff --git a/bitbake/lib/toaster/toastergui/static/js/table.js
b/bitbake/lib/toaster/toastergui/static/js/table.js
index 5e3171f..6888c71 100644
--- a/bitbake/lib/toaster/toastergui/static/js/table.js
+++ b/bitbake/lib/toaster/toastergui/static/js/table.js
@@ -75,14 +75,21 @@ function tableInit(ctx){
if (tableData.total === 0){
tableContainer.hide();
- if ($("#no-results-special-"+ctx.tableName).length > 0) {
- /* use this page's special no-results form instead of the default */
- $("#no-results-search-input-"+ctx.tableName).val(tableParams.search);
- $("#no-results-special-"+ctx.tableName).show();
- $("#results-found-"+ctx.tableName).hide();
- } else {
- $("#new-search-input-"+ctx.tableName).val(tableParams.search);
- $("#no-results-"+ctx.tableName).show();
+ /* No results caused by a search returning nothing */
+ if (tableParams.search) {
+ if ($("#no-results-special-"+ctx.tableName).length > 0) {
+ /* use this page's special no-results form instead of the default */
+ $("#no-results-search-input-"+ctx.tableName).val(tableParams.search);
+ $("#no-results-special-"+ctx.tableName).show();
+ $("#results-found-"+ctx.tableName).hide();
+ } else {
+ $("#new-search-input-"+ctx.tableName).val(tableParams.search);
+ $("#no-results-"+ctx.tableName).show();
+ }
+ }
+ else {
+ /* No results caused by there being no data */
+ $("#empty-state-"+ctx.tableName).show();
}
table.trigger("table-done", [tableData.total, tableParams]);
@@ -90,6 +97,7 @@ function tableInit(ctx){
} else {
tableContainer.show();
$("#no-results-"+ctx.tableName).hide();
+ $("#empty-state-"+ctx.tableName).hide();
}
setupTableChrome(tableData);
diff --git a/bitbake/lib/toaster/toastergui/tables.py
b/bitbake/lib/toaster/toastergui/tables.py
index bbdd258..d1906c1 100644
--- a/bitbake/lib/toaster/toastergui/tables.py
+++ b/bitbake/lib/toaster/toastergui/tables.py
@@ -1424,6 +1424,7 @@ class ProjectBuildsTable(BuildsTable):
super(ProjectBuildsTable, self).__init__(*args, **kwargs)
self.title = 'All project builds'
self.mrb_type = 'project'
+ self.empty_state = "This project has no builds"
# set from the querystring
self.project_id = None
@@ -1466,4 +1467,11 @@ class ProjectBuildsTable(BuildsTable):
context['mru'] = Build.get_recent(project)
context['project'] = project
+ self.setup_queryset(**kwargs)
+ if self.queryset.count() == 0 and \
+ project.build_set.filter(outcome=Build.IN_PROGRESS).count() > 0:
+ context['build_in_progress_none_completed'] = True
+ else:
+ context['build_in_progress_none_completed'] = False
+
return context
diff --git
a/bitbake/lib/toaster/toastergui/templates/projectbuilds-toastertable.html
b/bitbake/lib/toaster/toastergui/templates/projectbuilds-toastertable.html
index b9348eb..6d27668 100644
--- a/bitbake/lib/toaster/toastergui/templates/projectbuilds-toastertable.html
+++ b/bitbake/lib/toaster/toastergui/templates/projectbuilds-toastertable.html
@@ -24,8 +24,10 @@
<h2 class="top-air" data-role="page-title"></h2>
- {% url 'projectbuilds' project.id as xhr_table_url %}
- {% include 'toastertable.html' %}
+ {% if not build_in_progress_none_completed %}
+ {% url 'projectbuilds' project.id as xhr_table_url %}
+ {% include 'toastertable.html' %}
+ {% endif %}
</div>
<script>
@@ -46,7 +48,14 @@
}
}
- titleElt.text(title);
+ if (total === 0) {
+ titleElt.hide();
+ }
+ else {
+ titleElt.show()
+ titleElt.text(title);
+ }
+
});
// highlight builds tab
diff --git a/bitbake/lib/toaster/toastergui/templates/toastertable.html
b/bitbake/lib/toaster/toastergui/templates/toastertable.html
index 131b0b8..350dff3 100644
--- a/bitbake/lib/toaster/toastergui/templates/toastertable.html
+++ b/bitbake/lib/toaster/toastergui/templates/toastertable.html
@@ -25,6 +25,10 @@
{% include 'toastertable-filter.html' %}
+<div class="row-fluid" id="empty-state-{{table_name}}" style="display:none">
+ <div class="alert alert-info">{{empty_state}}</div>
+</div>
+
<div id="no-results-{{table_name}}" style="display:none">
<div class="alert">
<form class="no-results input-append">
diff --git a/bitbake/lib/toaster/toastergui/widgets.py
b/bitbake/lib/toaster/toastergui/widgets.py
index 4117031..c968830 100644
--- a/bitbake/lib/toaster/toastergui/widgets.py
+++ b/bitbake/lib/toaster/toastergui/widgets.py
@@ -75,7 +75,8 @@ class ToasterTable(TemplateView):
def get_context_data(self, **kwargs):
context = super(ToasterTable, self).get_context_data(**kwargs)
context['title'] = self.title
- context['table_name'] = type(self).__name__.lower()
+ context['table_name'] = type(self).__name__.lower()
+ context['empty_state'] = self.empty_state
return context
--
1.9.1
--
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster