Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
Filter provider options by what's available
Browse files Browse the repository at this point in the history
  • Loading branch information
mturley committed Feb 4, 2019
1 parent badc511 commit b6b46a0
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 14 deletions.
12 changes: 10 additions & 2 deletions app/javascript/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,16 @@ export const OPENSTACK = 'openstack';
export const RHV = 'rhevm';

export const V2V_TARGET_PROVIDERS = [
{ name: __('Red Hat Virtualization'), id: RHV },
{ name: __('Red Hat OpenStack Platform'), id: OPENSTACK }
{
name: __('Red Hat Virtualization'),
id: RHV,
type: 'ManageIQ::Providers::Redhat::InfraManager'
},
{
name: __('Red Hat OpenStack Platform'),
id: OPENSTACK,
type: 'ManageIQ::Providers::Openstack::CloudManager'
}
];

export const FETCH_TARGET_COMPUTE_URLS = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Object {
"errorSavingSettings": null,
"fetchingServersRejected": false,
"fetchingSettingsRejected": false,
"hasSufficientProviders": false,
"isFetchingConversionHosts": true,
"isFetchingProviders": false,
"isFetchingServers": false,
Expand Down Expand Up @@ -43,6 +44,7 @@ Object {
"errorSavingSettings": null,
"fetchingServersRejected": false,
"fetchingSettingsRejected": false,
"hasSufficientProviders": false,
"isFetchingConversionHosts": false,
"isFetchingProviders": false,
"isFetchingServers": false,
Expand Down Expand Up @@ -77,6 +79,7 @@ Object {
"errorSavingSettings": null,
"fetchingServersRejected": false,
"fetchingSettingsRejected": false,
"hasSufficientProviders": false,
"isFetchingConversionHosts": false,
"isFetchingProviders": false,
"isFetchingServers": false,
Expand Down Expand Up @@ -107,6 +110,7 @@ Object {
"errorSavingSettings": null,
"fetchingServersRejected": false,
"fetchingSettingsRejected": false,
"hasSufficientProviders": false,
"isFetchingConversionHosts": false,
"isFetchingProviders": false,
"isFetchingServers": true,
Expand Down Expand Up @@ -137,6 +141,7 @@ Object {
"errorSavingSettings": null,
"fetchingServersRejected": true,
"fetchingSettingsRejected": false,
"hasSufficientProviders": false,
"isFetchingConversionHosts": false,
"isFetchingProviders": false,
"isFetchingServers": false,
Expand Down Expand Up @@ -167,6 +172,7 @@ Object {
"errorSavingSettings": null,
"fetchingServersRejected": false,
"fetchingSettingsRejected": false,
"hasSufficientProviders": false,
"isFetchingConversionHosts": false,
"isFetchingProviders": false,
"isFetchingServers": false,
Expand Down Expand Up @@ -197,6 +203,7 @@ Object {
"errorSavingSettings": null,
"fetchingServersRejected": false,
"fetchingSettingsRejected": true,
"hasSufficientProviders": false,
"isFetchingConversionHosts": false,
"isFetchingProviders": false,
"isFetchingServers": false,
Expand Down Expand Up @@ -227,6 +234,7 @@ Object {
"errorSavingSettings": null,
"fetchingServersRejected": false,
"fetchingSettingsRejected": false,
"hasSufficientProviders": false,
"isFetchingConversionHosts": false,
"isFetchingProviders": false,
"isFetchingServers": false,
Expand Down Expand Up @@ -259,6 +267,7 @@ Object {
"errorSavingSettings": null,
"fetchingServersRejected": false,
"fetchingSettingsRejected": false,
"hasSufficientProviders": false,
"isFetchingConversionHosts": false,
"isFetchingProviders": false,
"isFetchingServers": false,
Expand Down Expand Up @@ -289,6 +298,7 @@ Object {
"errorSavingSettings": "error",
"fetchingServersRejected": false,
"fetchingSettingsRejected": false,
"hasSufficientProviders": false,
"isFetchingConversionHosts": false,
"isFetchingProviders": false,
"isFetchingServers": false,
Expand Down Expand Up @@ -319,6 +329,7 @@ Object {
"errorSavingSettings": null,
"fetchingServersRejected": false,
"fetchingSettingsRejected": false,
"hasSufficientProviders": false,
"isFetchingConversionHosts": false,
"isFetchingProviders": false,
"isFetchingServers": false,
Expand Down Expand Up @@ -351,6 +362,7 @@ Object {
"errorSavingSettings": null,
"fetchingServersRejected": false,
"fetchingSettingsRejected": false,
"hasSufficientProviders": false,
"isFetchingConversionHosts": false,
"isFetchingProviders": false,
"isFetchingServers": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ConversionHostsSettings extends React.Component {
{!hasSufficientProviders ? (
<ShowWizardEmptyState
description={
__('The source and target providers must be configured before attempting a migration') // prettier-ignore
__('There are no providers available from which to configure a conversion host. You must configure a target provider before configuring conversion hosts.') // prettier-ignore
}
buttonText={__('Configure Providers')}
buttonHref="/ems_infra/show_list"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import { RHV, OPENSTACK } from '../../../../../../../../common/constants';

export const stepIDs = {
locationStep: 'conversionHostWizardLocationStep',
hostsStep: 'conversionHostWizardHostsStep',
authenticationStep: 'conversionHostWizardAuthenticationStep',
resultsStep: 'conversionHostWizardResultsStep'
};

export const PROVIDER_TYPES = {
[RHV]: 'ManageIQ::Providers::Redhat::InfraManager',
[OPENSTACK]: 'ManageIQ::Providers::Openstack::CloudManager'
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
FETCH_TARGET_COMPUTE_URLS
} from '../../../../../../../../../common/constants';

import { stepIDs, PROVIDER_TYPES } from '../ConversionHostWizardConstants';
import { stepIDs } from '../ConversionHostWizardConstants';

class ConversionHostWizardLocationStep extends React.Component {
componentDidUpdate(prevProps) {
Expand All @@ -36,9 +36,12 @@ class ConversionHostWizardLocationStep extends React.Component {
const { providers, isFetchingTargetComputeResources, targetComputeResources } = this.props;
const { selectedProviderType, selectedProviderId } = this.getDerivedProps();

const providersFilteredBySelectedType = providers.filter(
provider => provider.type === PROVIDER_TYPES[selectedProviderType]
const availableProviderOptions = V2V_TARGET_PROVIDERS.filter(option =>
providers.some(provider => provider.type === option.type)
);
const selectedProviderOption = availableProviderOptions.find(option => option.id === selectedProviderType);
const providersFilteredBySelectedType =
selectedProviderOption && providers.filter(provider => provider.type === selectedProviderOption.type);

const targetComputeFilteredBySelectedProvider = targetComputeResources.filter(
computeResource => computeResource.ems_id === selectedProviderId
Expand All @@ -61,7 +64,7 @@ class ConversionHostWizardLocationStep extends React.Component {
{...selectFieldBaseProps}
name="providerType"
label={__('Provider Type')}
options={V2V_TARGET_PROVIDERS}
options={availableProviderOptions}
/>
{selectedProviderType && (
<Spinner loading={isFetchingTargetComputeResources}>
Expand Down

0 comments on commit b6b46a0

Please sign in to comment.