Github user garrensmith commented on a diff in the pull request:
https://github.com/apache/couchdb-fauxton/pull/370#discussion_r28764003
--- Diff: app/addons/databases/actions.js ---
@@ -0,0 +1,105 @@
+// 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([
+ 'app',
+ 'api',
+ 'addons/databases/stores',
+ 'addons/databases/actiontypes',
+ 'addons/databases/resources'
+],
+function (app, FauxtonAPI, Stores, ActionTypes, Resources) {
+ return {
+ init: function (collection, backboneCollection) {
+ FauxtonAPI.dispatch({
+ type: ActionTypes.DATABASES_INIT,
+ options: {
+ collection: collection,
+ backboneCollection: backboneCollection
+ }
+ });
+ },
+
+ setPage: function (_page) {
+ FauxtonAPI.dispatch({
+ type: ActionTypes.DATABASES_SETPAGE,
+ options: {
+ page: _page
+ }
+ });
+ },
+
+ setStartLoading: function () {
+ FauxtonAPI.dispatch({
+ type: ActionTypes.DATABASES_STARTLOADING,
+ options: {}
+ });
+ },
+
+ setLoadComplete: function () {
+ FauxtonAPI.dispatch({
+ type: ActionTypes.DATABASES_LOADCOMPLETE,
+ options: {}
+ });
+ },
+
+ createNewDatabase: function (databaseName, nameAccCallback) {
+ databaseName = (databaseName === null ? null : databaseName.trim());
+ if (databaseName === null || databaseName.length === 0) {
+ FauxtonAPI.addNotification({
+ msg: 'Please enter a valid database name',
+ type: 'error',
+ clear: true
+ });
+ return;
+ }
+ // name accepted, make sure prompt can be removed
+ nameAccCallback();
+
+ var db = Stores.databasesStore.obtainNewDatabaseModel(databaseName);
+ FauxtonAPI.addNotification({ msg: 'Creating database.' });
+ db.save().done(function () {
+ FauxtonAPI.addNotification({
+ msg: 'Database created successfully',
+ type: 'success',
+ clear: true
+ });
+ var route = '#/database/' + app.utils.safeURLName(databaseName)
+ '/_all_docs?limit=' + Resources.DocLimit;
+ app.router.navigate(route, { trigger: true });
+ }
+ ).error(function (xhr) {
+ var responseText = JSON.parse(xhr.responseText).reason;
+ FauxtonAPI.addNotification({
+ msg: 'Create database failed: ' + responseText,
+ type: 'error',
+ clear: true
+ });
+ }
+ );
+ },
+
+ jumpToDatabase: function (databaseName) {
+ databaseName = databaseName === null ? null : databaseName.trim();
+ if (databaseName === null || databaseName.length === 0) {
--- End diff --
You could change this to:
```javascript
if (_.isNull(databaseName) || _.isEmpty(databaseName) {...
```
Makes it a little more readable.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---