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 [email protected] or file a JIRA ticket
with INFRA.
---