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

Remove filtering of editable source opts. provider

Previously, a hard-coded list of providers which have a source options
page in the replica creation wizard was kept.

With this commit, all providers can and will be queried for their source
environment schema, so there will no longer be a need to keep the list.
Sergiu Miclea 6 лет назад
Родитель
Сommit
f1ca5e1d7a

+ 0 - 3
config.js

@@ -29,9 +29,6 @@ const conf: Config = {
   // The timeout between polling requests
   requestPollTimeout: 5000,
 
-  // The list of providers which offer source options
-  sourceOptionsProviders: ['aws', 'azure', 'opc', 'openstack', 'oracle_vm', 'vmware_vsphere'],
-
   // - Specifies the `limit` for each provider when listing all its VMs for pagination.
   // - If the provider is not in this list, the 'default' value will be used.
   // - If the `default` value is lower than the number of instances that fit into a page, the latter number will be used.

+ 9 - 19
src/components/organisms/EditReplica/EditReplica.jsx

@@ -107,7 +107,7 @@ type State = {
 @observer
 class EditReplica extends React.Component<Props, State> {
   state = {
-    selectedPanel: null,
+    selectedPanel: 'source_options',
     destinationData: {},
     sourceData: {},
     updateDisabled: false,
@@ -121,8 +121,6 @@ class EditReplica extends React.Component<Props, State> {
 
   componentWillMount() {
     this.loadData(true)
-
-    this.setState({ selectedPanel: this.hasSourceOptions() ? 'source_options' : 'dest_options' })
   }
 
   async loadData(useCache: boolean) {
@@ -148,9 +146,8 @@ class EditReplica extends React.Component<Props, State> {
         }
       }
     }
-    if (this.hasSourceOptions()) {
-      loadAllOptions('source')
-    }
+
+    loadAllOptions('source')
     loadAllOptions('destination')
   }
 
@@ -214,10 +211,6 @@ class EditReplica extends React.Component<Props, State> {
       : false
   }
 
-  hasSourceOptions(): boolean {
-    return Boolean(configLoader.config.sourceOptionsProviders.find(p => p === this.props.sourceEndpoint.type))
-  }
-
   isUpdateDisabled() {
     let isLoadingDestOptions = this.state.selectedPanel === 'dest_options'
       && (providerStore.destinationSchemaLoading || providerStore.destinationOptionsPrimaryLoading)
@@ -586,6 +579,12 @@ class EditReplica extends React.Component<Props, State> {
 
   render() {
     let navigationItems: NavigationItem[] = [
+      {
+        value: 'source_options',
+        label: 'Source Options',
+        disabled: this.state.sourceFailed,
+        title: this.state.sourceFailed ? 'There are source platform errors, source options can\'t be updated' : '',
+      },
       { value: 'dest_options', label: 'Target Options' },
       { value: 'network_mapping', label: 'Network Mapping' },
     ]
@@ -594,15 +593,6 @@ class EditReplica extends React.Component<Props, State> {
       navigationItems.push({ value: 'storage_mapping', label: 'Storage Mapping' })
     }
 
-    if (this.hasSourceOptions()) {
-      navigationItems.splice(0, 0, {
-        value: 'source_options',
-        label: 'Source Options',
-        disabled: this.state.sourceFailed,
-        title: this.state.sourceFailed ? 'There are source platform errors, source options can\'t be updated' : '',
-      })
-    }
-
     return (
       <Modal
         isOpen={this.props.isOpen}

+ 0 - 5
src/components/pages/WizardPage/WizardPage.jsx

@@ -36,7 +36,6 @@ import scheduleStore from '../../../stores/ScheduleStore'
 import replicaStore from '../../../stores/ReplicaStore'
 import KeyboardManager from '../../../utils/KeyboardManager'
 import { wizardPages, executionOptions, providerTypes } from '../../../constants'
-import configLoader from '../../../utils/Config'
 
 import type { MainItem } from '../../../types/MainItem'
 import type { Endpoint as EndpointType, StorageBackend } from '../../../types/Endpoint'
@@ -81,18 +80,14 @@ class WizardPage extends React.Component<Props, State> {
   }
 
   get pages() {
-    let sourceProvider = wizardStore.data.source ? wizardStore.data.source.type : ''
     let destProvider = wizardStore.data.target ? wizardStore.data.target.type || '' : ''
     let pages = wizardPages
-    let sourceOptionsProviders = configLoader.config.sourceOptionsProviders
     let hasStorageMapping = () => providerStore.providers && providerStore.providers[destProvider]
       ? !!providerStore.providers[destProvider].types.find(t => t === providerTypes.STORAGE) : false
 
     return pages
       .filter(p => !p.excludeFrom || p.excludeFrom !== this.state.type)
       .filter(p => p.id !== 'storage' || hasStorageMapping())
-      .filter(p => p.id !== 'source-options'
-        || sourceOptionsProviders.find(p => p === sourceProvider))
   }
 
   componentWillMount() {

+ 0 - 1
src/types/Config.js

@@ -19,7 +19,6 @@ export type Config = {
   showOpenstackCurrentUserSwitch: boolean,
   useBarbicanSecrets: boolean,
   requestPollTimeout: number,
-  sourceOptionsProviders: string[],
   instancesListBackgroundLoading: { default: number, [string]: number },
   extraOptionsApiCalls: ExtraOption[],
   providerSortPriority: { [providerName: string]: number },