You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2013/02/11 12:12:15 UTC
[10/50] [abbrv] git commit: Handle a null or empty database name
Handle a null or empty database name
If name is null then user cancelled the prompt so we
do nothing.
If name is zero length then display an error via
notifications.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/c585708f
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/c585708f
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/c585708f
Branch: refs/heads/fauxton
Commit: c585708f71ca4344abd0d51e86edecbc6ff16812
Parents: 08de3e7
Author: Mike Wallace <mi...@googlemail.com>
Authored: Sun Jan 20 22:26:48 2013 +0000
Committer: Mike Wallace <mi...@googlemail.com>
Committed: Mon Jan 21 13:12:10 2013 +0000
----------------------------------------------------------------------
src/fauxton/app/modules/databases/views.js | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/c585708f/src/fauxton/app/modules/databases/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/databases/views.js b/src/fauxton/app/modules/databases/views.js
index fafddc5..b069b85 100644
--- a/src/fauxton/app/modules/databases/views.js
+++ b/src/fauxton/app/modules/databases/views.js
@@ -98,13 +98,24 @@ function(app, FauxtonAPI) {
},
newDatabase: function() {
+ var notification;
// TODO: use a modal here instead of the prompt
var name = prompt('Name of database', 'newdatabase');
+ if (name === null) {
+ return;
+ } else if (name.length === 0) {
+ notification = FauxtonAPI.addNotification({
+ msg: "Please enter a valid database name",
+ type: "error",
+ clear: true
+ });
+ return;
+ }
var db = new this.collection.model({
id: encodeURIComponent(name),
name: name
});
- var notification = FauxtonAPI.addNotification({msg: "Creating database."});
+ notification = FauxtonAPI.addNotification({msg: "Creating database."});
db.save().done(function() {
notification = FauxtonAPI.addNotification({
msg: "Database created successfully",