diff options
author | Robert Kowalski <rok@kowalski.gd> | 2014-03-14 20:45:31 +0100 |
---|---|---|
committer | Robert Kowalski <rok@kowalski.gd> | 2014-03-14 20:45:43 +0100 |
commit | b8accb4eb7c46e3888416afc4aff407487f2f21c (patch) | |
tree | b7ac178345d7d501197ca204daff7aa451cfa177 | |
parent | a17bf86af27a2eb52e552360fecb5e74b6e5f582 (diff) | |
download | couchdb-b8accb4eb7c46e3888416afc4aff407487f2f21c.tar.gz |
Fauxton: highlight databases with more deleted docs than existing
Fixes COUCHDB-2110
4 files changed, 55 insertions, 1 deletions
diff --git a/src/fauxton/app/addons/databases/resources.js b/src/fauxton/app/addons/databases/resources.js index 80cd533f8..f8aab96fe 100644 --- a/src/fauxton/app/addons/databases/resources.js +++ b/src/fauxton/app/addons/databases/resources.js @@ -123,6 +123,14 @@ function(app, FauxtonAPI, Documents) { return this.get("doc_count"); }, + numDeletedDocs: function() { + return this.get("doc_del_count"); + }, + + isGraveYard: function() { + return this.numDeletedDocs() > this.numDocs(); + }, + updateSeq: function(full) { var updateSeq = this.get("update_seq"); if (full || (typeof(updateSeq) === 'number')) { diff --git a/src/fauxton/app/addons/databases/templates/item.html b/src/fauxton/app/addons/databases/templates/item.html index 549f42157..304ab7820 100644 --- a/src/fauxton/app/addons/databases/templates/item.html +++ b/src/fauxton/app/addons/databases/templates/item.html @@ -16,7 +16,13 @@ the License. <a href="#/database/<%=encoded%>/_all_docs"><%= database.get("name") %></a> </td> <td><%= database.status.humanSize() %></td> -<td><%= database.status.numDocs() %></td> +<td> + <%= database.status.numDocs() %> + <% if (database.status.isGraveYard()) { %> + <i class="js-db-graveyard icon icon-exclamation-sign" data-toggle="tooltip" + title="This database has just <%= database.status.numDocs() %> docs and <%= database.status.numDeletedDocs() %> deleted docs"></i> + <% } %> +</td> <td><%= database.status.updateSeq() %></td> <td> <a class="db-actions btn fonticon-replicate set-replication-start" title="Replicate <%= database.get("name") %>" href="#/replication/new/<%=encoded%>"></a> diff --git a/src/fauxton/app/addons/databases/tests/resourcesSpec.js b/src/fauxton/app/addons/databases/tests/resourcesSpec.js new file mode 100644 index 000000000..8e3fee4fb --- /dev/null +++ b/src/fauxton/app/addons/databases/tests/resourcesSpec.js @@ -0,0 +1,39 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. +define([ + 'api', + 'addons/databases/resources', + 'addons/databases/views', + 'testUtils' +], function (FauxtonAPI, Resources, Views, testUtils) { + var assert = testUtils.assert, + ViewSandbox = testUtils.ViewSandbox; + + describe("Databases: List", function () { + + describe("List items", function () { + + it("detects graveyards", function () { + var modelWithGraveYard = new Resources.Status({ + doc_count: 5, + doc_del_count: 6 + }); + var modelWithoutGraveYard = new Resources.Status({ + doc_count: 6, + doc_del_count: 5 + }); + assert.ok(modelWithGraveYard.isGraveYard()); + assert.ok(!modelWithoutGraveYard.isGraveYard()); + }); + }); + }); +}); diff --git a/src/fauxton/app/addons/databases/views.js b/src/fauxton/app/addons/databases/views.js index ef52b2f4f..d63248602 100644 --- a/src/fauxton/app/addons/databases/views.js +++ b/src/fauxton/app/addons/databases/views.js @@ -137,6 +137,7 @@ function(app, Components, FauxtonAPI, Databases) { } }); this.dbSearchTypeahead.render(); + this.$el.find(".js-db-graveyard").tooltip(); }, selectAll: function(evt){ |