Skip to content
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

Conversation

irosenzw
Copy link
Contributor

@irosenzw irosenzw commented Aug 23, 2020

When creating a VM from template the wizard title will be:
Create Virtual Machine from <template name> template

Signed-off-by: Ido Rosenzwig irosenzw@redhat.com

@openshift-ci-robot openshift-ci-robot added the bugzilla/severity-high Referenced Bugzilla bug's severity is high for the branch this PR is targeting. label Aug 23, 2020
@openshift-ci-robot
Copy link
Contributor

@irosenzw: This pull request references Bugzilla bug 1871103, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.6.0) matches configured target release for branch (4.6.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1871103: Remove 'Template' field from VM wizard

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Aug 23, 2020
@irosenzw
Copy link
Contributor Author

/retest

@@ -73,14 +71,6 @@ export const VMSettingsTabComponent: React.FC<VMSettingsTabComponentProps> = ({
/>
</FormField>
</FormFieldMemoRow>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how will the user know which template was selected in virtualization/templates ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you propose ? keep the template's dropdown or add a label (or another component) to show the chosen template ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess having a label should be enough. Although there will probably be some logic , when the template doesn't exist, etc. So having a component might be beneficial.

@irosenzw irosenzw force-pushed the remove-template-field-vm-wizard branch from 307b29b to d469b72 Compare August 26, 2020 12:32
@openshift-ci-robot
Copy link
Contributor

@irosenzw: This pull request references Bugzilla bug 1871103, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.6.0) matches configured target release for branch (4.6.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1871103: Remove 'Template' field from VM wizard

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

1 similar comment
@openshift-ci-robot
Copy link
Contributor

@irosenzw: This pull request references Bugzilla bug 1871103, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.6.0) matches configured target release for branch (4.6.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1871103: Remove 'Template' field from VM wizard

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@irosenzw
Copy link
Contributor Author

Screenshot from 2020-08-26 15-34-23

import { FormField, FormFieldType } from '../../form/form-field';
import { ignoreCaseSort } from '../../../../utils/sort';
import { VMSettingsField } from '../../types';
import {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about all these strings?

@@ -290,6 +291,7 @@ class CreateVMWizardComponent extends React.Component<CreateVMWizardComponentPro
const wizardStateToProps = (state, { reduxID }) => ({
isLastTabErrorFatal: isLastStepErrorFatal(state, reduxID),
tabsMetadata: getStepsMetadata(state, reduxID),
userTemplateName: iGetCommonData(state, reduxID, VMWizardProps.userTemplateName),
// fetch data from store to detect and fire changes
...[...DetectCommonDataChanges]
.filter((v) => v !== VMWizardProps.storageClassConfigMap) // passed directly
Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The 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

@@ -73,14 +71,6 @@ export const VMSettingsTabComponent: React.FC<VMSettingsTabComponentProps> = ({
/>
</FormField>
</FormFieldMemoRow>
<UserTemplates
userTemplateField={getField(VMSettingsField.USER_TEMPLATE)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can remove VMSettingsField.USER_TEMPLATE field as it is not used anymore

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plus all the not needed logic

@atiratree
Copy link
Member

@matthewcarleton what is your opinion on this design and what should we do when the template is missing? (somebody has wrong url)

@matthewcarleton
Copy link
Contributor

@matthewcarleton what is your opinion on this design and what should we do when the template is missing? (somebody has wrong url)

Having the template name in the title of the wizard works. We could also have
Template
template-name-here
as the first label - read only input
WDYT @irosenzw ?

For when the template is missing
for the short term I think we'll have to have an error in the wizard that alerts them of the issue and how to fix it. More long term we are talking about Template status so that could help avoid selecting a template that has this issue.
This is if I follow you correctly. I wasn't aware of this type of issue.

@irosenzw
Copy link
Contributor Author

@matthewcarleton can you please attach a design proposal so we can all be on the same page of what you are suggesting ?

@atiratree
Copy link
Member

For when the template is missing
for the short term I think we'll have to have an error in the wizard that alerts them of the issue and how to fix it. More long term we are talking about Template status so that could help avoid selecting a template that has this issue.
This is if I follow you correctly. I wasn't aware of this type of issue.

I don't expect anything to be wrong template. I think the only issue will be that the user saved a template creation url and is trying to use, while that template has been already deleted

@matthewcarleton
Copy link
Contributor

matthewcarleton commented Aug 26, 2020

For when the template is missing
for the short term I think we'll have to have an error in the wizard that alerts them of the issue and how to fix it. More long term we are talking about Template status so that could help avoid selecting a template that has this issue.
This is if I follow you correctly. I wasn't aware of this type of issue.

I don't expect anything to be wrong template. I think the only issue will be that the user saved a template creation url and is trying to use, while that template has been already deleted
This would happen in the UI?

yes, but not that likely - you go to create from a template and somebody deletes it

nevertheless we should add a guard against it

Yes in the case where someone is trying to create from a template and then another user deletes that template it would be nice if they are aware right away and not have to wait for the creation to fail.

Template no longer available
It appears this template has been removed. Please contact your system administrator for more information.

Not sure if we can provide any additional info around the user that deleted it can we?

@atiratree
Copy link
Member

yes, but not that likely - you go to create from a template and somebody deletes it

nevertheless we should add a guard against it

@matthewcarleton
Copy link
Contributor

@irosenzw just want to make sure you saw my last comment. It posted strangely - but there is a response there to @suomiy latest comment.

@irosenzw irosenzw force-pushed the remove-template-field-vm-wizard branch 2 times, most recently from 6857641 to f57e0ba Compare September 3, 2020 17:24
@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 3, 2020
@irosenzw irosenzw force-pushed the remove-template-field-vm-wizard branch 2 times, most recently from 8f7938e to 60793ca Compare September 3, 2020 17:34
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 3, 2020
@irosenzw irosenzw force-pushed the remove-template-field-vm-wizard branch 3 times, most recently from fd79b5a to 668c01f Compare September 3, 2020 18:04
@@ -89,6 +94,8 @@ const CreateVMWizardFooterComponent: React.FC<CreateVMWizardFooterComponentProps
const areMainTabsHidden = VM_WIZARD_DIFFICULT_TABS.some((tab) => steps[tab].isHidden);
const isLastStepValid = steps[VMWizardTab.RESULT].isValid;

const isValidUserTemplate = !userTemplateName || (userTemplateName && isUserTemplateValid);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would make more sense to call this isInvalidUserTemplate IMO

userTemplateName: {
value: props.userTemplateName,
initialized: false,
isValid: true,
Copy link
Member

@atiratree atiratree Sep 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not load all the userTemplates, but just the one we need.

In that case we don't need isValid value here, because the validity is already present in FirehoseResult object

It is a fluid value. It could easily happen that we open wizard and then somebody deletes the userTemplate - and in that case the wizard stops being valid

@@ -10,6 +10,32 @@ import { K8sKind } from '@console/internal/module/k8s';
import { TemplateModel } from '@console/internal/models';
import { DataVolumeModel, VirtualMachineModel } from '../../../models';
import { getExtraWSQueries } from '../selectors/selectors';
import { iGetUserTemplateName, iGetUserTemplateValidity } from '../selectors/immutable/template';

const userTemplateError = (state: any, wizardReduxID: string): Error => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we load one use template in that case we don't need a special handler like this one but a generic handler like VMWizardProps.userTemplates have right now

@@ -37,6 +37,27 @@ export const vmWizardInternalActions: VMWizardInternalActions = {
},
type: InternalActionType.Update,
}),
[InternalActionType.UpdateUserTemplateName]: (id, value) => ({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is too many actions and it will not scale. Please create just a generic action like setCommonDataDataValue

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and it seems you are dispatching it in just one place, so you don't need such granularity

};

const selectedUserTemplateUpdater = (options: UpdateOptions) => {
const { id, prevState, dispatch, getState } = options;
const state = getState();
if (!hasVmSettingsChanged(prevState, state, id, VMSettingsField.USER_TEMPLATE)) {

if (!hasCommonDataChanged(prevState, state, id, VMWizardProps.userTemplateName)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't expect the name to change so the logic has to be redone.

VMSettingsField.USER_TEMPLATE,
)
) &&
!hasCommonDataChanged(prevState, state, id, VMWizardProps.userTemplateName)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to have it here

@irosenzw irosenzw force-pushed the remove-template-field-vm-wizard branch from 668c01f to e3edc7f Compare September 7, 2020 14:06
@matthewcarleton
Copy link
Contributor

Create a VM from an existing template:
valid-template

Create a VM from a non-existing template:
invalid-template

What if we said

Could not load requested template
requested template vm-templates-example-5 can not be found. It may have been removed.
Please contact your admin for more information or choose another template (this could link back to the template list)

});
const stateToProps = (state, { wizardReduxID }) => {
const iUserTemplate = iGetCommonData(state, wizardReduxID, VMWizardProps.userTemplate);
const isInvalidUserTemplate = iUserTemplate ? !!iGetLoadError(iUserTemplate) : false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be prob also disabled when it is loading

getResource(TemplateModel, {
namespace: 'openshift',
prop: VMWizardProps.commonTemplates,
matchLabels: { [TEMPLATE_TYPE_LABEL]: TEMPLATE_TYPE_BASE },
}),
getResource(TemplateModel, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this websocket should only run when isCreateTemplate

: operatingSystemsNative;

if (openshiftFlag) {
operatingSystems.push(iUserTemplate.toJS());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can fail on NPE

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we refactor this function so that we gather info only from iUserTemplate when we have it. Otherwise from iCommonTemplates?

@@ -117,11 +120,12 @@ const CreateVMWizardFooterComponent: React.FC<CreateVMWizardFooterComponentProps
const isFinishingStep = [VMWizardTab.REVIEW, VMWizardTab.RESULT].includes(activeStepID);
const isLastStep = activeStepID === VMWizardTab.RESULT;

const isNextButtonDisabled = isAnyStepLocked;
const isReviewButtonDisabled = isAnyStepLocked;
const isNextButtonDisabled = isAnyStepLocked || isInvalidUserTemplate;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after some consideration. These metadata are used in multiple places - that is why this will not disable left nav when needed. We should track this invalidity in redux. I think a good place for this would be finalizeTabResolver. You can play with the logic there and get inspired with finalizeImportProviderStateUpdate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first, I don't understand why it won't disable the left nav when needed, can you provide an example.
second, can we maybe add the functionality as a followup ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete the template why you are in a wizard. IMO it is better to do it here, as these inconsistencies add up and are hard to follow up.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another valid option IMO is to disable just the review and create button and let the wizard be navigable with the error on the top. But the navigation would be at least consistent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when the template gets deleted all the nav buttons are disabled (next, back, review and create)
and when the template gets create while in the wizard they are enabled again.
I don't see what is wrong with the logic here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the nav is enabled and it is possible to jump to other tabs

};

const selectedUserTemplateUpdater = (options: UpdateOptions) => {
const { id, prevState, dispatch, getState } = options;
const state = getState();
if (!hasVmSettingsChanged(prevState, state, id, VMSettingsField.USER_TEMPLATE)) {

if (!hasCommonDataChanged(prevState, state, id, VMWizardProps.isUserTemplateInitialized)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why should here be something instead when the logic gets executed there?

const params = {
userTemplate,
userTemplateName,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we remove it from params. It does not seem necessary to have it there.

const vanillaTemplates = immutableListToShallowJS(iGetLoadedData(commonTemplates));

if (isUserTemplateValid) {
vanillaTemplates.push(userTemplate);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets just use the one userTemplate when resolving os/flavor/workload

concatImmutableLists(iGetLoadedData(commonTemplates), iGetLoadedData(userTemplates)),
);
const isUserTemplateLoaded = iGetIsLoaded(iUserTemplate);
const userTemplateName: string = isUserTemplateLoaded
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same - no need to resolve the name here

| ChangedCommonDataProp;

export type ChangedCommonData = Set<ChangedCommonDataProp>;

export const DetectCommonDataChanges = new Set<ChangedCommonDataProp>([
VMWizardProps.activeNamespace,
VMWizardProps.openshiftFlag,
VMWizardProps.userTemplate,
VMWizardProps.virtualMachines,

This comment was marked as resolved.

@@ -45,12 +45,14 @@ export const getOperatingSystems = (templates: TemplateKind[], userTemplate: str

export const getWorkloadProfiles = (
templates: TemplateKind[],
{ flavor, os, userTemplate }: { flavor: string; os: string; userTemplate: string },
{ flavor, os, userTemplateName }: { flavor: string; os: string; userTemplateName: string },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

repeating myself, but let's not pass the name but just the [template] for userTemplates

@atiratree
Copy link
Member

What if we said

Could not load requested template
requested template vm-templates-example-5 can not be found. It may have been removed.
Please contact your admin for more information or choose another template (this could link back to the template list)

@matthewcarleton

We could do this, but I am against it at this time. This component handles all types of errors (of all resources and casuses) and if we start adding customization like this one on top of each other iit will become a mess.

We have to come either with a better generic solution to these errors or add a good extension framework.
If we try to do it here, this PR will get more out of scope.

@irosenzw irosenzw force-pushed the remove-template-field-vm-wizard branch from 2251e43 to 6de9114 Compare September 9, 2020 09:48
let operatingSystems = [];

if (openshiftFlag && iUserTemplate) {
operatingSystems.push(getTemplateOperatingSystems([iUserTemplate.toJS()]));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use toJSON here or toShallowJS

]);
}
return getTemplateOperatingSystems(getTemplatesOfLabelType(templates, TEMPLATE_TYPE_BASE));
};

export const getWorkloadProfiles = (
templates: TemplateKind[],
{ flavor, os, userTemplate }: { flavor: string; os: string; userTemplate: string },
{ flavor, os, isUserTemplateValid }: { flavor: string; os: string; isUserTemplateValid: boolean },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need isUserTemplateValid variable? can we just pass templates and that is all?

@@ -34,48 +34,46 @@ export const getFlavorLabel = (flavor: string) => {
return undefined;
};

export const getOperatingSystems = (templates: TemplateKind[], userTemplate: string) => {
if (userTemplate) {
export const getOperatingSystems = (templates: TemplateKind[], userTemplateName: string) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, why do we need to pass userTemplateName?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@irosenzw please take a look. This should work the same way as getWorkloadProfiles.

workload,
os,
isUserTemplateValid,
}: { workload: string; os: string; isUserTemplateValid: boolean },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

const isUserTemplateValid = iGetIsLoaded(iUserTemplate) && !iGetLoadError(iUserTemplate);

const templates = isUserTemplateValid
? [iGetLoadedData(iUserTemplate).toJS()]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please prefer toShallowJS here

@irosenzw irosenzw force-pushed the remove-template-field-vm-wizard branch from 6de9114 to fec2f7d Compare September 9, 2020 12:59
let operatingSystems = [];

if (openshiftFlag && iUserTemplate) {
operatingSystems.push(getTemplateOperatingSystems([toShallowJS(iUserTemplate)]));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

array in an array. better to have an assignment?

@@ -43,7 +45,6 @@ export const WorkloadProfile: React.FC<WorkloadProps> = React.memo(
field={workloadProfileField}
fieldType={FormFieldType.SELECT}
loadingResources={{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be in loading resources if the wizard is in userTemplate mode


const workloadProfiles = getWorkloadProfiles(vanillaTemplates, params);
const workloadProfiles = getWorkloadProfiles(templates, params);

const loadingResources = openshiftFlag
? {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loadingResources: same here

@irosenzw irosenzw force-pushed the remove-template-field-vm-wizard branch from fec2f7d to 0804db0 Compare September 9, 2020 14:46
@matthewcarleton
Copy link
Contributor

What if we said

Could not load requested template
requested template vm-templates-example-5 can not be found. It may have been removed.
Please contact your admin for more information or choose another template (this could link back to the template list)

@matthewcarleton

We could do this, but I am against it at this time. This component handles all types of errors (of all resources and casuses) and if we start adding customization like this one on top of each other iit will become a mess.

We have to come either with a better generic solution to these errors or add a good extension framework.
If we try to do it here, this PR will get more out of scope.

+1 to improving this in general - I think errors are most helpful when they are specific. These generic errors don't help the user take action to fix the problem.

commonTemplates,
iUserTemplate,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be only assigned in userTemplate mode

};

const selectedUserTemplateUpdater = (options: UpdateOptions) => {
const { id, prevState, dispatch, getState } = options;
const state = getState();
if (!hasVmSettingsChanged(prevState, state, id, VMSettingsField.USER_TEMPLATE)) {

if (!hasCommonDataChanged(prevState, state, id, VMWizardProps.isUserTemplateInitialized)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any issue with it. It seems pretty simple:

const selectUserTemplateOnLoadedUpdater = (options: UpdateOptions) => {
  const { id, dispatch, getState } = options;
  const state = getState();

  if (
    iGetCommonData(state, id, VMWizardProps.isUserTemplateInitialized) ||
    !iGetLoadedCommonData(state, id, VMWizardProps.userTemplate)
  ) {
    return;
  }

  dispatch(
    vmWizardInternalActions[InternalActionType.UpdateCommonDataValue](
      id,
      [VMWizardProps.isUserTemplateInitialized],
      true,
    ),
  );

  const iUserTemplate = iGetLoadedCommonData(state, id, VMWizardProps.userTemplate);
  const isDisabled = asDisabled(iUserTemplate != null, VMWizardProps.userTemplate);

  dispatch(
    vmWizardInternalActions[InternalActionType.UpdateVmSettings](id, {
      [VMSettingsField.PROVISION_SOURCE_TYPE]: { isDisabled },
      [VMSettingsField.CONTAINER_IMAGE]: { isDisabled },
      [VMSettingsField.IMAGE_URL]: { isDisabled },
      [VMSettingsField.OPERATING_SYSTEM]: { isDisabled },
      [VMSettingsField.CLONE_COMMON_BASE_DISK_IMAGE]: {
        isHidden: asHidden(iUserTemplate != null, VMWizardProps.userTemplate),
      },
    }),
  );

  prefillVmTemplateUpdater(options);
};

@@ -34,48 +34,46 @@ export const getFlavorLabel = (flavor: string) => {
return undefined;
};

export const getOperatingSystems = (templates: TemplateKind[], userTemplate: string) => {
if (userTemplate) {
export const getOperatingSystems = (templates: TemplateKind[], userTemplateName: string) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@irosenzw please take a look. This should work the same way as getWorkloadProfiles.

@irosenzw irosenzw force-pushed the remove-template-field-vm-wizard branch 2 times, most recently from 81a5144 to 4be8724 Compare September 10, 2020 09:03
if (isCreateTemplate) {
return CREATE_VM_TEMPLATE;
}
if (isProviderImport) {
return IMPORT_VM;
}
return CREATE_VM;
return iUserTemplate ? `${CREATE_VM} from ${iGetName(iUserTemplate)} template` : CREATE_VM;

This comment was marked as resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already changed it

);
const isUserTemplateValid = iGetIsLoaded(iUserTemplate) && !iGetLoadError(iUserTemplate);

const templates = isUserTemplateValid
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are 3 options here

if iUserTemplate {
  if isUserTemplateValid {
    use iUserTemplate
  } else {
     use []
  }
} else {
  use commonTemplates
}

const vanillaTemplates = immutableListToShallowJS(
concatImmutableLists(iGetLoadedData(commonTemplates), iGetLoadedData(userTemplates)),
);
const templates = isUserTemplateValid
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, there are 3 options

commonTemplates,
cnvBaseImages,
}
: {};

if (openshiftFlag && iUserTemplate) {
Object.assign(loadingResources, { [iUserTemplate]: iUserTemplate });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Object.assign(loadingResources, { [iUserTemplate]: iUserTemplate });
Object.assign(loadingResources, { iUserTemplate: iUserTemplate });

the key is just called iUserTemplate (this notation would resolve in a key called [object Object])

};

if (iUserTemplate) {
Object.assign(loadingResources, { [iUserTemplate]: iUserTemplate });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Object.assign(loadingResources, { [iUserTemplate]: iUserTemplate });
Object.assign(loadingResources, { iUserTemplate: iUserTemplate });

@@ -144,7 +147,7 @@ export const OSFlavor: React.FC<OSFlavorProps> = React.memo(
checkboxDescription: '',
};

if (!userTemplate) {
if (!isUserTemplateValid) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!isUserTemplateValid) {
if (!iUserTemplate) {

like this?

let operatingSystemValidation;
let flavorValidation;

if (
iGetIsLoaded(commonTemplates) &&
iGetIsLoaded(userTemplates) &&
(iGetIsLoaded(commonTemplates) || isUserTemplateValid) &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just loaded not valid and &&

@irosenzw irosenzw force-pushed the remove-template-field-vm-wizard branch 2 times, most recently from 7656c41 to c3f7ea3 Compare September 10, 2020 10:11
@@ -88,7 +56,7 @@ const selectedUserTemplateUpdater = (options: UpdateOptions) => {
[VMSettingsField.IMAGE_URL]: { isDisabled },
[VMSettingsField.OPERATING_SYSTEM]: { isDisabled },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we should disable also workload profile since it cannot be changed for the user template

@@ -118,7 +121,7 @@ const CreateVMWizardFooterComponent: React.FC<CreateVMWizardFooterComponentProps
const isLastStep = activeStepID === VMWizardTab.RESULT;

const isNextButtonDisabled = isAnyStepLocked;
const isReviewButtonDisabled = isAnyStepLocked;
const isReviewButtonDisabled = isAnyStepLocked || isInvalidUserTemplate;

This comment was marked as outdated.

@irosenzw irosenzw force-pushed the remove-template-field-vm-wizard branch from c3f7ea3 to 9660223 Compare September 10, 2020 11:36
@@ -118,7 +121,8 @@ const CreateVMWizardFooterComponent: React.FC<CreateVMWizardFooterComponentProps
const isLastStep = activeStepID === VMWizardTab.RESULT;

const isNextButtonDisabled = isAnyStepLocked;
const isReviewButtonDisabled = isAnyStepLocked;
const isReviewButtonDisabled = isAnyStepLocked || isInvalidUserTemplate;
const isCreateButtonDisabled = isInvalidUserTemplate;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const isCreateButtonDisabled = isInvalidUserTemplate;
const isCreateButtonDisabled = isNextButtonDisabled || isInvalidUserTemplate;

When creating a VM from template the title will be:
`Create Virtual Machine from <template name>`

Signed-off-by: Ido Rosenzwig <irosenzw@redhat.com>
@irosenzw irosenzw force-pushed the remove-template-field-vm-wizard branch from 9660223 to b7c474c Compare September 10, 2020 12:20
@atiratree
Copy link
Member

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 10, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: irosenzw, suomiy

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 10, 2020
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 8338461 into openshift:master Sep 10, 2020
@openshift-ci-robot
Copy link
Contributor

@irosenzw: All pull requests linked via external trackers have merged:

Bugzilla bug 1871103 has been moved to the MODIFIED state.

In response to this:

Bug 1871103: Remove 'Template' field from VM wizard

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@spadgett spadgett added this to the v4.6 milestone Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-high Referenced Bugzilla bug's severity is high for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. component/kubevirt Related to kubevirt-plugin lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants