You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by timmak <gi...@git.apache.org> on 2017/01/16 08:19:07 UTC

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

GitHub user timmak opened a pull request:

    https://github.com/apache/couchdb-fauxton/pull/833

    remove backbone from auth

    In process of removing jQuery this also will require remove backbone rather make a few small PRs then on big one.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/timmak/couchdb-fauxton remove-backbone-from-auth

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/couchdb-fauxton/pull/833.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #833
    
----
commit 907799bd7d0b0f8cd7ab85ccca8488683c800a29
Author: Tim Pinington <ti...@gmail.com>
Date:   2017-01-16T08:17:14Z

    remove backbone from auth

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/833#discussion_r100528767
  
    --- Diff: .eslintrc ---
    @@ -31,9 +31,10 @@
         "react/jsx-uses-vars": 2,
         "react/jsx-uses-react": 2
       },
    -
    +  "parser": "babel-eslint",
    --- End diff --
    
    I would prefer to stick to using `eslint`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton issue #833: remove backbone from auth

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on the issue:

    https://github.com/apache/couchdb-fauxton/pull/833
  
    No problem. Let me know if I can help. You can ping me on irc `garrensmith`. Also for fast testing you can run `npm run devtests` then edit `tests/dev.js` to point to the test files you want and visit `localhost:8001` for the tests to run in the browser.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/833#discussion_r100529913
  
    --- Diff: app/addons/auth/base.js ---
    @@ -61,50 +71,16 @@ Auth.initialize = function () {
             className: 'logout'
           });
         } else {
    -      link = {
    -        id: 'auth',
    -        title: 'Login',
    -        href: '#/login',
    -        icon: 'fonticon-user',
    -        bottomNav: true
    -      };
           FauxtonAPI.removeHeaderLink({ id: 'logout', footerNav: true });
         }
         FauxtonAPI.updateHeaderLink(link);
       });
     
    -  Auth.session.fetchUser().then(function () {
    -    Auth.session.trigger('change');
    -  });
    -
    -  var auth = function (session, roles) {
    -    var deferred = $.Deferred();
    -
    -    if (session.isAdminParty()) {
    -      session.trigger('authenticated');
    -      deferred.resolve();
    -    } else if (session.matchesRoles(roles)) {
    -      session.trigger('authenticated');
    -      deferred.resolve();
    -    } else {
    -      deferred.reject();
    -    }
    -
    -    return [deferred];
    -  };
    -
    -  var authDenied = function () {
    -    var url = window.location.hash.replace('#', '');
    -    var pattern = /login\?urlback=/g;
    -
    -    if (pattern.test(url)) {
    -      url = url.replace('login?urlback=', '');
    -    }
    -    FauxtonAPI.navigate('/login?urlback=' + url, { replace: true });
    -  };
    -
    -  FauxtonAPI.auth.registerAuth(auth);
    -  FauxtonAPI.auth.registerAuthDenied(authDenied);
    -};
    -
    -export default Auth;
    +    Auth.session.fetchUser().then(function () {
    +      // debugger;
    +      // Auth.session.trigger('change');
    --- End diff --
    
    I think we need this trigger. Could you enable it back.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton issue #833: remove backbone from auth

Posted by timmak <gi...@git.apache.org>.
Github user timmak commented on the issue:

    https://github.com/apache/couchdb-fauxton/pull/833
  
    Thanks @garrensmith will remove `babel-eslint` and the transform and work through the other stuff mentioned as for design changes will have a better idea once I know whether or not to do in this branch.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/833#discussion_r100529877
  
    --- Diff: app/addons/auth/base.js ---
    @@ -61,50 +71,16 @@ Auth.initialize = function () {
             className: 'logout'
           });
         } else {
    -      link = {
    -        id: 'auth',
    -        title: 'Login',
    -        href: '#/login',
    -        icon: 'fonticon-user',
    -        bottomNav: true
    -      };
           FauxtonAPI.removeHeaderLink({ id: 'logout', footerNav: true });
         }
         FauxtonAPI.updateHeaderLink(link);
       });
     
    -  Auth.session.fetchUser().then(function () {
    -    Auth.session.trigger('change');
    -  });
    -
    -  var auth = function (session, roles) {
    -    var deferred = $.Deferred();
    -
    -    if (session.isAdminParty()) {
    -      session.trigger('authenticated');
    -      deferred.resolve();
    -    } else if (session.matchesRoles(roles)) {
    -      session.trigger('authenticated');
    -      deferred.resolve();
    -    } else {
    -      deferred.reject();
    -    }
    -
    -    return [deferred];
    -  };
    -
    -  var authDenied = function () {
    -    var url = window.location.hash.replace('#', '');
    -    var pattern = /login\?urlback=/g;
    -
    -    if (pattern.test(url)) {
    -      url = url.replace('login?urlback=', '');
    -    }
    -    FauxtonAPI.navigate('/login?urlback=' + url, { replace: true });
    -  };
    -
    -  FauxtonAPI.auth.registerAuth(auth);
    -  FauxtonAPI.auth.registerAuthDenied(authDenied);
    -};
    -
    -export default Auth;
    +    Auth.session.fetchUser().then(function () {
    +      // debugger;
    --- End diff --
    
    Can you remove this debugging code


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

Posted by timmak <gi...@git.apache.org>.
Github user timmak commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/833#discussion_r100534546
  
    --- Diff: app/addons/auth/base.js ---
    @@ -44,7 +54,7 @@ Auth.initialize = function () {
         } else if (session.isLoggedIn()) {
           link = {
             id: 'auth',
    -        title: session.user().name,
    +        title: session.user.name,
    --- End diff --
    
    user is know users setter and getters so no need for the function call


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/833#discussion_r96420470
  
    --- Diff: app/core/auth.js ---
    @@ -11,50 +11,30 @@
     // the License.
     
     import FauxtonAPI from "./base";
    -import Backbone from "backbone";
    -import _ from "lodash";
     
    -// This is not exposed externally as it should not need to be accessed or overridden
    -var Auth = function (options) {
    -  this._options = options;
    -  this.initialize.apply(this, arguments);
    -};
    -
    -// Piggy-back on Backbone's self-propagating extend function,
    -Auth.extend = Backbone.Model.extend;
    -
    -_.extend(Auth.prototype, Backbone.Events, {
    -  authDeniedCb: function () {},
    -
    -  initialize: function () {
    -  },
    -
    -  authHandlerCb : function () {
    -    var deferred = $.Deferred();
    -    deferred.resolve();
    -    return deferred;
    -  },
    -
    -  registerAuth: function (authHandlerCb) {
    -    this.authHandlerCb = authHandlerCb;
    -  },
    -
    -  registerAuthDenied: function (authDeniedCb) {
    -    this.authDeniedCb = authDeniedCb;
    -  },
    +function authenticate(session, roles) {
    +  if (session.isAdminParty()) {
    +    return session.trigger('authenticated');
    --- End diff --
    
    if you are going to return in each if statement, you don't need the else. You can also make the `else if` just its own if statement


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton issue #833: remove backbone from auth

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on the issue:

    https://github.com/apache/couchdb-fauxton/pull/833
  
    Sure will do. I\u2019m traveling and then at couchdb summit. So It will take me a few days to get to it.
    
    On 07 Feb 2017, 4:32 PM +0200, Tim Pinington <no...@github.com>, wrote:
    > @garrensmith could you give this a code review ended up making a lot of changes
    > \u2014
    > You are receiving this because you were mentioned.
    > Reply to this email directly, view it on GitHub, or mute the thread.



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/833#discussion_r100530991
  
    --- Diff: app/addons/auth/components/LoginForm.jsx ---
    @@ -0,0 +1,101 @@
    +import React from "react";
    +import ReactDOM from "react-dom";
    +import { login } from "./../actions";
    +
    +class LoginForm extends React.Component {
    +  constructor() {
    +    super();
    +    this.state = {
    +      username: "",
    +      password: ""
    +    };
    +  }
    +  onInputChange(e) {
    +    var change = e.target.name === "name"
    +      ? { username: e.target.value }
    +      : { password: e.target.value };
    +    this.setState(change);
    +  }
    +  submit(e) {
    +    e.preventDefault();
    +    if (!this.checkUnrecognizedAutoFill()) {
    +      this.login(this.state.username, this.state.password);
    +    }
    +  }
    +  // Safari has a bug where autofill doesn't trigger a change event. This checks for the condition where the state
    +  // and form fields have a mismatch. See: https://issues.apache.org/jira/browse/COUCHDB-2829
    +  checkUnrecognizedAutoFill() {
    +    if (this.state.username !== "" || this.state.password !== "") {
    +      return false;
    +    }
    +    var username = this.props.testBlankUsername
    +      ? this.props.testBlankUsername
    +      : ReactDOM.findDOMNode(this.refs.username).value;
    +    var password = this.props.testBlankPassword
    +      ? this.props.testBlankPassword
    +      : ReactDOM.findDOMNode(this.refs.password).value;
    +    this.setState({ username: username, password: password }); // doesn't set immediately, hence separate login() call
    +    this.login(username, password);
    +
    +    return true;
    +  }
    +  login(username, password) {
    +    login(username, password, this.props.urlBack);
    +  }
    +  componentDidMount() {
    +    ReactDOM.findDOMNode(this.refs.username).focus();
    +  }
    +  render() {
    +    return (
    +      <div className="couch-login-wrapper">
    +        <div className="row-fluid">
    +          <div className="span12">
    +            <form id="login" onSubmit={this.submit.bind(this)}>
    +              <p className="help-block">
    +                Enter your username and password.
    +              </p>
    +              <input
    +                id="username"
    +                type="text"
    +                name="name"
    +                ref="username"
    +                placeholder="Username"
    +                size="24"
    +                onChange={this.onInputChange.bind(this)}
    +                value={this.state.username}
    +              />
    +              <br />
    +              <input
    +                id="password"
    +                type="password"
    +                name="password"
    +                ref="password"
    +                placeholder="Password"
    +                size="24"
    +                onChange={this.onInputChange.bind(this)}
    +                value={this.state.password}
    +              />
    +              <br />
    +              <button id="submit" className="btn btn-success" type="submit">
    +                Log In
    +              </button>
    +            </form>
    +          </div>
    +        </div>
    +      </div>
    +    );
    +  }
    +}
    +
    +LoginForm.defaultProps = {
    +   urlBack: "",
    +  // for testing purposes only
    --- End diff --
    
    Can you remove if its only for testing.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

Posted by timmak <gi...@git.apache.org>.
Github user timmak commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/833#discussion_r96428612
  
    --- Diff: app/addons/config/routes.js ---
    @@ -16,10 +16,10 @@ import CORSActions from "../cors/actions";
     import ClusterActions from "../cluster/cluster.actions";
     import ConfigActions from "./actions";
     import Layout from './layout';
    -
    +import React from 'react';
    --- End diff --
    
    ```
    configForNode: function (node) {
        ConfigActions.fetchAndEditConfig(node);
        return <Layout
          node={node}
          docURL={this.configs.documentation}
          endpoint={this.configs.url()}
          crumbs={[{ name: 'Config' }]}
          showCors={false}
        />;
      },
    
      configCorsForNode: function (node) {
        CORSActions.fetchAndEditCors(node);
        return <Layout
          node={node}
          docURL={this.configs.documentation}
          endpoint={this.configs.url()}
          crumbs={[{ name: 'Config' }]}
          showCors={true}
        />;
      }
    ```
    So react needs to be imported here unless I am missing something


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton issue #833: remove backbone from auth

Posted by timmak <gi...@git.apache.org>.
Github user timmak commented on the issue:

    https://github.com/apache/couchdb-fauxton/pull/833
  
    @justin-mcdavid-ibm @garrensmith I will apply the designs and the redux stuff in the branch all seems straight forward


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton issue #833: remove backbone from auth

Posted by timmak <gi...@git.apache.org>.
Github user timmak commented on the issue:

    https://github.com/apache/couchdb-fauxton/pull/833
  
    Yep will do just ran out of time will try get done later today


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/833#discussion_r100531254
  
    --- Diff: app/addons/auth/stores/ChangePassword.js ---
    @@ -0,0 +1,57 @@
    +import FauxtonAPI from "../../../core/api";
    +import {
    +  AUTH_CLEAR_CHANGE_PWD_FIELDS,
    +  AUTH_UPDATE_CHANGE_PWD_FIELD,
    +  AUTH_UPDATE_CHANGE_PWD_CONFIRM_FIELD
    +} from "../actiontypes";
    +
    +const ChangePasswordStore = FauxtonAPI.Store.extend({
    --- End diff --
    
    If you feeling brave, you are welcome to change this all to use redux. See the permission section as an example


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/833#discussion_r100529377
  
    --- Diff: app/addons/auth/actions.js ---
    @@ -10,148 +10,162 @@
     // License for the specific language governing permissions and limitations under
     // the License.
     import FauxtonAPI from "../../core/api";
    -import ActionTypes from "./actiontypes";
    +import { session } from "../../core/couchdb";
    +import {
    +  AUTH_CLEAR_CHANGE_PWD_FIELDS,
    +  AUTH_UPDATE_CHANGE_PWD_FIELD,
    +  AUTH_UPDATE_CHANGE_PWD_CONFIRM_FIELD,
    +  AUTH_CLEAR_CREATE_ADMIN_FIELDS,
    +  AUTH_CREDS_VALID,
    +  AUTH_CREDS_INVALID,
    +  AUTH_UPDATE_CREATE_ADMIN_USERNAME_FIELD,
    +  AUTH_UPDATE_CREATE_ADMIN_PWD_FIELD,
    +  AUTH_SELECT_PAGE,
    +  AUTH_SHOW_PASSWORD_MODAL,
    +  AUTH_HIDE_PASSWORD_MODAL
    +} from "./actiontypes";
     import ClusterStore from "../cluster/cluster.stores";
     
    -var nodesStore = ClusterStore.nodesStore;
    -
    -var errorHandler = function (xhr, type, msg) {
    -  msg = xhr;
    -  if (arguments.length === 3) {
    -    msg = xhr.responseJSON.reason;
    -  }
    +const nodesStore = ClusterStore.nodesStore;
     
    +function errorHandler({ message }) {
       FauxtonAPI.addNotification({
    -    msg: msg,
    -    type: 'error'
    +    msg: message,
    +    type: "error"
       });
     };
     
    -
    -function login (username, password, urlBack) {
    -  var promise = FauxtonAPI.session.login(username, password);
    -
    -  promise.then(() => {
    -    FauxtonAPI.addNotification({ msg: FauxtonAPI.session.messages.loggedIn });
    -    if (urlBack) {
    -      return FauxtonAPI.navigate(urlBack);
    -    }
    -    FauxtonAPI.navigate('/');
    -  }, errorHandler);
    +export function login(username, password, urlBack) {
    +  return FauxtonAPI.session.login(username, password)
    +    .then(() => {
    +      FauxtonAPI.addNotification({ msg: FauxtonAPI.session.messages.loggedIn });
    +      if (urlBack && !urlBack.includes("login")) {
    +        return FauxtonAPI.navigate(urlBack);
    +      }
    +      FauxtonAPI.navigate("/");
    +    })
    +    .catch(errorHandler);
     }
     
    -function changePassword (password, passwordConfirm) {
    +export function changePassword(password, passwordConfirm) {
       var nodes = nodesStore.getNodes();
    -  var promise = FauxtonAPI.session.changePassword(password, passwordConfirm, nodes[0].node);
    -
    -  promise.then(() => {
    -    FauxtonAPI.addNotification({ msg: FauxtonAPI.session.messages.changePassword });
    -    FauxtonAPI.dispatch({ type: ActionTypes.AUTH_CLEAR_CHANGE_PWD_FIELDS });
    -  }, errorHandler);
    +  var promise = FauxtonAPI.session.changePassword(
    +    password,
    +    passwordConfirm,
    +    nodes[0].node
    +  );
    +
    +  promise.then(
    +    () => {
    +      FauxtonAPI.addNotification({
    +        msg: FauxtonAPI.session.messages.changePassword
    +      });
    +      FauxtonAPI.dispatch({ type: AUTH_CLEAR_CHANGE_PWD_FIELDS });
    +    },
    +    errorHandler
    +  );
     }
     
    -function updateChangePasswordField (value) {
    +export function updateChangePasswordField(value) {
       FauxtonAPI.dispatch({
    -    type: ActionTypes.AUTH_UPDATE_CHANGE_PWD_FIELD,
    +    type: AUTH_UPDATE_CHANGE_PWD_FIELD,
         value: value
       });
     }
     
    -function updateChangePasswordConfirmField (value) {
    +export function updateChangePasswordConfirmField(value) {
       FauxtonAPI.dispatch({
    -    type: ActionTypes.AUTH_UPDATE_CHANGE_PWD_CONFIRM_FIELD,
    +    type: AUTH_UPDATE_CHANGE_PWD_CONFIRM_FIELD,
         value: value
       });
     }
     
    -function createAdmin (username, password, loginAfter) {
    +export function createAdmin(username, password, loginAfter) {
       var nodes = nodesStore.getNodes();
    -  var promise = FauxtonAPI.session.createAdmin(username, password, loginAfter, nodes[0].node);
    -
    -  promise.then(() => {
    -    FauxtonAPI.addNotification({ msg: FauxtonAPI.session.messages.adminCreated });
    -    if (loginAfter) {
    -      FauxtonAPI.navigate('/');
    -    } else {
    -      FauxtonAPI.dispatch({ type: ActionTypes.AUTH_CLEAR_CREATE_ADMIN_FIELDS });
    +  FauxtonAPI.session.createAdmin(
    +    username,
    +    password,
    +    loginAfter,
    +    nodes[0].node
    +  )
    +  .then(
    +    () => {
    +      FauxtonAPI.addNotification({
    +        msg: FauxtonAPI.session.messages.adminCreated
    +      });
    +      if (loginAfter) {
    +        FauxtonAPI.navigate("/");
    +      } else {
    --- End diff --
    
    Could you use a return on the `FauxtonAPI.navigate("/");` then you don't need the else part of the statement


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/833#discussion_r96427042
  
    --- Diff: app/core/base.js ---
    @@ -159,4 +161,15 @@ FauxtonAPI.setSession = function (newSession) {
     
     FauxtonAPI.reducers = [];
     
    +FauxtonAPI.json = (url, opts = {}) => fetch(
    --- End diff --
    
    Could you move this into its own file, maybe something like `ajax`.  This PR https://github.com/apache/couchdb-fauxton/pull/745 had a good idea. Unfortunately it doesn't look like they will complete it. Could you rather do something similar like that for all our ajax requests with fetch


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton issue #833: remove backbone from auth

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on the issue:

    https://github.com/apache/couchdb-fauxton/pull/833
  
    Awesome. That will be amazing.�
    
    All misspelling thanks to my iPhone.
    
    
    
    
    On Mon, Feb 13, 2017 at 4:20 AM -0500, "Tim Pinington" <no...@github.com> wrote:
    
    
    
    
    
    
    
    
    
    
    
    
    @justin-mcdavid-ibm @garrensmith I will apply the designs and the redux stuff in the branch all seems straight forward
    
    
    
    \u2014
    You are receiving this because you were mentioned.
    Reply to this email directly, view it on GitHub, or mute the thread.
    
    
      
      
    
    
    
    
    
    
    
    
    



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/833#discussion_r96420216
  
    --- Diff: app/addons/config/routes.js ---
    @@ -16,10 +16,10 @@ import CORSActions from "../cors/actions";
     import ClusterActions from "../cluster/cluster.actions";
     import ConfigActions from "./actions";
     import Layout from './layout';
    -
    +import React from 'react';
    --- End diff --
    
    Do you need to import React here?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/833#discussion_r100530478
  
    --- Diff: app/addons/auth/components/LoginForm.jsx ---
    @@ -0,0 +1,101 @@
    +import React from "react";
    +import ReactDOM from "react-dom";
    +import { login } from "./../actions";
    +
    +class LoginForm extends React.Component {
    +  constructor() {
    +    super();
    +    this.state = {
    +      username: "",
    +      password: ""
    +    };
    +  }
    +  onInputChange(e) {
    +    var change = e.target.name === "name"
    --- End diff --
    
    Can you use `let`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/833#discussion_r100529500
  
    --- Diff: app/addons/auth/actions.js ---
    @@ -10,148 +10,162 @@
     // License for the specific language governing permissions and limitations under
     // the License.
     import FauxtonAPI from "../../core/api";
    -import ActionTypes from "./actiontypes";
    +import { session } from "../../core/couchdb";
    +import {
    +  AUTH_CLEAR_CHANGE_PWD_FIELDS,
    +  AUTH_UPDATE_CHANGE_PWD_FIELD,
    +  AUTH_UPDATE_CHANGE_PWD_CONFIRM_FIELD,
    +  AUTH_CLEAR_CREATE_ADMIN_FIELDS,
    +  AUTH_CREDS_VALID,
    +  AUTH_CREDS_INVALID,
    +  AUTH_UPDATE_CREATE_ADMIN_USERNAME_FIELD,
    +  AUTH_UPDATE_CREATE_ADMIN_PWD_FIELD,
    +  AUTH_SELECT_PAGE,
    +  AUTH_SHOW_PASSWORD_MODAL,
    +  AUTH_HIDE_PASSWORD_MODAL
    +} from "./actiontypes";
     import ClusterStore from "../cluster/cluster.stores";
     
    -var nodesStore = ClusterStore.nodesStore;
    -
    -var errorHandler = function (xhr, type, msg) {
    -  msg = xhr;
    -  if (arguments.length === 3) {
    -    msg = xhr.responseJSON.reason;
    -  }
    +const nodesStore = ClusterStore.nodesStore;
     
    +function errorHandler({ message }) {
       FauxtonAPI.addNotification({
    -    msg: msg,
    -    type: 'error'
    +    msg: message,
    +    type: "error"
       });
     };
     
    -
    -function login (username, password, urlBack) {
    -  var promise = FauxtonAPI.session.login(username, password);
    -
    -  promise.then(() => {
    -    FauxtonAPI.addNotification({ msg: FauxtonAPI.session.messages.loggedIn });
    -    if (urlBack) {
    -      return FauxtonAPI.navigate(urlBack);
    -    }
    -    FauxtonAPI.navigate('/');
    -  }, errorHandler);
    +export function login(username, password, urlBack) {
    +  return FauxtonAPI.session.login(username, password)
    +    .then(() => {
    +      FauxtonAPI.addNotification({ msg: FauxtonAPI.session.messages.loggedIn });
    +      if (urlBack && !urlBack.includes("login")) {
    +        return FauxtonAPI.navigate(urlBack);
    +      }
    +      FauxtonAPI.navigate("/");
    +    })
    +    .catch(errorHandler);
     }
     
    -function changePassword (password, passwordConfirm) {
    +export function changePassword(password, passwordConfirm) {
       var nodes = nodesStore.getNodes();
    -  var promise = FauxtonAPI.session.changePassword(password, passwordConfirm, nodes[0].node);
    -
    -  promise.then(() => {
    -    FauxtonAPI.addNotification({ msg: FauxtonAPI.session.messages.changePassword });
    -    FauxtonAPI.dispatch({ type: ActionTypes.AUTH_CLEAR_CHANGE_PWD_FIELDS });
    -  }, errorHandler);
    +  var promise = FauxtonAPI.session.changePassword(
    +    password,
    +    passwordConfirm,
    +    nodes[0].node
    +  );
    +
    +  promise.then(
    +    () => {
    +      FauxtonAPI.addNotification({
    +        msg: FauxtonAPI.session.messages.changePassword
    +      });
    +      FauxtonAPI.dispatch({ type: AUTH_CLEAR_CHANGE_PWD_FIELDS });
    +    },
    +    errorHandler
    +  );
     }
     
    -function updateChangePasswordField (value) {
    +export function updateChangePasswordField(value) {
       FauxtonAPI.dispatch({
    -    type: ActionTypes.AUTH_UPDATE_CHANGE_PWD_FIELD,
    +    type: AUTH_UPDATE_CHANGE_PWD_FIELD,
         value: value
       });
     }
     
    -function updateChangePasswordConfirmField (value) {
    +export function updateChangePasswordConfirmField(value) {
       FauxtonAPI.dispatch({
    -    type: ActionTypes.AUTH_UPDATE_CHANGE_PWD_CONFIRM_FIELD,
    +    type: AUTH_UPDATE_CHANGE_PWD_CONFIRM_FIELD,
         value: value
       });
     }
     
    -function createAdmin (username, password, loginAfter) {
    +export function createAdmin(username, password, loginAfter) {
       var nodes = nodesStore.getNodes();
    -  var promise = FauxtonAPI.session.createAdmin(username, password, loginAfter, nodes[0].node);
    -
    -  promise.then(() => {
    -    FauxtonAPI.addNotification({ msg: FauxtonAPI.session.messages.adminCreated });
    -    if (loginAfter) {
    -      FauxtonAPI.navigate('/');
    -    } else {
    -      FauxtonAPI.dispatch({ type: ActionTypes.AUTH_CLEAR_CREATE_ADMIN_FIELDS });
    +  FauxtonAPI.session.createAdmin(
    +    username,
    +    password,
    +    loginAfter,
    +    nodes[0].node
    +  )
    +  .then(
    +    () => {
    +      FauxtonAPI.addNotification({
    +        msg: FauxtonAPI.session.messages.adminCreated
    +      });
    +      if (loginAfter) {
    +        FauxtonAPI.navigate("/");
    +      } else {
    +        FauxtonAPI.dispatch({ type: AUTH_CLEAR_CREATE_ADMIN_FIELDS });
    +      }
    +    },
    +    (xhr, type, msg) => {
    +      msg = xhr;
    +      if (arguments.length === 3) {
    +        msg = xhr.responseJSON.reason;
    +      }
    +      errorHandler(
    +        FauxtonAPI.session.messages.adminCreationFailedPrefix + " " + msg
    --- End diff --
    
    Could you use the es2015 string interpolation:
    ` `${ FauxtonAPI.session.messages.adminCreationFailedPrefix}  ${msg}` `


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

Posted by timmak <gi...@git.apache.org>.
Github user timmak commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/833#discussion_r100534561
  
    --- Diff: app/addons/auth/base.js ---
    @@ -61,50 +71,16 @@ Auth.initialize = function () {
             className: 'logout'
           });
         } else {
    -      link = {
    -        id: 'auth',
    -        title: 'Login',
    -        href: '#/login',
    -        icon: 'fonticon-user',
    -        bottomNav: true
    -      };
           FauxtonAPI.removeHeaderLink({ id: 'logout', footerNav: true });
         }
         FauxtonAPI.updateHeaderLink(link);
       });
     
    -  Auth.session.fetchUser().then(function () {
    -    Auth.session.trigger('change');
    -  });
    -
    -  var auth = function (session, roles) {
    -    var deferred = $.Deferred();
    -
    -    if (session.isAdminParty()) {
    -      session.trigger('authenticated');
    -      deferred.resolve();
    -    } else if (session.matchesRoles(roles)) {
    -      session.trigger('authenticated');
    -      deferred.resolve();
    -    } else {
    -      deferred.reject();
    -    }
    -
    -    return [deferred];
    -  };
    -
    -  var authDenied = function () {
    -    var url = window.location.hash.replace('#', '');
    -    var pattern = /login\?urlback=/g;
    -
    -    if (pattern.test(url)) {
    -      url = url.replace('login?urlback=', '');
    -    }
    -    FauxtonAPI.navigate('/login?urlback=' + url, { replace: true });
    -  };
    -
    -  FauxtonAPI.auth.registerAuth(auth);
    -  FauxtonAPI.auth.registerAuthDenied(authDenied);
    -};
    -
    -export default Auth;
    +    Auth.session.fetchUser().then(function () {
    +      // debugger;
    +      // Auth.session.trigger('change');
    --- End diff --
    
    There is no longer a trigger by setting the user the triggers a change


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

Posted by timmak <gi...@git.apache.org>.
Github user timmak commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/833#discussion_r96428914
  
    --- Diff: app/core/base.js ---
    @@ -9,9 +9,11 @@
     // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
     // License for the specific language governing permissions and limitations under
     // the License.
    -
    +import "babel-polyfill";
    --- End diff --
    
    I need this to get test running I think promise implementation was missing I will try see I can remove requiring the whole polyfill


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/833#discussion_r100529625
  
    --- Diff: app/addons/auth/actions.js ---
    @@ -10,148 +10,162 @@
     // License for the specific language governing permissions and limitations under
     // the License.
     import FauxtonAPI from "../../core/api";
    -import ActionTypes from "./actiontypes";
    +import { session } from "../../core/couchdb";
    +import {
    +  AUTH_CLEAR_CHANGE_PWD_FIELDS,
    +  AUTH_UPDATE_CHANGE_PWD_FIELD,
    +  AUTH_UPDATE_CHANGE_PWD_CONFIRM_FIELD,
    +  AUTH_CLEAR_CREATE_ADMIN_FIELDS,
    +  AUTH_CREDS_VALID,
    +  AUTH_CREDS_INVALID,
    +  AUTH_UPDATE_CREATE_ADMIN_USERNAME_FIELD,
    +  AUTH_UPDATE_CREATE_ADMIN_PWD_FIELD,
    +  AUTH_SELECT_PAGE,
    +  AUTH_SHOW_PASSWORD_MODAL,
    +  AUTH_HIDE_PASSWORD_MODAL
    +} from "./actiontypes";
     import ClusterStore from "../cluster/cluster.stores";
     
    -var nodesStore = ClusterStore.nodesStore;
    -
    -var errorHandler = function (xhr, type, msg) {
    -  msg = xhr;
    -  if (arguments.length === 3) {
    -    msg = xhr.responseJSON.reason;
    -  }
    +const nodesStore = ClusterStore.nodesStore;
     
    +function errorHandler({ message }) {
       FauxtonAPI.addNotification({
    -    msg: msg,
    -    type: 'error'
    +    msg: message,
    +    type: "error"
       });
     };
     
    -
    -function login (username, password, urlBack) {
    -  var promise = FauxtonAPI.session.login(username, password);
    -
    -  promise.then(() => {
    -    FauxtonAPI.addNotification({ msg: FauxtonAPI.session.messages.loggedIn });
    -    if (urlBack) {
    -      return FauxtonAPI.navigate(urlBack);
    -    }
    -    FauxtonAPI.navigate('/');
    -  }, errorHandler);
    +export function login(username, password, urlBack) {
    +  return FauxtonAPI.session.login(username, password)
    +    .then(() => {
    +      FauxtonAPI.addNotification({ msg: FauxtonAPI.session.messages.loggedIn });
    +      if (urlBack && !urlBack.includes("login")) {
    +        return FauxtonAPI.navigate(urlBack);
    +      }
    +      FauxtonAPI.navigate("/");
    +    })
    +    .catch(errorHandler);
     }
     
    -function changePassword (password, passwordConfirm) {
    +export function changePassword(password, passwordConfirm) {
       var nodes = nodesStore.getNodes();
    -  var promise = FauxtonAPI.session.changePassword(password, passwordConfirm, nodes[0].node);
    -
    -  promise.then(() => {
    -    FauxtonAPI.addNotification({ msg: FauxtonAPI.session.messages.changePassword });
    -    FauxtonAPI.dispatch({ type: ActionTypes.AUTH_CLEAR_CHANGE_PWD_FIELDS });
    -  }, errorHandler);
    +  var promise = FauxtonAPI.session.changePassword(
    +    password,
    +    passwordConfirm,
    +    nodes[0].node
    +  );
    +
    +  promise.then(
    +    () => {
    +      FauxtonAPI.addNotification({
    +        msg: FauxtonAPI.session.messages.changePassword
    +      });
    +      FauxtonAPI.dispatch({ type: AUTH_CLEAR_CHANGE_PWD_FIELDS });
    +    },
    +    errorHandler
    +  );
     }
     
    -function updateChangePasswordField (value) {
    +export function updateChangePasswordField(value) {
       FauxtonAPI.dispatch({
    -    type: ActionTypes.AUTH_UPDATE_CHANGE_PWD_FIELD,
    +    type: AUTH_UPDATE_CHANGE_PWD_FIELD,
         value: value
       });
     }
     
    -function updateChangePasswordConfirmField (value) {
    +export function updateChangePasswordConfirmField(value) {
       FauxtonAPI.dispatch({
    -    type: ActionTypes.AUTH_UPDATE_CHANGE_PWD_CONFIRM_FIELD,
    +    type: AUTH_UPDATE_CHANGE_PWD_CONFIRM_FIELD,
         value: value
       });
     }
     
    -function createAdmin (username, password, loginAfter) {
    +export function createAdmin(username, password, loginAfter) {
       var nodes = nodesStore.getNodes();
    -  var promise = FauxtonAPI.session.createAdmin(username, password, loginAfter, nodes[0].node);
    -
    -  promise.then(() => {
    -    FauxtonAPI.addNotification({ msg: FauxtonAPI.session.messages.adminCreated });
    -    if (loginAfter) {
    -      FauxtonAPI.navigate('/');
    -    } else {
    -      FauxtonAPI.dispatch({ type: ActionTypes.AUTH_CLEAR_CREATE_ADMIN_FIELDS });
    +  FauxtonAPI.session.createAdmin(
    +    username,
    +    password,
    +    loginAfter,
    +    nodes[0].node
    +  )
    +  .then(
    +    () => {
    +      FauxtonAPI.addNotification({
    +        msg: FauxtonAPI.session.messages.adminCreated
    +      });
    +      if (loginAfter) {
    +        FauxtonAPI.navigate("/");
    +      } else {
    +        FauxtonAPI.dispatch({ type: AUTH_CLEAR_CREATE_ADMIN_FIELDS });
    +      }
    +    },
    +    (xhr, type, msg) => {
    +      msg = xhr;
    +      if (arguments.length === 3) {
    +        msg = xhr.responseJSON.reason;
    +      }
    +      errorHandler(
    +        FauxtonAPI.session.messages.adminCreationFailedPrefix + " " + msg
    +      );
         }
    -  }, (xhr, type, msg) => {
    -    msg = xhr;
    -    if (arguments.length === 3) {
    -      msg = xhr.responseJSON.reason;
    -    }
    -    errorHandler(FauxtonAPI.session.messages.adminCreationFailedPrefix + ' ' + msg);
    -  });
    +  );
     }
     
     // simple authentication method - does nothing other than check creds
    -function authenticate (username, password, onSuccess) {
    -  $.ajax({
    -    cache: false,
    -    type: 'POST',
    -    url: '/_session',
    -    dataType: 'json',
    -    data: { name: username, password: password }
    -  }).then(() => {
    -    FauxtonAPI.dispatch({
    -      type: ActionTypes.AUTH_CREDS_VALID,
    -      options: { username: username, password: password }
    -    });
    -    hidePasswordModal();
    -    onSuccess(username, password);
    -  }, () => {
    -    FauxtonAPI.addNotification({
    -      msg: 'Your password is incorrect.',
    -      type: 'error',
    -      clear: true
    -    });
    -    FauxtonAPI.dispatch({
    -      type: ActionTypes.AUTH_CREDS_INVALID,
    -      options: { username: username, password: password }
    -    });
    -  });
    +export function authenticate(username, password, onSuccess) {
    +  session
    +    .create({
    +      name: username,
    +      password: password
    +    })
    +    .then(
    +      () => {
    +        FauxtonAPI.dispatch({
    +          type: AUTH_CREDS_VALID,
    +          options: { username: username, password: password }
    --- End diff --
    
    With es2015 you can make this options object look like this
    
    ```
    {
     usernane,
    password
    }
    ```
    
    Could you check if other objects could use that format as well.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/833#discussion_r100529683
  
    --- Diff: app/addons/auth/actiontypes.js ---
    @@ -2,24 +2,24 @@
     // 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
    +//   http =//www.apache.org/licenses/LICENSE-2.;
    --- End diff --
    
    oops. Can you change back


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

Posted by timmak <gi...@git.apache.org>.
Github user timmak commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/833#discussion_r100534629
  
    --- Diff: app/addons/auth/stores/ChangePassword.js ---
    @@ -0,0 +1,57 @@
    +import FauxtonAPI from "../../../core/api";
    +import {
    +  AUTH_CLEAR_CHANGE_PWD_FIELDS,
    +  AUTH_UPDATE_CHANGE_PWD_FIELD,
    +  AUTH_UPDATE_CHANGE_PWD_CONFIRM_FIELD
    +} from "../actiontypes";
    +
    +const ChangePasswordStore = FauxtonAPI.Store.extend({
    --- End diff --
    
    will investigate this


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/833#discussion_r96420591
  
    --- Diff: app/core/auth.js ---
    @@ -11,50 +11,30 @@
     // the License.
     
     import FauxtonAPI from "./base";
    -import Backbone from "backbone";
    -import _ from "lodash";
     
    -// This is not exposed externally as it should not need to be accessed or overridden
    -var Auth = function (options) {
    -  this._options = options;
    -  this.initialize.apply(this, arguments);
    -};
    -
    -// Piggy-back on Backbone's self-propagating extend function,
    -Auth.extend = Backbone.Model.extend;
    -
    -_.extend(Auth.prototype, Backbone.Events, {
    -  authDeniedCb: function () {},
    -
    -  initialize: function () {
    -  },
    -
    -  authHandlerCb : function () {
    -    var deferred = $.Deferred();
    -    deferred.resolve();
    -    return deferred;
    -  },
    -
    -  registerAuth: function (authHandlerCb) {
    -    this.authHandlerCb = authHandlerCb;
    -  },
    -
    -  registerAuthDenied: function (authDeniedCb) {
    -    this.authDeniedCb = authDeniedCb;
    -  },
    +function authenticate(session, roles) {
    +  if (session.isAdminParty()) {
    +    return session.trigger('authenticated');
    +  } else if (session.matchesRoles(roles)) {
    +    return session.trigger('authenticated');
    +  } else {
    +    throw new Error('Unable to authentacte');
    +  }
    +}
     
    -  checkAccess: function (roles) {
    -    var requiredRoles = roles || [],
    -    that = this;
    +function authenticatoinDenied() {
    +  let url = window.location.hash
    --- End diff --
    
    nice idea here. Could you make this a `const`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton issue #833: remove backbone from auth

Posted by timmak <gi...@git.apache.org>.
Github user timmak commented on the issue:

    https://github.com/apache/couchdb-fauxton/pull/833
  
    @garrensmith could you give this a code review ended up making a lot of changes


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/833#discussion_r96427095
  
    --- Diff: app/core/base.js ---
    @@ -9,9 +9,11 @@
     // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
     // License for the specific language governing permissions and limitations under
     // the License.
    -
    +import "babel-polyfill";
    --- End diff --
    
    What do we need the polyfill for?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

Posted by timmak <gi...@git.apache.org>.
Github user timmak commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/833#discussion_r96428694
  
    --- Diff: app/core/base.js ---
    @@ -159,4 +161,15 @@ FauxtonAPI.setSession = function (newSession) {
     
     FauxtonAPI.reducers = [];
     
    +FauxtonAPI.json = (url, opts = {}) => fetch(
    --- End diff --
    
    Sure why not


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/833#discussion_r100529832
  
    --- Diff: app/addons/auth/base.js ---
    @@ -44,7 +54,7 @@ Auth.initialize = function () {
         } else if (session.isLoggedIn()) {
           link = {
             id: 'auth',
    -        title: session.user().name,
    +        title: session.user.name,
    --- End diff --
    
    Is this correct? Shouldn't it be session.user().name?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton issue #833: remove backbone from auth

Posted by justin-mcdavid-ibm <gi...@git.apache.org>.
Github user justin-mcdavid-ibm commented on the issue:

    https://github.com/apache/couchdb-fauxton/pull/833
  
    Hi Tim, thanks for your work on this section.
    
    Here are some ideas of what we might do with that section. 
    
    <img width="1008" alt="password - inactive" src="https://cloud.githubusercontent.com/assets/12969375/22844688/4c306926-ef94-11e6-82f9-7026754807d4.png">
    <img width="1008" alt="password - active" src="https://cloud.githubusercontent.com/assets/12969375/22844690/4f9b2ed4-ef94-11e6-9e72-e371123acd53.png">
    <img width="1008" alt="admin creation - inactive" src="https://cloud.githubusercontent.com/assets/12969375/22844692/52c7aeb6-ef94-11e6-94d2-e238399d6186.png">
    <img width="1008" alt="admin creation - active" src="https://cloud.githubusercontent.com/assets/12969375/22844697/5505d374-ef94-11e6-80d5-8c1150c7ab70.png">
    
    We've been trying to move towards a main-nav/tabs model to free up more real estate (you can see this in the Replication section, where we have a tabs component that you could reuse).  I'm sure Garren would be able to help if you have any questions on the component. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton issue #833: remove backbone from auth

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on the issue:

    https://github.com/apache/couchdb-fauxton/pull/833
  
    @timmak this looks great. I'll try and give a proper review later today or latest tomorrow. Could you try and fix the tests and make sure they pass.
    



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton issue #833: remove backbone from auth

Posted by timmak <gi...@git.apache.org>.
Github user timmak commented on the issue:

    https://github.com/apache/couchdb-fauxton/pull/833
  
    Still working on it fixing the test is turning out to be a lot harder


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton issue #833: remove backbone from auth

Posted by millayr <gi...@git.apache.org>.
Github user millayr commented on the issue:

    https://github.com/apache/couchdb-fauxton/pull/833
  
    hey @timmak awesome job on this.  I'd recommend taking a look at this https://github.com/apache/couchdb-fauxton/pull/840 if you haven't already for a handy tab layout component.  thanks!


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/833#discussion_r100531532
  
    --- Diff: app/addons/verifyinstall/resources.js ---
    @@ -11,152 +11,159 @@
     // the License.
     
     import app from "../../app";
    +import { json } from "../../core/http";
     import FauxtonAPI from "../../core/api";
     import Databases from "../databases/resources";
     import Documents from "../documents/resources";
     var Verifyinstall = FauxtonAPI.addon();
     
     var db = new Databases.Model({
    -  id: 'verifytestdb',
    -  name: 'verifytestdb'
    +  id: "verifytestdb",
    +  name: "verifytestdb"
     });
     
     var dbReplicate = new Databases.Model({
    -  id: 'verifytestdb_replicate',
    -  name: 'verifytestdb_replicate'
    +  id: "verifytestdb_replicate",
    +  name: "verifytestdb_replicate"
     });
     
     var doc, viewDoc;
     
     Verifyinstall.testProcess = {
    -  saveDoc: function () {
    -    doc = new Documents.Doc({_id: 'test_doc_1', a: 1}, {
    +  saveDoc: function() {
    +    doc = new Documents.Doc({ _id: "test_doc_1", a: 1 }, {
           database: db
         });
     
         return doc.save();
       },
    -
    -  destroyDoc: function () {
    +  destroyDoc: function() {
         return doc.destroy();
       },
    -
    -  updateDoc: function () {
    -    doc.set({b: 'hello'});
    +  updateDoc: function() {
    +    doc.set({ b: "hello" });
         return doc.save();
       },
    -
    -  saveDB: function () {
    +  saveDB: function() {
         return db.save();
       },
    -
    -  setupDB: function (db) {
    +  setupDB: function(db) {
         var deferred = FauxtonAPI.Deferred();
    -    db.fetch()
    -    .then(function () {
    -      return db.destroy();
    -    }, function () {
    -      deferred.resolve();
    -    })
    -    .then(function () {
    -      deferred.resolve();
    -    }, function (xhr, error, reason) {
    -      if (reason === 'Unauthorized') {
    -        deferred.reject(xhr, error, reason);
    -      }
    -    });
    +    db
    +      .fetch()
    +      .then(
    +        function() {
    +          return db.destroy();
    +        },
    +        function() {
    +          deferred.resolve();
    +        }
    +      )
    +      .then(
    +        function() {
    +          deferred.resolve();
    +        },
    +        function(xhr, error, reason) {
    +          if (reason === "Unauthorized") {
    +            deferred.reject(xhr, error, reason);
    +          }
    +        }
    +      );
     
         return deferred;
       },
    -
    -  setup: function () {
    -    return FauxtonAPI.when([
    -      this.setupDB(db),
    -      this.setupDB(dbReplicate)
    -    ]);
    +  setup: function() {
    +    return FauxtonAPI.when([this.setupDB(db), this.setupDB(dbReplicate)]);
       },
    -
    -  testView: function () {
    -    var deferred = FauxtonAPI.Deferred();
    -    var promise = $.get(viewDoc.url() + '/_view/testview');
    -
    -    promise.then(function (resp) {
    -      resp = _.isString(resp) ? JSON.parse(resp) : resp;
    -      var row = resp.rows[0];
    -      if (row.value === 6) {
    -        return deferred.resolve();
    -      }
    -      var reason = {
    -        reason: 'Values expect 6, got ' + row.value
    -      };
    -
    -      deferred.reject({responseText: JSON.stringify(reason)});
    -    }, deferred.reject);
    -
    -    return deferred;
    +  testView: function() {
    +    return json(viewDoc.url() + "/_view/testview").then(
    +      function(resp) {
    +        var row = resp.rows[0];
    +        if (row.value === 6) {
    +          return Promise.resolve();
    +        }
    +        var reason = {
    +          reason: "Values expect 6, got " + row.value
    +        };
    +        return Promise.reject({ responseText: JSON.stringify(reason) });
    +      },
    +      Promise.reject
    +    );
       },
    +  setupView: function() {
    +    var doc1 = new Documents.Doc({ _id: "test_doc_10", a: 1 }, {
    +      database: db
    +    });
    +    var doc2 = new Documents.Doc({ _id: "test_doc_20", a: 2 }, {
    +      database: db
    +    });
    +    var doc3 = new Documents.Doc({ _id: "test_doc_30", a: 3 }, {
    +      database: db
    +    });
     
    -  setupView: function () {
    -    var doc1 = new Documents.Doc({_id: 'test_doc_10', a: 1}, { database: db });
    -    var doc2 = new Documents.Doc({_id: 'test_doc_20', a: 2}, { database: db });
    -    var doc3 = new Documents.Doc({_id: 'test_doc_30', a: 3}, { database: db });
    -
    -    viewDoc = new Documents.Doc({
    -      _id: '_design/view_check',
    -      views: {
    -        'testview': {
    -          map: 'function (doc) { emit(doc._id, doc.a); }',
    -          reduce: '_sum'
    +    viewDoc = new Documents.Doc(
    +      {
    +        _id: "_design/view_check",
    +        views: {
    +          testview: {
    +            map: "function (doc) { emit(doc._id, doc.a); }",
    +            reduce: "_sum"
    +          }
             }
    +      },
    +      {
    +        database: db
           }
    -    }, {
    -      database: db
    -    });
    +    );
     
    -    return FauxtonAPI.when([doc1.save(), doc2.save(), doc3.save(), viewDoc.save()]);
    +    return FauxtonAPI.when([
    +      doc1.save(),
    +      doc2.save(),
    +      doc3.save(),
    +      viewDoc.save()
    +    ]);
       },
    -
    -  setupReplicate: function () {
    +  setupReplicate: function() {
         return $.ajax({
    -      url: app.host + '/_replicate',
    -      contentType: 'application/json',
    -      type: 'POST',
    -      dataType: 'json',
    +      url: app.host + "/_replicate",
    +      contentType: "application/json",
    +      type: "POST",
    +      dataType: "json",
           processData: false,
           data: JSON.stringify({
             create_target: true,
    -        source: 'verifytestdb',
    -        target: 'verifytestdb_replicate'
    +        source: "verifytestdb",
    +        target: "verifytestdb_replicate"
           })
         });
       },
    -
    -  testReplicate: function () {
    +  testReplicate: function() {
    --- End diff --
    
    These changes don't really seem related to your PR. It just makes it a little harder to review everything


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/833#discussion_r100529282
  
    --- Diff: app/addons/auth/actions.js ---
    @@ -10,148 +10,162 @@
     // License for the specific language governing permissions and limitations under
     // the License.
     import FauxtonAPI from "../../core/api";
    -import ActionTypes from "./actiontypes";
    +import { session } from "../../core/couchdb";
    +import {
    +  AUTH_CLEAR_CHANGE_PWD_FIELDS,
    +  AUTH_UPDATE_CHANGE_PWD_FIELD,
    +  AUTH_UPDATE_CHANGE_PWD_CONFIRM_FIELD,
    +  AUTH_CLEAR_CREATE_ADMIN_FIELDS,
    +  AUTH_CREDS_VALID,
    +  AUTH_CREDS_INVALID,
    +  AUTH_UPDATE_CREATE_ADMIN_USERNAME_FIELD,
    +  AUTH_UPDATE_CREATE_ADMIN_PWD_FIELD,
    +  AUTH_SELECT_PAGE,
    +  AUTH_SHOW_PASSWORD_MODAL,
    +  AUTH_HIDE_PASSWORD_MODAL
    +} from "./actiontypes";
     import ClusterStore from "../cluster/cluster.stores";
     
    -var nodesStore = ClusterStore.nodesStore;
    -
    -var errorHandler = function (xhr, type, msg) {
    -  msg = xhr;
    -  if (arguments.length === 3) {
    -    msg = xhr.responseJSON.reason;
    -  }
    +const nodesStore = ClusterStore.nodesStore;
     
    +function errorHandler({ message }) {
       FauxtonAPI.addNotification({
    -    msg: msg,
    -    type: 'error'
    +    msg: message,
    +    type: "error"
       });
     };
     
    -
    -function login (username, password, urlBack) {
    -  var promise = FauxtonAPI.session.login(username, password);
    -
    -  promise.then(() => {
    -    FauxtonAPI.addNotification({ msg: FauxtonAPI.session.messages.loggedIn });
    -    if (urlBack) {
    -      return FauxtonAPI.navigate(urlBack);
    -    }
    -    FauxtonAPI.navigate('/');
    -  }, errorHandler);
    +export function login(username, password, urlBack) {
    +  return FauxtonAPI.session.login(username, password)
    +    .then(() => {
    +      FauxtonAPI.addNotification({ msg: FauxtonAPI.session.messages.loggedIn });
    +      if (urlBack && !urlBack.includes("login")) {
    +        return FauxtonAPI.navigate(urlBack);
    +      }
    +      FauxtonAPI.navigate("/");
    +    })
    +    .catch(errorHandler);
     }
     
    -function changePassword (password, passwordConfirm) {
    +export function changePassword(password, passwordConfirm) {
       var nodes = nodesStore.getNodes();
    -  var promise = FauxtonAPI.session.changePassword(password, passwordConfirm, nodes[0].node);
    -
    -  promise.then(() => {
    -    FauxtonAPI.addNotification({ msg: FauxtonAPI.session.messages.changePassword });
    -    FauxtonAPI.dispatch({ type: ActionTypes.AUTH_CLEAR_CHANGE_PWD_FIELDS });
    -  }, errorHandler);
    +  var promise = FauxtonAPI.session.changePassword(
    +    password,
    +    passwordConfirm,
    +    nodes[0].node
    +  );
    +
    +  promise.then(
    +    () => {
    +      FauxtonAPI.addNotification({
    +        msg: FauxtonAPI.session.messages.changePassword
    +      });
    +      FauxtonAPI.dispatch({ type: AUTH_CLEAR_CHANGE_PWD_FIELDS });
    +    },
    +    errorHandler
    +  );
     }
     
    -function updateChangePasswordField (value) {
    +export function updateChangePasswordField(value) {
       FauxtonAPI.dispatch({
    -    type: ActionTypes.AUTH_UPDATE_CHANGE_PWD_FIELD,
    +    type: AUTH_UPDATE_CHANGE_PWD_FIELD,
         value: value
       });
     }
     
    -function updateChangePasswordConfirmField (value) {
    +export function updateChangePasswordConfirmField(value) {
       FauxtonAPI.dispatch({
    -    type: ActionTypes.AUTH_UPDATE_CHANGE_PWD_CONFIRM_FIELD,
    +    type: AUTH_UPDATE_CHANGE_PWD_CONFIRM_FIELD,
         value: value
       });
     }
     
    -function createAdmin (username, password, loginAfter) {
    +export function createAdmin(username, password, loginAfter) {
       var nodes = nodesStore.getNodes();
    --- End diff --
    
    very minor. But could you make this a `const`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #833: remove backbone from auth

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/833#discussion_r100528884
  
    --- Diff: .babelrc ---
    @@ -3,5 +3,5 @@
         "react",
         "es2015"
       ],
    -  "plugins": ["transform-object-assign"]
    +  "plugins": ["transform-object-assign", "transform-export-extensions"]
    --- End diff --
    
    I'm not completely sold on using `"transform-export-extensions`. I think this along with the `babel-eslint` would need to be done via a separate Pr justifying why we should switch to them.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---