-
Notifications
You must be signed in to change notification settings - Fork 592
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
Bug 1871103: Remove 'Template' field from VM wizard #6402
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 |
---|---|---|
|
@@ -38,7 +38,7 @@ import { CREATE_VM, CREATE_VM_TEMPLATE, IMPORT_VM, TabTitleResolver } from './st | |
import { vmWizardActions } from './redux/actions'; | ||
import { ActionType } from './redux/types'; | ||
import { getResultInitialState } from './redux/initial-state/result-tab-initial-state'; | ||
import { iGetCommonData } from './selectors/immutable/selectors'; | ||
import { iGetCommonData, iGetName, iGetLoadedCommonData } from './selectors/immutable/selectors'; | ||
import { getExtraWSQueries } from './selectors/selectors'; | ||
import { | ||
getStepsMetadata, | ||
|
@@ -58,6 +58,7 @@ import { CloudInitTab } from './tabs/cloud-init-tab/cloud-init-tab'; | |
import { useStorageClassConfigMapWrapped } from '../../hooks/storage-class-config-map'; | ||
import { ValidTabGuard } from './tabs/valid-tab-guard'; | ||
import { FirehoseResourceEnhanced } from '../../types/custom'; | ||
import { ITemplate } from '../../types/template'; | ||
|
||
import './create-vm-wizard.scss'; | ||
|
||
|
@@ -69,6 +70,7 @@ type CreateVMWizardComponentProps = { | |
dataIDReferences: IDReferences; | ||
reduxID: string; | ||
tabsMetadata: VMWizardTabsMetadata; | ||
iUserTemplate: ITemplate; | ||
onInitialize: () => void; | ||
onClose: (disposeOnly: boolean) => void; | ||
createVM: () => void; | ||
|
@@ -131,14 +133,14 @@ class CreateVMWizardComponent extends React.Component<CreateVMWizardComponentPro | |
}; | ||
|
||
getWizardTitle() { | ||
const { isCreateTemplate, isProviderImport } = this.props; | ||
const { isCreateTemplate, isProviderImport, iUserTemplate } = this.props; | ||
if (isCreateTemplate) { | ||
return CREATE_VM_TEMPLATE; | ||
} | ||
if (isProviderImport) { | ||
return IMPORT_VM; | ||
} | ||
return CREATE_VM; | ||
return iUserTemplate ? `${CREATE_VM} from ${iGetName(iUserTemplate)}` : CREATE_VM; | ||
} | ||
|
||
goBackToEditingSteps = () => | ||
|
@@ -291,6 +293,7 @@ class CreateVMWizardComponent extends React.Component<CreateVMWizardComponentPro | |
const wizardStateToProps = (state, { reduxID }) => ({ | ||
isLastTabErrorFatal: isLastStepErrorFatal(state, reduxID), | ||
tabsMetadata: getStepsMetadata(state, reduxID), | ||
iUserTemplate: iGetLoadedCommonData(state, reduxID, VMWizardProps.userTemplate), | ||
// fetch data from store to detect and fire changes | ||
...[...DetectCommonDataChanges] | ||
.filter((v) => v !== VMWizardProps.storageClassConfigMap) // passed directly | ||
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. we don't have to load all the userTemplates anymore. Just the one is enough. 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. plus we don't have to load it at all when we are not in the userTemplateMode |
||
|
@@ -307,7 +310,7 @@ const wizardDispatchToProps = (dispatch, props) => ({ | |
data: { | ||
isCreateTemplate: props.isCreateTemplate, | ||
isProviderImport: props.isProviderImport, | ||
userTemplateName: props.userTemplateName, | ||
isUserTemplateInitialized: false, | ||
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. +1 I guess this makes it simpler. I just hope we don't need it somewhere later. |
||
storageClassConfigMap: undefined, | ||
isSimpleView: props.isSimpleView, | ||
}, | ||
|
@@ -359,6 +362,8 @@ export const CreateVMWizardPageComponent: React.FC<CreateVMWizardPageComponentPr | |
}) => { | ||
const activeNamespace = match && match.params && match.params.ns; | ||
const searchParams = new URLSearchParams(location && location.search); | ||
const userMode = searchParams.get('mode') || VMWizardMode.VM; | ||
const userTemplateName = (userMode === VMWizardMode.VM && searchParams.get('template')) || ''; | ||
|
||
let resources: FirehoseResourceEnhanced[] = []; | ||
|
||
|
@@ -376,11 +381,6 @@ export const CreateVMWizardPageComponent: React.FC<CreateVMWizardPageComponentPr | |
|
||
if (flags[FLAGS.OPENSHIFT]) { | ||
resources.push( | ||
getResource(TemplateModel, { | ||
namespace: activeNamespace, | ||
prop: VMWizardProps.userTemplates, | ||
matchLabels: { [TEMPLATE_TYPE_LABEL]: TEMPLATE_TYPE_VM }, | ||
}), | ||
getResource(TemplateModel, { | ||
namespace: 'openshift', | ||
prop: VMWizardProps.commonTemplates, | ||
|
@@ -391,6 +391,28 @@ export const CreateVMWizardPageComponent: React.FC<CreateVMWizardPageComponentPr | |
prop: VMWizardProps.openshiftCNVBaseImages, | ||
}), | ||
); | ||
|
||
if (userMode === VMWizardMode.TEMPLATE) { | ||
resources.push( | ||
getResource(TemplateModel, { | ||
namespace: activeNamespace, | ||
prop: VMWizardProps.userTemplates, | ||
matchLabels: { [TEMPLATE_TYPE_LABEL]: TEMPLATE_TYPE_VM }, | ||
}), | ||
); | ||
} | ||
|
||
if (userTemplateName) { | ||
resources.push( | ||
getResource(TemplateModel, { | ||
name: userTemplateName, | ||
namespace: activeNamespace, | ||
prop: VMWizardProps.userTemplate, | ||
isList: false, | ||
matchLabels: { [TEMPLATE_TYPE_LABEL]: TEMPLATE_TYPE_VM }, | ||
}), | ||
); | ||
} | ||
} | ||
resources.push(...wsResources); | ||
} | ||
|
@@ -402,8 +424,6 @@ export const CreateVMWizardPageComponent: React.FC<CreateVMWizardPageComponentPr | |
dataIDReferences[VMWizardProps.activeNamespace] = ['UI', 'activeNamespace']; | ||
dataIDReferences[VMWizardProps.openshiftFlag] = [featureReducerName, FLAGS.OPENSHIFT]; | ||
|
||
const userMode = searchParams.get('mode') || VMWizardMode.VM; | ||
const userTemplateName = (userMode === VMWizardMode.VM && searchParams.get('template')) || ''; | ||
const isSimpleView = | ||
userMode === VMWizardMode.IMPORT && | ||
searchParams.get('view')?.toLowerCase() !== VMWizardView.ADVANCED; // normal mode defaults to advanced | ||
|
@@ -413,7 +433,6 @@ export const CreateVMWizardPageComponent: React.FC<CreateVMWizardPageComponentPr | |
<CreateVMWizard | ||
isCreateTemplate={userMode === VMWizardMode.TEMPLATE} | ||
isProviderImport={userMode === VMWizardMode.IMPORT} | ||
userTemplateName={userTemplateName} | ||
isSimpleView={isSimpleView} | ||
dataIDReferences={dataIDReferences} | ||
storageClassConfigMap={storageClassConfigMap} | ||
|
This comment was marked as outdated.
Sorry, something went wrong.