diff --git a/ui/app/components/search-box.js b/ui/app/components/search-box.js index 8efb5dd5e..19aa76bef 100644 --- a/ui/app/components/search-box.js +++ b/ui/app/components/search-box.js @@ -12,7 +12,7 @@ export default Component.extend({ // Used to throttle sets to searchTerm debounce: 150, - classNames: ['field', 'has-addons'], + classNames: ['search-box', 'field', 'has-addons'], actions: { setSearchTerm(e) { diff --git a/ui/app/styles/components.scss b/ui/app/styles/components.scss index 7832c934d..50f6ef1c8 100644 --- a/ui/app/styles/components.scss +++ b/ui/app/styles/components.scss @@ -1,6 +1,7 @@ @import "./components/badge"; @import "./components/boxed-section"; @import "./components/breadcrumbs"; +@import "./components/empty-message"; @import "./components/gutter"; @import "./components/inline-definitions"; @import "./components/job-diff"; diff --git a/ui/app/styles/components/empty-message.scss b/ui/app/styles/components/empty-message.scss new file mode 100644 index 000000000..3f00021eb --- /dev/null +++ b/ui/app/styles/components/empty-message.scss @@ -0,0 +1,21 @@ +.empty-message { + padding: 1.5rem; + background: $white-ter; + border-radius: $radius; + + .empty-message-headline { + font-size: $size-3; + color: $grey; + text-align: center; + } + + .empty-message-body { + padding: 0 20%; + text-align: center; + color: $grey; + + strong { + color: $grey; + } + } +} diff --git a/ui/app/templates/jobs/index.hbs b/ui/app/templates/jobs/index.hbs index 4ab6544fe..e5a57b38c 100644 --- a/ui/app/templates/jobs/index.hbs +++ b/ui/app/templates/jobs/index.hbs @@ -3,9 +3,11 @@ {{/global-header}} {{#gutter-menu class="page-body"}}
-
-
{{search-box searchTerm=(mut searchTerm) placeholder="Search jobs..."}}
-
+ {{#if model.length}} +
+
{{search-box searchTerm=(mut searchTerm) placeholder="Search jobs..."}}
+
+ {{/if}} {{#list-pagination source=sortedJobs size=pageSize @@ -37,6 +39,18 @@ + {{else}} +
+ {{#if (eq model.length 0)}} +

No Jobs

+

+ There are currently no visible jobs in the cluster. It could be that the cluster is empty. It could also mean {{#link-to "settings.tokens"}}you don't have access to see any jobs{{/link-to}}. +

+ {{else if searchTerm}} +

No Matches

+

No jobs match the term {{searchTerm}}

+ {{/if}} +
{{/list-pagination}}
{{/gutter-menu}} diff --git a/ui/tests/acceptance/jobs-list-test.js b/ui/tests/acceptance/jobs-list-test.js index 699739fe4..36f0fb576 100644 --- a/ui/tests/acceptance/jobs-list-test.js +++ b/ui/tests/acceptance/jobs-list-test.js @@ -1,5 +1,5 @@ import Ember from 'ember'; -import { click, findAll, currentURL, visit } from 'ember-native-dom-helpers'; +import { click, find, findAll, currentURL, visit, fillIn } from 'ember-native-dom-helpers'; import { test } from 'qunit'; import moduleForAcceptance from 'nomad-ui/tests/helpers/module-for-acceptance'; @@ -80,3 +80,30 @@ test('each job row should link to the corresponding job', function(assert) { assert.equal(currentURL(), `/jobs/${job.id}`); }); }); + +test('when there are no jobs, there is an empty message', function(assert) { + visit('/jobs'); + + andThen(() => { + assert.ok(find('.empty-message')); + assert.equal(find('.empty-message-headline').textContent, 'No Jobs'); + }); +}); + +test('when there are jobs, but no matches for a search result, there is an empty message', function( + assert +) { + server.create('job', { name: 'cat 1' }); + server.create('job', { name: 'cat 2' }); + + visit('/jobs'); + + andThen(() => { + fillIn('.search-box input', 'dog'); + }); + + andThen(() => { + assert.ok(find('.empty-message')); + assert.equal(find('.empty-message-headline').textContent, 'No Matches'); + }); +});