Преглед изворни кода

Enable copying of every value in endpoint details

Before this patch, only fields containing URLs could be copied.
Sergiu Miclea пре 8 година
родитељ
комит
71dfcddcac
1 измењених фајлова са 11 додато и 13 уклоњено
  1. 11 13
      src/components/organisms/EndpointDetailsContent/EndpointDetailsContent.jsx

+ 11 - 13
src/components/organisms/EndpointDetailsContent/EndpointDetailsContent.jsx

@@ -74,10 +74,6 @@ class EndpointDetailsContent extends React.Component {
     onEditClick: PropTypes.func,
     onEditClick: PropTypes.func,
   }
   }
 
 
-  isUrl(value) {
-    return /^https?:\/\//.test(value)
-  }
-
   renderConnectionInfoLoading() {
   renderConnectionInfoLoading() {
     if (!this.props.loading) {
     if (!this.props.loading) {
       return null
       return null
@@ -124,10 +120,8 @@ class EndpointDetailsContent extends React.Component {
 
 
       if (key === 'password') {
       if (key === 'password') {
         valueClass = <PasswordValue value={value} />
         valueClass = <PasswordValue value={value} />
-      } else if (this.isUrl(value)) {
-        valueClass = <CopyValue value={value} maxWidth="90%" />
       } else {
       } else {
-        valueClass = <Value>{value}</Value>
+        valueClass = this.renderValue(value)
       }
       }
 
 
       return (
       return (
@@ -153,28 +147,32 @@ class EndpointDetailsContent extends React.Component {
     )
     )
   }
   }
 
 
+  renderValue(value) {
+    return <CopyValue value={value} maxWidth="90%" />
+  }
+
   render() {
   render() {
     this.renderedKeys = {}
     this.renderedKeys = {}
-
+    const { type, name, description, created_at } = this.props.item
     return (
     return (
       <Wrapper>
       <Wrapper>
-        <EndpointLogos endpoint={this.props.item.type} />
+        <EndpointLogos endpoint={type} />
         <Info>
         <Info>
           <Field>
           <Field>
             <Label>Name</Label>
             <Label>Name</Label>
-            <Value>{this.props.item.name}</Value>
+            {this.renderValue(name)}
           </Field>
           </Field>
           <Field>
           <Field>
             <Label>Type</Label>
             <Label>Type</Label>
-            <Value>{this.props.item.type}</Value>
+            {this.renderValue(type)}
           </Field>
           </Field>
           <Field>
           <Field>
             <Label>Description</Label>
             <Label>Description</Label>
-            <Value>{this.props.item.description || '-'}</Value>
+            {description ? this.renderValue(description) : <Value>-</Value>}
           </Field>
           </Field>
           <Field>
           <Field>
             <Label>Created</Label>
             <Label>Created</Label>
-            <Value>{DateUtils.getLocalTime(this.props.item.created_at).format('DD/MM/YYYY HH:mm')}</Value>
+            {this.renderValue(DateUtils.getLocalTime(created_at).format('DD/MM/YYYY HH:mm'))}
           </Field>
           </Field>
           {this.renderConnectionInfoLoading()}
           {this.renderConnectionInfoLoading()}
           {this.renderConnectionInfo(this.props.connectionInfo)}
           {this.renderConnectionInfo(this.props.connectionInfo)}