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

Improve Edit Replica options loading

Fixes an issue where destination options would not load if Edit Replica
is opened while destination options call is already made in Replica
Details Page.
Sergiu Miclea 6 лет назад
Родитель
Сommit
59ea267e24
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[]> {