Skip to content

Commit ad94cd2

Browse files
authored
Merge pull request #349 from smiclea/CORWEB-195
Automatically detect storage mapping support CORWEB-195
2 parents ffc4f70 + 36bc1a8 commit ad94cd2

5 files changed

Lines changed: 17 additions & 15 deletions

File tree

config.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ const conf: Config = {
2828
// The timeout between polling requests
2929
requestPollTimeout: 5000,
3030

31-
// The list of providers which offer storage listing
32-
storageProviders: ['openstack', 'azure', 'oracle_vm'],
33-
3431
// The list of providers which offer source options
3532
sourceOptionsProviders: ['aws'],
3633

src/components/organisms/EditReplica/EditReplica.jsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ import type { Endpoint, StorageBackend, StorageMap } from '../../../types/Endpoi
3838
import type { Field } from '../../../types/Field'
3939
import type { Instance, Nic, Disk } from '../../../types/Instance'
4040
import type { Network, NetworkMap } from '../../../types/Network'
41+
import { providerTypes } from '../../../constants'
4142

4243
import StyleProps from '../../styleUtils/StyleProps'
43-
import configLoader from '../../../utils/Config'
4444

4545
const PanelContent = styled.div`
4646
padding: 32px;
@@ -100,9 +100,11 @@ class EditReplica extends React.Component<Props, State> {
100100
scrollableRef: HTMLElement
101101

102102
componentWillMount() {
103-
if (this.hasStorageMap()) {
104-
endpointStore.loadStorage(this.props.destinationEndpoint.id, {})
105-
}
103+
providerStore.loadProviders().then(() => {
104+
if (this.hasStorageMap()) {
105+
endpointStore.loadStorage(this.props.destinationEndpoint.id, {})
106+
}
107+
})
106108

107109
providerStore.loadDestinationSchema(this.props.destinationEndpoint.type, this.props.type || 'replica').then(() => {
108110
return providerStore.getDestinationOptions(this.props.destinationEndpoint.id, this.props.destinationEndpoint.type, undefined, true)
@@ -111,13 +113,15 @@ class EditReplica extends React.Component<Props, State> {
111113
})
112114
}
113115

114-
hasStorageMap() {
116+
hasStorageMap(): boolean {
115117
if (this.props.type === 'replica') {
116118
// storage mapping edit is not currently supported by the API
117119
return false
118120
}
119121

120-
return Boolean(configLoader.config.storageProviders.find(p => p === this.props.destinationEndpoint.type))
122+
return providerStore.providers && providerStore.providers[this.props.destinationEndpoint.type] ?
123+
!!providerStore.providers[this.props.destinationEndpoint.type].types.find(t => t === providerTypes.STORAGE)
124+
: false
121125
}
122126

123127
isUpdateDisabled() {

src/components/pages/WizardPage/WizardPage.jsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import notificationStore from '../../../stores/NotificationStore'
3535
import scheduleStore from '../../../stores/ScheduleStore'
3636
import replicaStore from '../../../stores/ReplicaStore'
3737
import KeyboardManager from '../../../utils/KeyboardManager'
38-
import { wizardPages, executionOptions } from '../../../constants'
38+
import { wizardPages, executionOptions, providerTypes } from '../../../constants'
3939
import configLoader from '../../../utils/Config'
4040

4141
import type { MainItem } from '../../../types/MainItem'
@@ -82,14 +82,15 @@ class WizardPage extends React.Component<Props, State> {
8282

8383
get pages() {
8484
let sourceProvider = wizardStore.data.source ? wizardStore.data.source.type : ''
85-
let destProvider = wizardStore.data.target ? wizardStore.data.target.type : ''
85+
let destProvider = wizardStore.data.target ? wizardStore.data.target.type || '' : ''
8686
let pages = wizardPages
8787
let sourceOptionsProviders = configLoader.config.sourceOptionsProviders
88-
let storageOptionsProviders = configLoader.config.storageProviders
88+
let hasStorageMapping = () => providerStore.providers && providerStore.providers[destProvider]
89+
? !!providerStore.providers[destProvider].types.find(t => t === providerTypes.STORAGE) : false
90+
8991
return pages
9092
.filter(p => !p.excludeFrom || p.excludeFrom !== this.state.type)
91-
.filter(p => p.id !== 'storage'
92-
|| storageOptionsProviders.find(p => p === destProvider))
93+
.filter(p => p.id !== 'storage' || hasStorageMapping())
9394
.filter(p => p.id !== 'source-options'
9495
|| sourceOptionsProviders.find(p => p === sourceProvider))
9596
}

src/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export const providerTypes = {
5151
TARGET_REPLICA: 4,
5252
SOURCE_REPLICA: 8,
5353
CONNECTION: 16,
54+
STORAGE: 32768,
5455
}
5556

5657
export const loginButtons = [

src/types/Config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export type Config = {
77
showOpenstackCurrentUserSwitch: boolean,
88
useBarbicanSecrets: boolean,
99
requestPollTimeout: number,
10-
storageProviders: string[],
1110
sourceOptionsProviders: string[],
1211
instancesListBackgroundLoading: { default: number, [string]: number },
1312
providersWithExtraOptions: Array<string | { name: string, envRequiredFields: string[] }>,

0 commit comments

Comments
 (0)