Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EBDC4E8CE for ; Mon, 11 Feb 2013 11:12:30 +0000 (UTC) Received: (qmail 55369 invoked by uid 500); 11 Feb 2013 11:12:30 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 54666 invoked by uid 500); 11 Feb 2013 11:12:29 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 48500 invoked by uid 99); 11 Feb 2013 11:12:16 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Feb 2013 11:12:16 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 5557D3C770; Mon, 11 Feb 2013 11:12:15 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jan@apache.org To: commits@couchdb.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [10/50] [abbrv] git commit: Handle a null or empty database name Message-Id: <20130211111215.5557D3C770@tyr.zones.apache.org> Date: Mon, 11 Feb 2013 11:12:15 +0000 (UTC) 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 Authored: Sun Jan 20 22:26:48 2013 +0000 Committer: Mike Wallace 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",