-
Notifications
You must be signed in to change notification settings - Fork 670
Show only the allowed storage interfaces on Disk-modal #3973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -251,6 +251,11 @@ export default (state, action: WizardInternalAction) => { | |
| [dialogID, 'tabs', VMWizardTab.VM_SETTINGS, 'value'], | ||
| fromJS(payload.value), | ||
| ); | ||
| case InternalActionType.SetTemplateValidations: | ||
| return state.setIn( | ||
| [dialogID, 'commonData', 'dataIDReferences', 'templateValidations'], | ||
| payload.value, | ||
|
||
| ); | ||
| default: | ||
| break; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import { FLAGS } from '@console/shared'; | ||
| import { TemplateValidations } from '../../../../../utils/validations/template/template-validations'; | ||
| import { isWinToolsImage, getVolumeContainerImage } from '../../../../../selectors/vm'; | ||
| import { | ||
| hasVmSettingsChanged, | ||
|
|
@@ -20,6 +21,7 @@ import { ProvisionSource } from '../../../../../constants/vm/provision-source'; | |
| import { getProviders } from '../../../provider-definitions'; | ||
| import { windowsToolsStorage } from '../../initial-state/storage-tab-initial-state'; | ||
| import { getStorages } from '../../../selectors/selectors'; | ||
| import { getTemplateValidations } from '../../validations/utils/templates-validations'; | ||
| import { prefillVmTemplateUpdater } from './prefill-vm-template-state-update'; | ||
|
|
||
| export const selectedUserTemplateUpdater = (options: UpdateOptions) => { | ||
|
|
@@ -144,6 +146,25 @@ export const nativeK8sUpdater = ({ id, dispatch, getState, changedCommonData }: | |
| ); | ||
| }; | ||
|
|
||
| export const templateValidationsUpdater = (options: UpdateOptions) => { | ||
| const { id, prevState, dispatch, getState } = options; | ||
| const state = getState(); | ||
| if ( | ||
| !hasVmSettingsChanged( | ||
| prevState, | ||
| state, | ||
| id, | ||
| VMSettingsField.OPERATING_SYSTEM, | ||
| VMSettingsField.FLAVOR, | ||
| VMSettingsField.WORKLOAD_PROFILE, | ||
| ) | ||
| ) { | ||
| return; | ||
| } | ||
| const validations: TemplateValidations[] = getTemplateValidations(options); | ||
|
||
| dispatch(vmWizardInternalActions[InternalActionType.SetTemplateValidations](id, validations)); | ||
| }; | ||
|
|
||
| export const updateVmSettingsState = (options: UpdateOptions) => | ||
| [ | ||
| ...(iGetCommonData(options.getState(), options.id, VMWizardProps.isProviderImport) | ||
|
|
@@ -154,6 +175,7 @@ export const updateVmSettingsState = (options: UpdateOptions) => | |
| flavorUpdater, | ||
| osUpdater, | ||
| nativeK8sUpdater, | ||
| templateValidationsUpdater, | ||
| ].forEach((updater) => { | ||
| updater && updater(options); | ||
| }); | ||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import { UpdateOptions } from '../../types'; | ||
| import { | ||
| iGetVmSettingAttribute, | ||
| iGetVmSettingValue, | ||
| } from '../../../selectors/immutable/vm-settings'; | ||
| import { iGetLoadedCommonData } from '../../../selectors/immutable/selectors'; | ||
| import { VMSettingsField, VMWizardProps } from '../../../types'; | ||
| import { iGetTemplateValidations } from '../../../../../selectors/immutable/template/selectors'; | ||
| import { iGetRelevantTemplates } from '../../../../../selectors/immutable/template/combined'; | ||
| import { TemplateValidations } from '../../../../../utils/validations/template/template-validations'; | ||
|
|
||
| const getValidationsFromTemplates = (templates): TemplateValidations[] => | ||
| templates.map( | ||
| (relevantTemplate) => new TemplateValidations(iGetTemplateValidations(relevantTemplate)), | ||
| ); | ||
|
|
||
| export const getTemplateValidations = (options: UpdateOptions): TemplateValidations[] => { | ||
| const { getState, id } = options; | ||
| const state = getState(); | ||
|
|
||
| const userTemplateName = iGetVmSettingValue(state, id, VMSettingsField.USER_TEMPLATE); | ||
| const os = iGetVmSettingAttribute(state, id, VMSettingsField.OPERATING_SYSTEM); | ||
| const flavor = iGetVmSettingAttribute(state, id, VMSettingsField.FLAVOR); | ||
| const workload = iGetVmSettingAttribute(state, id, VMSettingsField.WORKLOAD_PROFILE); | ||
|
|
||
| const iUserTemplates = iGetLoadedCommonData(state, id, VMWizardProps.userTemplates); | ||
| const iCommonTemplates = iGetLoadedCommonData(state, id, VMWizardProps.commonTemplates); | ||
|
|
||
| const templates = iGetRelevantTemplates(iUserTemplates, iCommonTemplates, { | ||
| userTemplateName, | ||
| os, | ||
| workload, | ||
| flavor, | ||
| }); | ||
|
|
||
| if (templates.size > 0 && os && workload) { | ||
| // templates are sorted by relevance if only flavor is missing | ||
| return getValidationsFromTemplates(templates.toArray()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see a reason why this is necessary. Please update to the newest version |
||
| } | ||
|
|
||
| return getValidationsFromTemplates([templates.first()]); | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a note:
dataIDReferencesis for storing references of already present data in the redux store only. Not the original data.