瀏覽代碼

Render object fields with no dest options values

The object fields should now render even though they don't have values
from the destination options API call.

This happens, for example, when editing an Openstack replica and its
dest-options call is disabled in `config.js`.
Sergiu Miclea 7 年之前
父節點
當前提交
774f3abe71
共有 2 個文件被更改,包括 10 次插入3 次删除
  1. 8 2
      src/plugins/endpoint/default/ConnectionSchemaPlugin.js
  2. 2 1
      src/stores/ProviderStore.js

+ 8 - 2
src/plugins/endpoint/default/ConnectionSchemaPlugin.js

@@ -22,14 +22,20 @@ export const defaultSchemaToFields = (schema: SchemaProperties, schemaDefinition
   let fields = Object.keys(schema.properties).map(fieldName => {
   let fields = Object.keys(schema.properties).map(fieldName => {
     let properties: any = schema.properties[fieldName]
     let properties: any = schema.properties[fieldName]
 
 
-    if (typeof schema.properties[fieldName].$ref === 'string' && schemaDefinitions) {
-      const definitionName = schema.properties[fieldName].$ref.substr(schema.properties[fieldName].$ref.lastIndexOf('/') + 1)
+    if (typeof properties.$ref === 'string' && schemaDefinitions) {
+      const definitionName = properties.$ref.substr(properties.$ref.lastIndexOf('/') + 1)
       properties = schemaDefinitions[definitionName]
       properties = schemaDefinitions[definitionName]
       return {
       return {
         name: fieldName,
         name: fieldName,
         type: properties.type ? properties.type : '',
         type: properties.type ? properties.type : '',
         properties: properties.properties ? defaultSchemaToFields(properties, null, fieldName) : [],
         properties: properties.properties ? defaultSchemaToFields(properties, null, fieldName) : [],
       }
       }
+    } else if (properties.type === 'object' && properties.properties && Object.keys(properties.properties).length) {
+      return {
+        name: fieldName,
+        type: 'object',
+        properties: defaultSchemaToFields(properties, null, fieldName),
+      }
     }
     }
 
 
     const name = parent ? `${parent}/${fieldName}` : fieldName
     const name = parent ? `${parent}/${fieldName}` : fieldName

+ 2 - 1
src/stores/ProviderStore.js

@@ -119,8 +119,9 @@ class ProviderStore {
     return ProviderSource.loadDestinationSchema(providerName, schemaType).then((fields: Field[]) => {
     return ProviderSource.loadDestinationSchema(providerName, schemaType).then((fields: Field[]) => {
       this.destinationSchemaLoading = false
       this.destinationSchemaLoading = false
       this.destinationSchema = fields
       this.destinationSchema = fields
-    }).catch(() => {
+    }).catch(err => {
       this.destinationSchemaLoading = false
       this.destinationSchemaLoading = false
+      throw err
     })
     })
   }
   }