|
@@ -161,6 +161,8 @@ class ProviderStore {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ loadOptionsSchemaLastReqId: string = ''
|
|
|
|
|
+
|
|
|
@action async loadOptionsSchema(options: {
|
|
@action async loadOptionsSchema(options: {
|
|
|
providerName: string,
|
|
providerName: string,
|
|
|
optionsType: 'source' | 'destination',
|
|
optionsType: 'source' | 'destination',
|
|
@@ -175,18 +177,28 @@ class ProviderStore {
|
|
|
this.destinationSchemaLoading = true
|
|
this.destinationSchemaLoading = true
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ const reqId = `${providerName}-${optionsType}`
|
|
|
|
|
+ this.loadOptionsSchemaLastReqId = reqId
|
|
|
|
|
+
|
|
|
try {
|
|
try {
|
|
|
let fields: Field[] = await ProviderSource.loadOptionsSchema(providerName, optionsType, useCache, quietError)
|
|
let fields: Field[] = await ProviderSource.loadOptionsSchema(providerName, optionsType, useCache, quietError)
|
|
|
- this.loadOptionsSchemaSuccess(fields, optionsType)
|
|
|
|
|
|
|
+ this.loadOptionsSchemaSuccess(fields, optionsType, this.loadOptionsSchemaLastReqId === reqId)
|
|
|
return fields
|
|
return fields
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
|
throw err
|
|
throw err
|
|
|
} finally {
|
|
} finally {
|
|
|
- this.loadOptionsSchemaDone(optionsType)
|
|
|
|
|
|
|
+ this.loadOptionsSchemaDone(optionsType, this.loadOptionsSchemaLastReqId === reqId)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @action loadOptionsSchemaSuccess(fields: Field[], optionsType: 'source' | 'destination') {
|
|
|
|
|
|
|
+ @action loadOptionsSchemaSuccess(
|
|
|
|
|
+ fields: Field[],
|
|
|
|
|
+ optionsType: 'source' | 'destination',
|
|
|
|
|
+ isValid: boolean,
|
|
|
|
|
+ ) {
|
|
|
|
|
+ if (!isValid) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
if (optionsType === 'source') {
|
|
if (optionsType === 'source') {
|
|
|
this.sourceSchema = fields
|
|
this.sourceSchema = fields
|
|
|
} else {
|
|
} else {
|
|
@@ -194,7 +206,10 @@ class ProviderStore {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @action loadOptionsSchemaDone(optionsType: 'source' | 'destination') {
|
|
|
|
|
|
|
+ @action loadOptionsSchemaDone(optionsType: 'source' | 'destination', isValid: boolean) {
|
|
|
|
|
+ if (!isValid) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
if (optionsType === 'source') {
|
|
if (optionsType === 'source') {
|
|
|
this.sourceSchemaLoading = false
|
|
this.sourceSchemaLoading = false
|
|
|
} else {
|
|
} else {
|
|
@@ -202,6 +217,8 @@ class ProviderStore {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ getOptionsValuesLastReqId: string = ''
|
|
|
|
|
+
|
|
|
async getOptionsValues(config: {
|
|
async getOptionsValues(config: {
|
|
|
optionsType: 'source' | 'destination',
|
|
optionsType: 'source' | 'destination',
|
|
|
endpointId: string,
|
|
endpointId: string,
|
|
@@ -229,9 +246,17 @@ class ProviderStore {
|
|
|
}
|
|
}
|
|
|
this.getOptionsValuesStart(optionsType, !envData)
|
|
this.getOptionsValuesStart(optionsType, !envData)
|
|
|
|
|
|
|
|
|
|
+ const reqId = `${endpointId}-${providerType}`
|
|
|
|
|
+ this.getOptionsValuesLastReqId = reqId
|
|
|
|
|
+
|
|
|
try {
|
|
try {
|
|
|
let options = await ProviderSource.getOptionsValues(optionsType, endpointId, envData, useCache, quietError)
|
|
let options = await ProviderSource.getOptionsValues(optionsType, endpointId, envData, useCache, quietError)
|
|
|
- this.getOptionsValuesSuccess(optionsType, providerName, options)
|
|
|
|
|
|
|
+ this.getOptionsValuesSuccess(
|
|
|
|
|
+ optionsType,
|
|
|
|
|
+ providerName,
|
|
|
|
|
+ options,
|
|
|
|
|
+ this.getOptionsValuesLastReqId === reqId,
|
|
|
|
|
+ )
|
|
|
return options
|
|
return options
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
|
console.error(err)
|
|
console.error(err)
|
|
@@ -242,7 +267,11 @@ class ProviderStore {
|
|
|
throw err
|
|
throw err
|
|
|
} finally {
|
|
} finally {
|
|
|
if (!canceled) {
|
|
if (!canceled) {
|
|
|
- this.getOptionsValuesDone(optionsType, !envData)
|
|
|
|
|
|
|
+ this.getOptionsValuesDone(
|
|
|
|
|
+ optionsType,
|
|
|
|
|
+ !envData,
|
|
|
|
|
+ this.getOptionsValuesLastReqId === reqId,
|
|
|
|
|
+ )
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -252,18 +281,30 @@ class ProviderStore {
|
|
|
if (isPrimary) {
|
|
if (isPrimary) {
|
|
|
this.sourceOptions = []
|
|
this.sourceOptions = []
|
|
|
this.sourceOptionsPrimaryLoading = true
|
|
this.sourceOptionsPrimaryLoading = true
|
|
|
|
|
+ this.sourceOptionsSecondaryLoading = false
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ this.sourceOptionsPrimaryLoading = false
|
|
|
this.sourceOptionsSecondaryLoading = true
|
|
this.sourceOptionsSecondaryLoading = true
|
|
|
}
|
|
}
|
|
|
} else if (isPrimary) {
|
|
} else if (isPrimary) {
|
|
|
this.destinationOptions = []
|
|
this.destinationOptions = []
|
|
|
this.destinationOptionsPrimaryLoading = true
|
|
this.destinationOptionsPrimaryLoading = true
|
|
|
|
|
+ this.destinationOptionsSecondaryLoading = false
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ this.destinationOptionsPrimaryLoading = false
|
|
|
this.destinationOptionsSecondaryLoading = true
|
|
this.destinationOptionsSecondaryLoading = true
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @action getOptionsValuesDone(optionsType: 'source' | 'destination', isPrimary: boolean) {
|
|
|
|
|
|
|
+ @action getOptionsValuesDone(
|
|
|
|
|
+ optionsType: 'source' | 'destination',
|
|
|
|
|
+ isPrimary: boolean,
|
|
|
|
|
+ isValid: boolean,
|
|
|
|
|
+ ) {
|
|
|
|
|
+ if (!isValid) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (optionsType === 'source') {
|
|
if (optionsType === 'source') {
|
|
|
if (isPrimary) {
|
|
if (isPrimary) {
|
|
|
this.sourceOptionsPrimaryLoading = false
|
|
this.sourceOptionsPrimaryLoading = false
|
|
@@ -277,7 +318,15 @@ class ProviderStore {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @action getOptionsValuesSuccess(optionsType: 'source' | 'destination', provider: string, options: OptionValues[]) {
|
|
|
|
|
|
|
+ @action getOptionsValuesSuccess(
|
|
|
|
|
+ optionsType: 'source' | 'destination',
|
|
|
|
|
+ provider: string,
|
|
|
|
|
+ options: OptionValues[],
|
|
|
|
|
+ isValid: boolean,
|
|
|
|
|
+ ) {
|
|
|
|
|
+ if (!isValid) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
let schema = optionsType === 'source' ? this.sourceSchema : this.destinationSchema
|
|
let schema = optionsType === 'source' ? this.sourceSchema : this.destinationSchema
|
|
|
schema.forEach(field => {
|
|
schema.forEach(field => {
|
|
|
const parser = OptionsSchemaPlugin[provider] || OptionsSchemaPlugin.default
|
|
const parser = OptionsSchemaPlugin[provider] || OptionsSchemaPlugin.default
|