Github user michellephung commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/370#discussion_r28821282
  
    --- 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;
    --- End diff --
    
    ```var route = FauxtonAPI.urls('allDocs', 'app', 
app.utils.safeURLName(databaseName), '?limit=' + Resources.DocLimit);```
    
    a bit of context:
    A couple of months ago we changed how to retrieve generalized urls in 
Fauxton.
    https://github.com/apache/couchdb-fauxton/pull/258
    
    there started to be several ways one could build a url string:
    -models.url(type);
    -string building
    -sequences of if-elseif statements
    
    so we centralized it to keep things uniform across the board.
    
    If you need to create a urls() function, you'd register/specify it in its 
respective base.js file.
    For Example, for documents urls: 
https://github.com/apache/couchdb-fauxton/blob/master/app/addons/documents/base.js



---
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.
---

Reply via email to