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

Merge pull request #474 from smiclea/improve-edit-options

Improve Edit Replica options loading
Nashwan Azhari 6 лет назад
Родитель
Сommit
cbe4691963
2 измененных файлов с 5 добавлено и 3 удалено
  1. 4 2
      src/components/organisms/EditReplica/EditReplica.jsx
  2. 1 1
      src/stores/ProviderStore.js

+ 4 - 2
src/components/organisms/EditReplica/EditReplica.jsx

@@ -120,8 +120,9 @@ class EditReplica extends React.Component<Props, State> {
 
 
     let loadAllOptions = async (type: 'source' | 'destination') => {
     let loadAllOptions = async (type: 'source' | 'destination') => {
       let endpoint = type === 'source' ? this.props.sourceEndpoint : this.props.destinationEndpoint
       let endpoint = type === 'source' ? this.props.sourceEndpoint : this.props.destinationEndpoint
+      let envData = type === 'source' ? this.props.replica.source_environment : this.props.replica.destination_environment
       try {
       try {
-        await this.loadOptions(endpoint, type, useCache)
+        await this.loadOptions(endpoint, type, useCache, envData)
         this.loadExtraOptions(null, type, useCache)
         this.loadExtraOptions(null, type, useCache)
       } catch (err) {
       } catch (err) {
         if (type === 'source') {
         if (type === 'source') {
@@ -139,7 +140,7 @@ class EditReplica extends React.Component<Props, State> {
     loadAllOptions('destination')
     loadAllOptions('destination')
   }
   }
 
 
-  async loadOptions(endpoint: Endpoint, optionsType: 'source' | 'destination', useCache: boolean) {
+  async loadOptions(endpoint: Endpoint, optionsType: 'source' | 'destination', useCache: boolean, envData: ?{ [string]: mixed }) {
     await providerStore.loadOptionsSchema({
     await providerStore.loadOptionsSchema({
       providerName: endpoint.type,
       providerName: endpoint.type,
       schemaType: this.props.type || 'replica',
       schemaType: this.props.type || 'replica',
@@ -151,6 +152,7 @@ class EditReplica extends React.Component<Props, State> {
       endpointId: endpoint.id,
       endpointId: endpoint.id,
       providerName: endpoint.type,
       providerName: endpoint.type,
       useCache,
       useCache,
+      envData,
     })
     })
   }
   }
 
 

+ 1 - 1
src/stores/ProviderStore.js

@@ -194,7 +194,7 @@ class ProviderStore {
     optionsType: 'source' | 'destination',
     optionsType: 'source' | 'destination',
     endpointId: string,
     endpointId: string,
     providerName: string,
     providerName: string,
-    envData?: { [string]: mixed },
+    envData?: ?{ [string]: mixed },
     useCache?: boolean,
     useCache?: boolean,
     quietError?: boolean,
     quietError?: boolean,
   }): Promise<OptionValues[]> {
   }): Promise<OptionValues[]> {