Просмотр исходного кода

Adds helper method to convert cloud labels and fields CORWEB-37

George Vrancianu 8 лет назад
Родитель
Сommit
c1292af17c

+ 0 - 1
src/actions/ConnectionsActions/ConnectionsActions.js

@@ -177,7 +177,6 @@ ConnectionsActions.saveEditEndpoint.listen((connection, data, callback = null) =
     method: "PUT",
     data: payload
   }).then((response) => {
-    console.log("CALLBACK", callback)
     if (typeof callback === "function") {
       callback(response)
     }

+ 2 - 2
src/components/CloudConnectionAuth/CloudConnectionAuth.js

@@ -18,7 +18,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 import React, { Component, PropTypes } from 'react';
 import withStyles from 'isomorphic-style-loader/lib/withStyles';
 import s from './CloudConnectionAuth.scss';
-import { defaultLabels } from '../../constants/CloudLabels';
+import Helper from '../Helper';
 import LoadingIcon from "../LoadingIcon/LoadingIcon";
 
 
@@ -56,7 +56,7 @@ class CloudConnectionAuth extends Component {
         if (value === false) value = "No"
 
         fields.push({
-          fieldName: defaultLabels[fieldName] ? defaultLabels[fieldName] : fieldName,
+          fieldName: Helper.convertCloudFieldLabel(fieldName),
           fieldValue: value
         })
       }

+ 2 - 3
src/components/CloudConnectionDetail/CloudConnectionDetail.js

@@ -20,7 +20,6 @@ import withStyles from 'isomorphic-style-loader/lib/withStyles';
 import s from './CloudConnectionDetail.scss';
 import Moment from 'react-moment';
 import LoadingIcon from '../LoadingIcon';
-import { defaultLabels } from '../../constants/CloudLabels';
 import Helper from '../Helper';
 
 const title = 'connection details';
@@ -61,7 +60,7 @@ class CloudConnectionDetail extends Component {
         if (value === false) value = "No"
 
         fields.push({
-          fieldName: defaultLabels[fieldName] ? defaultLabels[fieldName] : fieldName,
+          fieldName: Helper.convertCloudFieldLabel(fieldName),
           fieldValue: value
         })
       }
@@ -135,7 +134,7 @@ class CloudConnectionDetail extends Component {
                 Type
               </div>
               <div className={s.value}>
-                {item.type}
+                {Helper.convertCloudLabel(item.type)}
               </div>
             </div>
             <div className={s.formGroup}>

+ 9 - 0
src/components/Helper/Helper.js

@@ -17,6 +17,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import { Component } from 'react';
 import moment from 'moment';
+import { cloudLabels, defaultLabels } from '../../constants/CloudLabels';
 
 class Helper extends Component {
   static getRandomArbitrary(min, max) {
@@ -40,6 +41,14 @@ class Helper extends Component {
     }
     return hiddenPass
   }
+
+  static convertCloudFieldLabel(label) {
+    return defaultLabels[label] || label
+  }
+
+  static convertCloudLabel(label) {
+    return cloudLabels[label] || label
+  }
 }
 
 export default Helper;

+ 4 - 5
src/components/WizardSummary/WizardSummary.js

@@ -20,8 +20,7 @@ import withStyles from 'isomorphic-style-loader/lib/withStyles';
 import s from './WizardSummary.scss';
 import moment from 'moment';
 import TextTruncate from 'react-text-truncate';
-import { defaultLabels } from '../../constants/CloudLabels';
-
+import Helper from '../Helper';
 
 const title = 'Summary';
 
@@ -54,7 +53,7 @@ class WizardSummary extends Component {
     let fields = []
     for (let i in this.props.summary.destination_environment) {
       fields.push({
-        label: defaultLabels[i] ? defaultLabels[i] : i,
+        label: Helper.convertCloudFieldLabel(i),
         value: this.props.summary.destination_environment[i]
       })
     }
@@ -128,14 +127,14 @@ class WizardSummary extends Component {
                   <span>Source: <br /> </span>
                   <span>
                     <TextTruncate line={1} text={this.props.summary.sourceCloud.credential.name} truncateText="..." />
-                    <span className={s.cloudBox}>{this.props.summary.sourceCloud.name}</span>
+                    <span className={s.cloudBox}>{Helper.convertCloudLabel(this.props.summary.sourceCloud.name)}</span>
                   </span>
                 </div>
                 <div className={s.row}>
                   <span>Target:</span>
                   <span>
                     <TextTruncate line={1} text={this.props.summary.targetCloud.credential.name} truncateText="..." />
-                    <span className={s.cloudBox}>{this.props.summary.targetCloud.name}</span>
+                    <span className={s.cloudBox}>{Helper.convertCloudLabel(this.props.summary.targetCloud.name)}</span>
                   </span>
                 </div>
               </div>

+ 4 - 0
src/constants/CloudLabels.js

@@ -59,3 +59,7 @@ export const defaultLabels = {
   allow_untrusted_swift: "Allow Untrusted Swift",
   glance_api_version: "Glance API Version"
 }
+
+export const cloudLabels = {
+  vmware_vsphere: 'vmware'
+}

+ 2 - 3
src/stores/ConnectionsStore/ConnectionsStore.js

@@ -21,9 +21,8 @@
 import React, { Component, PropTypes } from 'react';
 import Reflux from 'reflux';
 import ConnectionsActions from '../../actions/ConnectionsActions';
-import WizardActions from '../../actions/WizardActions';
 import MigrationActions from '../../actions/MigrationActions';
-import { defaultLabels } from '../../constants/CloudLabels';
+import Helper from '../../components/Helper';
 import Api from '../../components/ApiCaller'
 import {servicesUrl, providerType} from '../../config';
 
@@ -343,7 +342,7 @@ class ConnectionsStore extends Reflux.Store
       for (var propName in cloudData.properties) {
         let field = {
           name: propName,
-          label: defaultLabels[propName] ? defaultLabels[propName] : propName
+          label: Helper.convertCloudFieldLabel(propName)
         }
 
         if (cloudData.properties[propName].default) {