You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by garrensmith <gi...@git.apache.org> on 2017/03/02 14:32:32 UTC

[GitHub] couchdb-fauxton pull request #864: Update replication to work with scheduler...

GitHub user garrensmith opened a pull request:

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

    Update replication to work with scheduler api

    This is to support the new scheduler api that will land in CouchDB soon

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

    $ git pull https://github.com/garrensmith/couchdb-fauxton update-replication

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

    https://github.com/apache/couchdb-fauxton/pull/864.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 #864
    
----
commit 15911c7af98448295d6b4ac148af256965607330
Author: Garren Smith <ga...@gmail.com>
Date:   2017-01-17T07:25:19Z

    basic setup replication rework

commit f9de98167a6680f8298715b964f40cd227afab96
Author: Garren Smith <ga...@gmail.com>
Date:   2017-03-02T09:59:00Z

    working _replicates section

commit e8f661d250d1830a2458cf4a38a8bcedec7aa969
Author: Garren Smith <ga...@gmail.com>
Date:   2017-03-02T12:20:32Z

    clear forms and loading for new replication

commit 97b40e1ea26a6b8970161653d77ae6f711583de8
Author: Garren Smith <ga...@gmail.com>
Date:   2017-03-02T12:24:28Z

    fix tests

commit 14820cf04b7945e3afc904f3032fe924b440eb9b
Author: Garren Smith <ga...@gmail.com>
Date:   2017-03-02T12:34:18Z

    lint issue fix

----


---
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 #864: Update replication to work with scheduler...

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

    https://github.com/apache/couchdb-fauxton/pull/864#discussion_r105749148
  
    --- Diff: app/addons/replication/route.js ---
    @@ -39,25 +41,31 @@ const ReplicationRouteObject = FauxtonAPI.RouteObject.extend({
       },
     
       defaultView: function (databaseName) {
    -    const localSource = databaseName || '';
    +    let localSource = databaseName || '';
    --- End diff --
    
    can we switch this back to `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 #864: Update replication to work with scheduler...

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

    https://github.com/apache/couchdb-fauxton/pull/864#discussion_r105734764
  
    --- Diff: app/addons/replication/components/common-table.js ---
    @@ -0,0 +1,406 @@
    +// 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.
    +import React from 'react';
    +import {Table, Tooltip, OverlayTrigger} from "react-bootstrap";
    +import moment from 'moment';
    +import {ErrorModal} from './modals';
    +
    +const formatUrl = (url) => {
    +  const urlObj = new URL(url);
    +  const encoded = encodeURIComponent(urlObj.pathname.slice(1));
    +
    +  if (url.indexOf(window.location.hostname) > -1) {
    +    return (
    +      <span>
    +        {urlObj.origin + '/'}
    +        <a href={`#/database/${encoded}/_all_docs`}>{urlObj.pathname.slice(1)}</a>
    +      </span>
    +    );
    +  }
    +
    +  return `${urlObj.origin}${urlObj.pathname}`;
    +};
    +
    +class RowStatus extends React.Component {
    +  constructor (props) {
    +    super(props);
    +    this.state = {
    +      modalVisible: false,
    +    };
    +  }
    +
    +  showModal () {
    +    this.setState({modalVisible: true});
    +  }
    +
    +  closeModal () {
    +    this.setState({modalVisible: false});
    +  }
    +
    +  getErrorIcon () {
    +    const {status} = this.props;
    +    if (status !== 'error' && status !== 'retrying') {
    +      return null;
    +    }
    +
    +    return (
    +      <span>
    +        <a
    +          data-bypass="true"
    +          className="replication__row-btn replication__row-btn--warning icon-exclamation-sign"
    +          onClick={this.showModal.bind(this)}
    +          title="View error message">
    +        </a>
    +        <ErrorModal
    +          onClick={this.closeModal.bind(this)}
    +          onClose={this.closeModal.bind(this)}
    +          errorMsg={this.props.errorMsg}
    +          visible={this.state.modalVisible}
    +          status={status}
    +        />
    +      </span>
    +    );
    +  }
    +
    +  render () {
    +    const {statusTime, status} = this.props;
    +    let momentTime = moment(statusTime);
    +    let statusValue = <span>{status}</span>;
    +
    +    if (momentTime.isValid()) {
    +      const formattedStatusTime = momentTime.format("MMM Do, h:mm a");
    +      const stateTimeTooltip = <Tooltip id="">Last updated: {formattedStatusTime}</Tooltip>;
    +      statusValue =
    +        <OverlayTrigger placement="top" overlay={stateTimeTooltip}>
    +          <span>{status}</span>
    +        </OverlayTrigger>;
    +    }
    +
    +    return (
    +      <td className={`replication__row-status replication__row-status--${status}`}>
    +        {statusValue}
    +        {this.getErrorIcon()}
    +      </td>
    +    );
    +  }
    +};
    +
    +RowStatus.propTypes = {
    +  statusTime: React.PropTypes.any,
    +  status: React.PropTypes.string,
    +  errorMsg: React.PropTypes.string.isRequired,
    +};
    +
    +RowStatus.defaultProps = {
    +  status: ''
    +};
    +
    +const RowActions = ({onlyDeleteAction, _id, url, deleteDocs}) => {
    +  const actions = [];
    +  if (!onlyDeleteAction) {
    +    actions.push(
    +      <li className="replication__row-list" key={1}>
    +        <a
    +          href={`#replication/id/${encodeURIComponent(_id)}`}
    +          className="replication__row-btn icon-wrench replication__row-btn--no-left-pad"
    +          title={`Edit replication`}
    +          data-bypass="true"
    +          >
    +        </a>
    +      </li>
    +    );
    +    actions.push(
    +      <li className="replication__row-list" key={2}>
    +        <a
    +          className="replication__row-btn fonticon-document"
    +          title={`Edit replication document`}
    --- End diff --
    
    Same as above.  Static string?


---
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 #864: Update replication to work with scheduler...

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/864#discussion_r105855225
  
    --- Diff: app/addons/replication/api.js ---
    @@ -16,6 +16,30 @@ import app from '../../app';
     import FauxtonAPI from '../../core/api';
     import base64 from 'base-64';
     import _ from 'lodash';
    +import 'whatwg-fetch';
    +
    +let newApiPromise = null;
    +export const supportNewApi = (forceCheck) => {
    +  if (!newApiPromise || forceCheck) {
    +    newApiPromise = new FauxtonAPI.Promise((resolve) => {
    +      fetch('/_scheduler/jobs', {
    +        credentials: 'include',
    +        headers: {
    +            'Accept': 'application/json; charset=utf-8',
    +          }
    +        })
    +      .then(resp => {
    +        if (resp.status > 202) {
    +          return resolve(false);
    --- End diff --
    
    if we don't use the return here, then it once its outside the if statement it will then try and resolve the promise again with `true`. I could put the return after the resolve. It doesn't really matter


---
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 #864: Update replication to work with scheduler...

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

    https://github.com/apache/couchdb-fauxton/pull/864#discussion_r105738831
  
    --- Diff: app/addons/replication/components/common-table.js ---
    @@ -0,0 +1,406 @@
    +// 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.
    +import React from 'react';
    +import {Table, Tooltip, OverlayTrigger} from "react-bootstrap";
    +import moment from 'moment';
    +import {ErrorModal} from './modals';
    +
    +const formatUrl = (url) => {
    +  const urlObj = new URL(url);
    +  const encoded = encodeURIComponent(urlObj.pathname.slice(1));
    +
    +  if (url.indexOf(window.location.hostname) > -1) {
    +    return (
    +      <span>
    +        {urlObj.origin + '/'}
    +        <a href={`#/database/${encoded}/_all_docs`}>{urlObj.pathname.slice(1)}</a>
    +      </span>
    +    );
    +  }
    +
    +  return `${urlObj.origin}${urlObj.pathname}`;
    +};
    +
    +class RowStatus extends React.Component {
    +  constructor (props) {
    +    super(props);
    +    this.state = {
    +      modalVisible: false,
    +    };
    +  }
    +
    +  showModal () {
    +    this.setState({modalVisible: true});
    +  }
    +
    +  closeModal () {
    +    this.setState({modalVisible: false});
    +  }
    +
    +  getErrorIcon () {
    +    const {status} = this.props;
    +    if (status !== 'error' && status !== 'retrying') {
    +      return null;
    +    }
    +
    +    return (
    +      <span>
    +        <a
    +          data-bypass="true"
    +          className="replication__row-btn replication__row-btn--warning icon-exclamation-sign"
    +          onClick={this.showModal.bind(this)}
    +          title="View error message">
    +        </a>
    +        <ErrorModal
    +          onClick={this.closeModal.bind(this)}
    +          onClose={this.closeModal.bind(this)}
    +          errorMsg={this.props.errorMsg}
    +          visible={this.state.modalVisible}
    +          status={status}
    +        />
    +      </span>
    +    );
    +  }
    +
    +  render () {
    +    const {statusTime, status} = this.props;
    +    let momentTime = moment(statusTime);
    +    let statusValue = <span>{status}</span>;
    +
    +    if (momentTime.isValid()) {
    +      const formattedStatusTime = momentTime.format("MMM Do, h:mm a");
    +      const stateTimeTooltip = <Tooltip id="">Last updated: {formattedStatusTime}</Tooltip>;
    +      statusValue =
    +        <OverlayTrigger placement="top" overlay={stateTimeTooltip}>
    +          <span>{status}</span>
    +        </OverlayTrigger>;
    +    }
    +
    +    return (
    +      <td className={`replication__row-status replication__row-status--${status}`}>
    +        {statusValue}
    +        {this.getErrorIcon()}
    +      </td>
    +    );
    +  }
    +};
    +
    +RowStatus.propTypes = {
    +  statusTime: React.PropTypes.any,
    +  status: React.PropTypes.string,
    +  errorMsg: React.PropTypes.string.isRequired,
    +};
    +
    +RowStatus.defaultProps = {
    +  status: ''
    +};
    +
    +const RowActions = ({onlyDeleteAction, _id, url, deleteDocs}) => {
    +  const actions = [];
    +  if (!onlyDeleteAction) {
    +    actions.push(
    +      <li className="replication__row-list" key={1}>
    +        <a
    +          href={`#replication/id/${encodeURIComponent(_id)}`}
    +          className="replication__row-btn icon-wrench replication__row-btn--no-left-pad"
    +          title={`Edit replication`}
    +          data-bypass="true"
    +          >
    +        </a>
    +      </li>
    +    );
    +    actions.push(
    +      <li className="replication__row-list" key={2}>
    +        <a
    +          className="replication__row-btn fonticon-document"
    +          title={`Edit replication document`}
    +          href={url}
    +          data-bypass="true"
    +          >
    +        </a>
    +      </li>
    +    );
    +  }
    +
    +  actions.push(
    +    <li className="replication__row-list" key={3}>
    +      <a
    +        className={`replication__row-btn icon-trash ${onlyDeleteAction ? 'replication__row-btn--no-left-pad' : ''} `}
    +        title={`Delete ${onlyDeleteAction ? 'job' : 'document'} ${_id}`}
    +        onClick={() => deleteDocs(_id)}>
    +      </a>
    +    </li>
    +  );
    +
    +  return (
    +    <ul className="replication__row-actions-list">
    +      {actions}
    +    </ul>
    +  );
    +};
    +
    +RowActions.propTypes = {
    +  _id: React.PropTypes.string.isRequired,
    +  url: React.PropTypes.string,
    +  error: React.PropTypes.bool.isRequired,
    +  errorMsg: React.PropTypes.string.isRequired,
    +  deleteDocs: React.PropTypes.func.isRequired
    +};
    +
    +const Row = ({
    +  _id,
    +  source,
    +  target,
    +  type,
    +  startTime,
    +  status,
    +  statusTime,
    +  url,
    +  selected,
    +  selectDoc,
    +  errorMsg,
    +  deleteDocs,
    +  onlyDeleteAction,
    +  showStateRow
    +}) => {
    +  let momentTime = moment(startTime);
    +  const formattedStartTime = momentTime.isValid() ? momentTime.format("MMM Do, h:mm a") : '';
    +  let stateRow = null;
    +
    +  if (showStateRow) {
    +    stateRow = <RowStatus
    +        statusTime={statusTime}
    +        status={status}
    +        errorMsg={errorMsg}
    +      />;
    +  }
    +
    +  return (
    +    <tr className="replication__table-row">
    +      <td className="replication__table-col"><input checked={selected} type="checkbox" onChange={() => selectDoc(_id)} /> </td>
    +      <td className="replication__table-col">{formatUrl(source)}</td>
    +      <td className="replication__table-col">{formatUrl(target)}</td>
    +      <td className="replication__table-col">{formattedStartTime}</td>
    +      <td className="replication__table-col">{type}</td>
    +      {stateRow}
    +      <td className="replication__table-col">
    +        <RowActions
    +          onlyDeleteAction={onlyDeleteAction}
    +          deleteDocs={deleteDocs}
    +          _id={_id}
    +          url={url}
    +          error={status === "error" || status === 'retrying'}
    +          errorMsg={errorMsg}
    +          />
    +      </td>
    +    </tr>
    +
    +  );
    +};
    +
    +Row.propTypes = {
    +  _id: React.PropTypes.string.isRequired,
    +  source: React.PropTypes.string.isRequired,
    +  target: React.PropTypes.string.isRequired,
    +  type: React.PropTypes.string.isRequired,
    +  status: React.PropTypes.string,
    +  url: React.PropTypes.string,
    +  statusTime: React.PropTypes.object.isRequired,
    +  startTime: React.PropTypes.object,
    +  selected: React.PropTypes.bool.isRequired,
    +  selectDoc: React.PropTypes.func.isRequired,
    +  errorMsg: React.PropTypes.string.isRequired,
    +  deleteDocs: React.PropTypes.func.isRequired,
    +  onlyDeleteAction: React.PropTypes.bool.isRequired,
    +  showStateRow: React.PropTypes.bool.isRequired
    +};
    +
    +const BulkSelectHeader = ({isSelected, deleteDocs, someDocsSelected, onCheck}) => {
    +  const trash = someDocsSelected ?
    +    <button
    +      onClick={() => deleteDocs()}
    +      className="replication__bulk-select-trash fonticon fonticon-trash"
    +      title="Delete all selected">
    +    </button> : null;
    +
    +  return (
    +    <div className="replication__bulk-select-wrapper">
    +      <div className="replication__bulk-select-header">
    +        <input className="replication__bulk-select-input" checked={isSelected} type="checkbox" onChange={onCheck} />
    +      </div>
    +    {trash}
    +    </div>
    +  );
    +};
    +
    +BulkSelectHeader.propTypes = {
    +  isSelected: React.PropTypes.bool.isRequired,
    +  someDocsSelected: React.PropTypes.bool.isRequired,
    +  onCheck: React.PropTypes.func.isRequired,
    +  deleteDocs: React.PropTypes.func.isRequired
    +};
    +
    +const EmptyRow = ({msg}) => {
    +  return (
    +    <tr>
    +      <td colSpan="7" className="replication__empty-row">
    +        {msg}
    +      </td>
    +    </tr>
    +  );
    +};
    +
    +EmptyRow.defaultProps = {
    +  msg: "There is no replicator-db activity or history to display."
    +};
    +
    +
    +export class ReplicationTable extends React.Component {
    +  constructor (props) {
    +    super(props);
    +  }
    +
    +  sort(column, descending, docs) {
    +    const sorted = docs.sort((a, b) => {
    +      if (a[column] < b[column]) {
    +        return -1;
    +      }
    +
    +      if (a[column] > b[column]) {
    +        return 1;
    +      }
    +
    +      return 0;
    +
    +    });
    +
    +    if (!descending) {
    +      sorted.reverse();
    +    }
    +
    +    return sorted;
    +  }
    +
    +  renderRows () {
    +    console.log(this.props.docs);
    +    if (this.props.docs.length === 0) {
    +      return <EmptyRow />;
    +    }
    +
    +    return this.sort(this.props.column, this.props.descending, this.props.docs).map((doc, i) => {
    +      return <Row
    +        key={i}
    +        _id={doc._id}
    +        selected={doc.selected}
    +        selectDoc={this.props.selectDoc}
    +        source={doc.source}
    +        target={doc.target}
    +        type={doc.continuous === true ? 'Continuous' : 'One time'}
    +        status={doc.status}
    +        statusTime={doc.statusTime}
    +        startTime={doc.startTime}
    +        url={doc.url}
    +        deleteDocs={this.props.deleteDocs}
    +        errorMsg={doc.errorMsg}
    +        doc={doc}
    +        onlyDeleteAction={this.props.onlyDeleteAction}
    +        showStateRow={this.props.showStateRow}
    +      />;
    +    });
    +  }
    +
    +  iconDirection (column) {
    +    if (column === this.props.column && !this.props.descending) {
    +      return 'fonticon-up-dir';
    +    }
    +
    +    return 'fonticon-down-dir';
    +  }
    +
    +  onSort (column) {
    +    return () => {
    +      this.props.changeSort({
    +        descending: column === this.props.column ? !this.props.descending : true,
    +        column
    +      });
    +    };
    +  }
    +
    +  isSelected (header) {
    +    if (header === this.props.column) {
    +      return 'replication__table--selected';
    +    }
    +
    +    return '';
    +  }
    +
    +  stateRow () {
    --- End diff --
    
    Minor but can we rename this to `stateCol`?  When this conditionally returns a heading for a column I think it's misleading to call it a row.


---
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 #864: Update replication to work with scheduler...

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

    https://github.com/apache/couchdb-fauxton/pull/864#discussion_r105748635
  
    --- Diff: app/addons/replication/controller.js ---
    @@ -186,25 +208,79 @@ export default class ReplicationController extends React.Component {
               max={600}
               startValue={300}
               stepSize={60}
    -          onPoll={Actions.getReplicationActivity}
    +          onPoll={this.getAllActivity.bind(this)}
               />
             <RefreshBtn
    -          refresh={Actions.getReplicationActivity}
    +          refresh={this.getAllActivity.bind(this)}
               />
           </div>
         );
       }
     
    +  getTabElements () {
    +    const {tabSection} = this.state;
    +    const elements = [
    +      <TabElement
    +        key={1}
    +        selected={tabSection === 'activity'}
    +        text={"Replicator DB Activity"}
    +        onChange={this.onTabChange.bind(this, 'activity', '#/replication')}
    +      />
    +    ];
    +
    +    if (this.state.supportNewApi) {
    +      elements.push(
    +        <TabElement
    +          key={2}
    +          selected={tabSection === '_replicate'}
    +          text={"_replicate Activity"}
    +          onChange={this.onTabChange.bind(this, '_replicate', '#/replication/_replicate')}
    +        />
    +      );
    +    }
    +
    +    return elements;
    +  }
    +
    +  onTabChange (section, url) {
    +    Actions.changeTabSection(section, url);
    +  }
    +
    +  getCrumbs () {
    +    if (this.state.tabSection === 'new replication') {
    +      return [{'name': 'Job Configuration'}];
    +    }
    +
    +    return [];
    +  }
    +
    +  getTabs () {
    +    if (this.state.tabSection === 'new replication') {
    +      return null;
    +    }
    +
    +    return (
    +      <TabElementWrapper>
    +        {this.getTabElements()}
    +      </TabElementWrapper>
    +    );
    +  }
    +
       render () {
    +    const { checkingAPI } = this.state;
    +
    +    if (checkingAPI) {
    --- End diff --
    
    Is it worth switching this to `this.state.checkingAPI` to eliminate the previous line?  Doesn't look like we use `checkingAPI` anywhere else later on.


---
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 #864: Update replication to work with scheduler api

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/864
  
    Thanks for the work, Garren.  It looks great.


---
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 #864: Update replication to work with scheduler...

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/864#discussion_r105855506
  
    --- Diff: app/addons/replication/components/common-activity.js ---
    @@ -0,0 +1,107 @@
    +// 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.
    +import React from 'react';
    +import {DeleteModal} from './modals';
    +
    +export class BulkDeleteController extends React.Component {
    --- End diff --
    
    This is used in the activity.js and replicateActivity.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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fauxton pull request #864: Update replication to work with scheduler...

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

    https://github.com/apache/couchdb-fauxton/pull/864#discussion_r105690327
  
    --- Diff: app/addons/replication/api.js ---
    @@ -16,6 +16,30 @@ import app from '../../app';
     import FauxtonAPI from '../../core/api';
     import base64 from 'base-64';
     import _ from 'lodash';
    +import 'whatwg-fetch';
    +
    +let newApiPromise = null;
    +export const supportNewApi = (forceCheck) => {
    +  if (!newApiPromise || forceCheck) {
    +    newApiPromise = new FauxtonAPI.Promise((resolve) => {
    +      fetch('/_scheduler/jobs', {
    +        credentials: 'include',
    +        headers: {
    +            'Accept': 'application/json; charset=utf-8',
    +          }
    +        })
    +      .then(resp => {
    +        if (resp.status > 202) {
    +          return resolve(false);
    --- End diff --
    
    why use `return` here?  somewhat tough to follow the logic if it's only use for control flow in this context.


---
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 #864: Update replication to work with scheduler api

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/864
  
    1. I'm sorry for the confusion in the mockups, but I think we should keep the "New Replication" button in place for Replicator DB Activity, and add it to the _replicate Activity tab as well, even though both buttons will only be capable of triggering a replicator db job.  My mistake here; I think we want to try and maintain the cohesive pattern of "new" buttons above the table across the dashboard, and when it comes time to add "Advanced Replication" to the mix, we can do so still maintaining that pattern. Updated mockups below.
    
    2. Hover help on the trashcan icon in the _replicate Activity section should not reference a document being deleted, but instead the job. \u201cDelete job id 1342345234534534563456.\u201d
    
    3. Hovering over the state should result in the state time displaying.
    
    4. _replicate Activity doesn\u2019t seem to be picking up the type correctly. My continuous jobs are showing up as \u201cone time.\u201d 
    
    5. The \u201cRetrying\u201d state should only be for for jobs that are actually being retried. Auth errors aren\u2019t retried, are they? I\u2019m seeing Retry for an error with message of \u201cunauthorized: unauthorized to access or create database https://garrensmith.cloudant.com/tickle_production/\u201d  which I believe is a \u201cfailed\u201d job, right?
    
    6. Not all Replicator DB jobs are displaying Start Times in the activity table, though the columns are still sorting on the start times in the replication docs.
    
    7. I'd like to shorten our caveat, so that it remains a one-liner when we eventually constrain line-lengths for block text across the dashboard. Please change the caveat to:
    "Active _replicate jobs are displayed.  Completed and failed jobs are not."
    
    8. Are we going to be able to surface erroring/crashing states for _replicate Activity?  I see that in my earlier mockup, that I left the "State" column out, mostly because I figured that the "Start Time" one would suffice if state would only be showing running jobs. But perhaps I misunderstood. If we can pick up _troubled jobs' replication states, then we definitely should have the state column.
    
    
    
    
    Here is the list of tweaks that I had in [FogBugz](https://cloudant.fogbugz.com/f/cases/81384/), if you'd like all comments consolidated here:
    
    1. On the Replication form, make the URL-entry fields a consistent length. Default document IDs are longer than the current "Replication Document" field, as well, so let's make the field longer, consistent with the lenght of the URL fields. It looks like the remote URL fields are currenly longer (~346px) to match the length of the text string below. I'd be fine if all URL fields and the Rep Doc field were 400px.
    
    2. On the Verify Deletion dialogue box, change the button text so that it accounts for singular and plural doc-deletions. Probably easiest would be to change the text to "Delete Document(s)", otherwise, you could have "Delete Document" for single deletions, and "Delete Documents" for multiple deletions.
    
    3. Change embedded help pop-up text from center-justification to default (left) justification.
    
    4. In the Replication-activity-section header, change "Replication" to "Replication Activity."
    
    5. Breadcrumbs are unnecessary on the new/edit-replication pages, as clicking the main nav takes the user to the exact same place as clicking on "Replication" in the header. So, I think we should remove the "Replication" crumb.
    
    6. Clicking on the edit-replication icon takes the user to the replication form page, where the header nav states "New Replication." "New" is a smidge confusing in the context of editing, but users are able to trigger entirely new replications from the page. So for both entirely "new" replications and replications being edited, lets change that header text to "Replication-Job Details".
    
    7. Increase the margin between the two buttons on the "Fix Document Conflict" dialogue box to 20px. 
    
    Thanks much for all your work on this.
    
    <img width="1008" alt="replication - _replicate activity" src="https://cloud.githubusercontent.com/assets/12969375/23528450/cba81e96-ff4e-11e6-9c36-1c300d9b973b.png">
    <img width="1008" alt="replication - replicator db activity" src="https://cloud.githubusercontent.com/assets/12969375/23528451/cbb1b708-ff4e-11e6-8131-0d2f9a962788.png">
    



---
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 #864: Update replication to work with scheduler...

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

    https://github.com/apache/couchdb-fauxton/pull/864#discussion_r105743029
  
    --- Diff: app/addons/replication/components/replicate-activity.js ---
    @@ -0,0 +1,116 @@
    +// 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.
    +import React from 'react';
    +import {DeleteModal} from './modals';
    +import {ReplicationTable} from './common-table';
    +import {ReplicationHeader} from './common-activity';
    +
    +export default class Activity extends React.Component {
    --- End diff --
    
    This looks a lot like the BulkDeleteController


---
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 #864: Update replication to work with scheduler...

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

    https://github.com/apache/couchdb-fauxton/pull/864#discussion_r105717253
  
    --- Diff: app/addons/replication/components/common-activity.js ---
    @@ -0,0 +1,107 @@
    +// 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.
    +import React from 'react';
    +import {DeleteModal} from './modals';
    +
    +export class BulkDeleteController extends React.Component {
    +  constructor (props) {
    +    super(props);
    +    this.state = {
    +      modalVisible: false,
    +      unconfirmedDeleteDocId: null
    +    };
    +  }
    +
    +  closeModal () {
    +    this.setState({
    +      modalVisible: false,
    +      unconfirmedDeleteDocId: null
    +    });
    +  }
    +
    +  showModal (doc) {
    --- End diff --
    
    Where is this called?  I couldn't quite locate where `showModal` is invoked for BulkDeleteController.


---
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 #864: Update replication to work with scheduler...

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/864#discussion_r105856116
  
    --- Diff: app/addons/replication/components/common-activity.js ---
    @@ -0,0 +1,107 @@
    +// 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.
    +import React from 'react';
    +import {DeleteModal} from './modals';
    +
    +export class BulkDeleteController extends React.Component {
    --- End diff --
    
    Actually good spot. This code is not used anymore. I've removed it.


---
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 #864: Update replication to work with scheduler api

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/864
  
    Hey Garren,
    
    Lookin' good! That section is rather slick. I see a few lingering issues, and a handful of things to polish, and then I think we're good.
    
    Something has changed broken alignment of the values in the replication form:
    ![field alignment](https://cloud.githubusercontent.com/assets/12969375/23669800/571f5bd2-031a-11e7-9e9c-96d857be79f4.png)
    
    And the width for the dropdown values is still not matching the width of the dropdown field (for both source and target local dbs):
    ![dropdowns](https://cloud.githubusercontent.com/assets/12969375/23669846/812658a4-031a-11e7-81e2-ff7fb7d1d886.png)
    
    The doc-conflict buttons could still use some extra space (20px) between them:
    ![screen shot 2017-03-07 at 9 43 58 am](https://cloud.githubusercontent.com/assets/12969375/23669931/d7f368a2-031a-11e7-8da7-2a0967a1de23.png)
    
    I noticed that the job-deleted banner message (and message in the notification center) is picking up more than just the replication number:
    
    ![screen shot 2017-03-07 at 10 39 18 am](https://cloud.githubusercontent.com/assets/12969375/23672199/bc0dfdac-0322-11e7-998c-cc07df8f8ebc.png)
    
    The length is such that I noticed a lack-of-wrapping bug in the notification center, which is something I'll open up a bug on.
    
    ![screen shot 2017-03-07 at 11 00 45 am](https://cloud.githubusercontent.com/assets/12969375/23672977/6664865c-0325-11e7-9758-622a7b32555e.png)
    
    Can we strip off the non-job-id information in that job name, and add a period to the end of the statement?
    
    
    **Some polish and tweaks:**
    
    With only one Action icon on the _replicate Activity table, I think it would be better to align it under the column header:
    
    ![screen shot 2017-03-07 at 9 48 37 am](https://cloud.githubusercontent.com/assets/12969375/23670110/7f650a32-031b-11e7-95e6-19c297c1c32d.png)
    
    I realize that "everybody" permissions terminology is going to be confusing for those who've set permissions using the CL, where the user is "nobody." For the last paragraph in this hoverhelp, I'd like to change the statement to "If the remote database granted permissions to unauthenticated connections, you do not need to enter a username or password."
    ![screen shot 2017-03-07 at 9 52 18 am](https://cloud.githubusercontent.com/assets/12969375/23670372/59f03c4e-031c-11e7-94c1-a4cd440e511a.png)
    
    Let's align the (now shorter) caveats with the text in the first content column (Source) in the tables.  I think that would be 80px from the left.
    
    ![screen shot 2017-03-07 at 9 59 16 am](https://cloud.githubusercontent.com/assets/12969375/23670595/145a18c0-031d-11e7-9b79-6bb7cc3cdce5.png)
    
    ![screen shot 2017-03-07 at 10 02 08 am](https://cloud.githubusercontent.com/assets/12969375/23670630/3c0e6fe2-031d-11e7-9e4d-14640892c899.png)
    
    It would be nice to swap out the white-check icon for the previously used replication icon:
    ![screen shot 2017-03-07 at 10 04 27 am](https://cloud.githubusercontent.com/assets/12969375/23670759/a606a874-031d-11e7-89b4-03da054fa48c.png)
    
    ![screen shot 2017-03-07 at 10 06 30 am](https://cloud.githubusercontent.com/assets/12969375/23670807/d0ae12f6-031d-11e7-9d5f-7ea55dda8acf.png)
    
    And swap the white-check icon on the verify-deletion buttons for trashcan icons:
    
    ![screen shot 2017-03-07 at 10 08 14 am](https://cloud.githubusercontent.com/assets/12969375/23670898/244d77da-031e-11e7-8b6d-617e08926ede.png)
    
    Thanks for your work on 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 issue #864: Update replication to work with scheduler api

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

    https://github.com/apache/couchdb-fauxton/pull/864
  
    > Something has changed broken alignment of the values in the replication form:
    
    This is actually a firefox issue. I've managed to make a work around.
    
    > The length is such that I noticed a lack-of-wrapping bug in the notification center, which is something I'll open up a bug on.
    
    I fixed it.
    
    > Can we strip off the non-job-id information in that job name, and add a period to the end of the statement?
    
    As far as I understand, that is the full replicate id. We cannot strip any part of it off.



---
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 #864: Update replication to work with scheduler api

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/864
  
    Here's the mockup:
    
    <img width="1008" alt="replication job configuration" src="https://cloud.githubusercontent.com/assets/12969375/23628932/edf63806-026a-11e7-949a-1224760807ac.png">
    
    So, no tab on this page. And instead of "Replication > New Replication" or the proposed "Replication-Job Details," I think "Job Configuration" in the header will be a better descriptor.  Because you can edit an existing job on this page, "New" isn't exactly correct (though I know an edited job is just a new job on the back of a stopped one).
    
    I know you're mid-way through this, and the beta doesn't necessarily reflect the most recent work, so apologies if this is already on your radar, but the local source/target dropdown component doesn't yet match the length of the longer dropdown field.
    
    Also, I realized that we can now remove some of the text from our Verify Deletion error messages, now that replicator and _replicate have separate tabs.  Also, we need to change some of the button text, as _replicate deletions don't involve deleting a document.
    
    Here are the messages, varying on whether deletion is triggered through the bulk selector, or in the table-row trashcan icons: 
    
    <img width="428" alt="replication - verify single deletion dialogue" src="https://cloud.githubusercontent.com/assets/12969375/23630045/6315d04e-026e-11e7-9f24-5f5eab144b50.png">
    <img width="428" alt="replication - verify deletions dialogue" src="https://cloud.githubusercontent.com/assets/12969375/23630044/6314733e-026e-11e7-8c5a-475f3cf9c6b6.png">
    
    Thanks for the work on this. It's looking great.



---
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 #864: Update replication to work with scheduler api

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

    https://github.com/apache/couchdb-fauxton/pull/864
  
    @justin-mcdavid-ibm I've made some of the changes. Others of them I have some comments:
    
    > I'm sorry for the confusion in the mockups, but I think we should keep the "New Replication" button in place for Replicator DB Activity, and add it to the _replicate Activity tab as well, even though both buttons will only be capable of triggering a replicator db job. My mistake here; I think we want to try and maintain the cohesive pattern of "new" buttons above the table across the dashboard, and when it comes time to add "Advanced Replication" to the mix, we can do so still maintaining that pattern. Updated mockups below.
    
    I'm a little confused on this. Do you still want a tab for the new replications? Can you do a quick mockup of how the `new replication page` now looks?
    
    > Hovering over the state should result in the state time displaying.
    
    We don't always get the state time returned. So its only displayed on hover if we get it. It seems that completed don't get the time.
    
    > The \u201cRetrying\u201d state should only be for for jobs that are actually being retried. Auth errors aren\u2019t retried, are they? I\u2019m seeing Retry for an error with message of \u201cunauthorized: unauthorized to access or create database https://garrensmith.cloudant.com/tickle_production/\u201d which I believe is a \u201cfailed\u201d job, right?
    
    I agree. I followed the mock up comments of `"Retrying" shown for both "Error" state and "Crashing" state.`. The auth state is an Error state.
    
    > Not all Replicator DB jobs are displaying Start Times in the activity table, though the columns are still sorting on the start times in the replication docs.
    
    The start time isn't always returned.


---
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 #864: Update replication to work with scheduler api

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

    https://github.com/apache/couchdb-fauxton/pull/864
  
    +1 after tests


---
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 #864: Update replication to work with scheduler...

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

    https://github.com/apache/couchdb-fauxton/pull/864#discussion_r105718172
  
    --- Diff: app/addons/replication/components/common-activity.js ---
    @@ -0,0 +1,107 @@
    +// 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.
    +import React from 'react';
    +import {DeleteModal} from './modals';
    +
    +export class BulkDeleteController extends React.Component {
    --- End diff --
    
    Is this class used anywhere?


---
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 #864: Update replication to work with scheduler...

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

    https://github.com/apache/couchdb-fauxton/pull/864#discussion_r105683957
  
    --- Diff: app/addons/replication/actions.js ---
    @@ -171,13 +298,20 @@ const deleteDocs = (docs) => {
       });
     };
     
    -const getReplicationStateFrom = (id) => {
    -  $.ajax({
    -    url: `${app.host}/_replicator/${encodeURIComponent(id)}`,
    -    contentType: 'application/json',
    -    dataType: 'json',
    +export const getReplicationStateFrom = (id) => {
    --- End diff --
    
    Minor thing but should this be `Form` and not `From`?


---
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 #864: Update replication to work with scheduler...

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/864#discussion_r105913826
  
    --- Diff: app/addons/replication/controller.js ---
    @@ -186,25 +208,79 @@ export default class ReplicationController extends React.Component {
               max={600}
               startValue={300}
               stepSize={60}
    -          onPoll={Actions.getReplicationActivity}
    +          onPoll={this.getAllActivity.bind(this)}
               />
             <RefreshBtn
    -          refresh={Actions.getReplicationActivity}
    +          refresh={this.getAllActivity.bind(this)}
               />
           </div>
         );
       }
     
    +  getTabElements () {
    +    const {tabSection} = this.state;
    +    const elements = [
    +      <TabElement
    +        key={1}
    +        selected={tabSection === 'activity'}
    +        text={"Replicator DB Activity"}
    +        onChange={this.onTabChange.bind(this, 'activity', '#/replication')}
    +      />
    +    ];
    +
    +    if (this.state.supportNewApi) {
    +      elements.push(
    +        <TabElement
    +          key={2}
    +          selected={tabSection === '_replicate'}
    +          text={"_replicate Activity"}
    +          onChange={this.onTabChange.bind(this, '_replicate', '#/replication/_replicate')}
    +        />
    +      );
    +    }
    +
    +    return elements;
    +  }
    +
    +  onTabChange (section, url) {
    +    Actions.changeTabSection(section, url);
    +  }
    +
    +  getCrumbs () {
    +    if (this.state.tabSection === 'new replication') {
    +      return [{'name': 'Job Configuration'}];
    +    }
    +
    +    return [];
    +  }
    +
    +  getTabs () {
    +    if (this.state.tabSection === 'new replication') {
    +      return null;
    +    }
    +
    +    return (
    +      <TabElementWrapper>
    +        {this.getTabElements()}
    +      </TabElementWrapper>
    +    );
    +  }
    +
       render () {
    +    const { checkingAPI } = this.state;
    +
    +    if (checkingAPI) {
    --- End diff --
    
    I think its a personal preference thing. I would prefer to leave as is.


---
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 #864: Update replication to work with scheduler...

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/864#discussion_r105855027
  
    --- Diff: app/addons/replication/actions.js ---
    @@ -171,13 +298,20 @@ const deleteDocs = (docs) => {
       });
     };
     
    -const getReplicationStateFrom = (id) => {
    -  $.ajax({
    -    url: `${app.host}/_replicator/${encodeURIComponent(id)}`,
    -    contentType: 'application/json',
    -    dataType: 'json',
    +export const getReplicationStateFrom = (id) => {
    --- End diff --
    
    No, that is correct. Its getting the replication state from a document with `id`


---
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 #864: Update replication to work with scheduler...

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

    https://github.com/apache/couchdb-fauxton/pull/864#discussion_r105717406
  
    --- Diff: app/addons/replication/components/common-activity.js ---
    @@ -0,0 +1,107 @@
    +// 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.
    +import React from 'react';
    +import {DeleteModal} from './modals';
    +
    +export class BulkDeleteController extends React.Component {
    +  constructor (props) {
    +    super(props);
    +    this.state = {
    +      modalVisible: false,
    +      unconfirmedDeleteDocId: null
    +    };
    +  }
    +
    +  closeModal () {
    +    this.setState({
    +      modalVisible: false,
    +      unconfirmedDeleteDocId: null
    +    });
    +  }
    +
    +  showModal (doc) {
    +    this.setState({
    +      modalVisible: true,
    +      unconfirmedDeleteDocId: doc
    --- End diff --
    
    Wouldn't this be `unconfirmedDeleteDocId: doc._id`?


---
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 #864: Update replication to work with scheduler...

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

    https://github.com/apache/couchdb-fauxton/pull/864#discussion_r105743148
  
    --- Diff: app/addons/replication/components/replicate-activity.js ---
    @@ -0,0 +1,116 @@
    +// 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.
    +import React from 'react';
    +import {DeleteModal} from './modals';
    +import {ReplicationTable} from './common-table';
    +import {ReplicationHeader} from './common-activity';
    +
    +export default class Activity extends React.Component {
    +  constructor (props) {
    +    super(props);
    +    this.state = {
    +      modalVisible: false,
    +      unconfirmedDeleteDocId: null
    +    };
    +  }
    +
    +  closeModal () {
    +    this.setState({
    +      modalVisible: false,
    +      unconfirmedDeleteDocId: null
    +    });
    +  }
    +
    +  showModal (doc) {
    +    this.setState({
    +      modalVisible: true,
    +      unconfirmedDeleteDocId: doc
    --- End diff --
    
    Can we rename `doc` to `docId` or something similar to avoid confusion with what this argument is supposed to represent?


---
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 #864: Update replication to work with scheduler...

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

    https://github.com/apache/couchdb-fauxton/pull/864#discussion_r105734625
  
    --- Diff: app/addons/replication/components/common-table.js ---
    @@ -0,0 +1,406 @@
    +// 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.
    +import React from 'react';
    +import {Table, Tooltip, OverlayTrigger} from "react-bootstrap";
    +import moment from 'moment';
    +import {ErrorModal} from './modals';
    +
    +const formatUrl = (url) => {
    +  const urlObj = new URL(url);
    +  const encoded = encodeURIComponent(urlObj.pathname.slice(1));
    +
    +  if (url.indexOf(window.location.hostname) > -1) {
    +    return (
    +      <span>
    +        {urlObj.origin + '/'}
    +        <a href={`#/database/${encoded}/_all_docs`}>{urlObj.pathname.slice(1)}</a>
    +      </span>
    +    );
    +  }
    +
    +  return `${urlObj.origin}${urlObj.pathname}`;
    +};
    +
    +class RowStatus extends React.Component {
    +  constructor (props) {
    +    super(props);
    +    this.state = {
    +      modalVisible: false,
    +    };
    +  }
    +
    +  showModal () {
    +    this.setState({modalVisible: true});
    +  }
    +
    +  closeModal () {
    +    this.setState({modalVisible: false});
    +  }
    +
    +  getErrorIcon () {
    +    const {status} = this.props;
    +    if (status !== 'error' && status !== 'retrying') {
    +      return null;
    +    }
    +
    +    return (
    +      <span>
    +        <a
    +          data-bypass="true"
    +          className="replication__row-btn replication__row-btn--warning icon-exclamation-sign"
    +          onClick={this.showModal.bind(this)}
    +          title="View error message">
    +        </a>
    +        <ErrorModal
    +          onClick={this.closeModal.bind(this)}
    +          onClose={this.closeModal.bind(this)}
    +          errorMsg={this.props.errorMsg}
    +          visible={this.state.modalVisible}
    +          status={status}
    +        />
    +      </span>
    +    );
    +  }
    +
    +  render () {
    +    const {statusTime, status} = this.props;
    +    let momentTime = moment(statusTime);
    +    let statusValue = <span>{status}</span>;
    +
    +    if (momentTime.isValid()) {
    +      const formattedStatusTime = momentTime.format("MMM Do, h:mm a");
    +      const stateTimeTooltip = <Tooltip id="">Last updated: {formattedStatusTime}</Tooltip>;
    +      statusValue =
    +        <OverlayTrigger placement="top" overlay={stateTimeTooltip}>
    +          <span>{status}</span>
    +        </OverlayTrigger>;
    +    }
    +
    +    return (
    +      <td className={`replication__row-status replication__row-status--${status}`}>
    +        {statusValue}
    +        {this.getErrorIcon()}
    +      </td>
    +    );
    +  }
    +};
    +
    +RowStatus.propTypes = {
    +  statusTime: React.PropTypes.any,
    +  status: React.PropTypes.string,
    +  errorMsg: React.PropTypes.string.isRequired,
    +};
    +
    +RowStatus.defaultProps = {
    +  status: ''
    +};
    +
    +const RowActions = ({onlyDeleteAction, _id, url, deleteDocs}) => {
    +  const actions = [];
    +  if (!onlyDeleteAction) {
    +    actions.push(
    +      <li className="replication__row-list" key={1}>
    +        <a
    +          href={`#replication/id/${encodeURIComponent(_id)}`}
    +          className="replication__row-btn icon-wrench replication__row-btn--no-left-pad"
    +          title={`Edit replication`}
    --- End diff --
    
    Can this be converted to a static string?


---
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 #864: Update replication to work with scheduler...

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

    https://github.com/apache/couchdb-fauxton/pull/864#discussion_r105750432
  
    --- Diff: app/addons/replication/stores.js ---
    @@ -77,6 +110,23 @@ const ReplicationStore = FauxtonAPI.Store.extend({
         this._activitySort = sort;
       },
     
    +  isReplicateInfoLoading () {
    +    return this._fetchingReplicateInfo;
    +  },
    +
    +  getReplicateInfo () {
    +    return this._replicateInfo.filter(doc => {
    +      return _.values(doc).filter(item => {
    +        if (!item) {return null;}
    --- End diff --
    
    Minor but can we change this to return `false`?  I feel like it'd be more readable when considering `filter` keeps/discards items based on boolean values.


---
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 #864: Update replication to work with scheduler...

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

    https://github.com/apache/couchdb-fauxton/pull/864#discussion_r105711712
  
    --- Diff: app/addons/replication/api.js ---
    @@ -228,38 +255,176 @@ export const parseReplicationDocs = (rows) => {
           status: doc._replication_state,
           errorMsg: doc._replication_state_reason ? doc._replication_state_reason : '',
           statusTime: new Date(doc._replication_state_time),
    -      url: `#/database/_replicator/${app.utils.getSafeIdForDoc(doc._id)}`,
    +      startTime: new Date(doc._replication_start_time),
    +      url: `#/database/_replicator/${encodeURIComponent(doc._id)}`,
           raw: doc
         };
       });
     };
     
    +export const convertState = (state) => {
    +  if (state.toLowerCase() === 'error' || state.toLowerCase() === 'crashing') {
    +    return 'retrying';
    +  }
    +
    +  return state;
    +};
    +
    +export const combineDocsAndScheduler = (docs, schedulerDocs) => {
    +  return docs.map(doc => {
    +    const schedule = schedulerDocs.find(s => s.doc_id === doc._id);
    +    if (!schedule) {
    +      return doc;
    +    }
    +
    +    doc.status = convertState(schedule.state);
    +    if (schedule.start_time) {
    +      doc.startTime = new Date(schedule.start_time);
    +    }
    +
    +    if (schedule.last_updated) {
    +      doc.stateTime = new Date(schedule.last_updated);
    +    }
    +
    +    return doc;
    +  });
    +};
    +
     export const fetchReplicationDocs = () => {
    -  return $.ajax({
    -    type: 'GET',
    -    url: '/_replicator/_all_docs?include_docs=true&limit=100',
    -    contentType: 'application/json; charset=utf-8',
    -    dataType: 'json',
    -  }).then((res) => {
    -    return parseReplicationDocs(res.rows.filter(row => row.id.indexOf("_design/_replicator") === -1));
    +  return supportNewApi()
    +  .then(newApi => {
    +    const docsPromise = fetch('/_replicator/_all_docs?include_docs=true&limit=100', {
    +      credentials: 'include',
    +      headers: {
    +        'Accept': 'application/json; charset=utf-8',
    +      }
    +    })
    +    .then(res => res.json())
    +    .then((res) => {
    +      if (res.error) {
    +        return [];
    +      }
    +
    +      return parseReplicationDocs(res.rows.filter(row => row.id.indexOf("_design/_replicator") === -1));
    +    });
    +
    +    if (!newApi) {
    +      return docsPromise;
    +    }
    +    const schedulerPromise = fetchSchedulerDocs();
    +    return FauxtonAPI.Promise.join(docsPromise, schedulerPromise, (docs, schedulerDocs) => {
    +      return combineDocsAndScheduler(docs, schedulerDocs);
    +    })
    +    .catch(() => {
    +      return [];
    +    });
    +  });
    +};
    +
    +export const fetchSchedulerDocs = () => {
    +  return fetch('/_scheduler/docs?include_docs=true', {
    +    credentials: 'include',
    +    headers: {
    +      'Accept': 'application/json; charset=utf-8',
    +    }
    +  })
    +  .then(res => res.json())
    +  .then((res) => {
    +    if (res.error) {
    +      return [];
    +    }
    +
    +    return res.docs;
       });
     };
     
     export const checkReplicationDocID = (docId) => {
       const promise = FauxtonAPI.Deferred();
    -  $.ajax({
    -    type: 'GET',
    -    url: `/_replicator/${docId}`,
    -    contentType: 'application/json; charset=utf-8',
    -    dataType: 'json',
    -  }).then(() => {
    -    promise.resolve(true);
    -  }, function (xhr) {
    -    if (xhr.statusText === "Object Not Found") {
    +  fetch(`/_replicator/${docId}`, {
    +    credentials: 'include',
    +    headers: {
    +      'Accept': 'application/json; charset=utf-8'
    +    },
    +  }).then(resp => {
    +    if (resp.statusText === "Object Not Found") {
           promise.resolve(false);
           return;
         }
         promise.resolve(true);
       });
       return promise;
     };
    +
    +export const parseReplicateInfo = (resp) => {
    +  return resp.jobs.filter(job => job.database === null).map(job => {
    +    return {
    +      _id: job.id,
    +      source: getDocUrl(job.source.slice(0, job.source.length - 1)),
    +      target: getDocUrl(job.target.slice(0, job.target.length - 1)),
    +      startTime: new Date(job.start_time),
    +      statusTime: new Date(job.last_updated),
    +      //making an asumption here that the first element is the latest
    +      status: convertState(job.history[0].type),
    +      errorMsg: '',
    +      selected: false,
    +      continuous: /continuous/.test(job.id),
    +      raw: job
    +    };
    +  });
    +};
    +
    +export const fetchReplicateInfo = () => {
    +  return supportNewApi()
    +  .then(newApi => {
    +    if (!newApi) {
    +      return [];
    +    }
    +
    +    return fetch('/_scheduler/jobs', {
    +      credentials: 'include',
    +      headers: {
    +        'Accept': 'application/json; charset=utf-8'
    +      },
    +    })
    +    .then(resp => resp.json())
    +    .then(resp => {
    +      return parseReplicateInfo(resp);
    +    });
    +  });
    +};
    +
    +export const deleteReplicatesApi = (replicates) => {
    +  const promises = replicates.map(replicate => {
    +    const data = {
    +      replication_id: replicate._id,
    +      cancel: true
    +    };
    +
    +    return fetch('/_replicate', {
    +      method: 'POST',
    +      credentials: 'include',
    +      headers: {
    +        'Accept': 'application/json; charset=utf-8',
    +        'Content-Type': 'application/json'
    +      },
    +      body: JSON.stringify(data)
    +    })
    +    .then(resp => resp.json());
    +  });
    +
    +  return FauxtonAPI.Promise.all(promises);
    +};
    +
    +export const createReplicatorDB = () => {
    +  return fetch('/_replicator', {
    +    method: 'PUT',
    +    credentials: 'include',
    +    headers: {
    +        'Accept': 'application/json; charset=utf-8',
    +      }
    +    })
    +    .then(res => res.json())
    +    .then(() => {
    +      return true;
    --- End diff --
    
    This looks like it could just fail silently if the PUT fails.  I'd recommend being a little more defensive here if it's not too difficult.


---
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 #864: Update replication to work with scheduler...

Posted by garrensmith <gi...@git.apache.org>.
Github user garrensmith closed the pull request at:

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


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