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 1754478: Migrate TemplateSource component #3154

Merged

Conversation

irosenzw
Copy link
Contributor

Migrate TemplateSource component from kubevirt-web-ui-components

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

@openshift-ci-robot
Copy link
Contributor

@irosenzw: This pull request references Bugzilla bug 1754478, 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.

In response to this:

Bug 1754478: Migrate TemplateSource component

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 Oct 30, 2019
@openshift-ci-robot
Copy link
Contributor

Hi @irosenzw. Thanks for your PR.

I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. component/kubevirt Related to kubevirt-plugin labels Oct 30, 2019
@ohadlevy
Copy link

should we include any tests ?

@irosenzw irosenzw force-pushed the migrate-templateSource branch 2 times, most recently from 970878b to 730ba6b Compare October 31, 2019 15:14
@openshift-ci-robot openshift-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 3, 2019
@openshift-ci-robot openshift-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 4, 2019
@irosenzw irosenzw force-pushed the migrate-templateSource branch 3 times, most recently from feedfb7 to 3fab0e4 Compare November 7, 2019 11:22
const isProvisionSource =
dataVolumes && !!_.get(getTemplateProvisionSource(template, dataVolumes), 'type');
const provisionSource = ProvisionSource.getProvisionSourceDetails(template);
const isProvisionSource = dataVolumes && !!provisionSource.type;
Copy link
Member

Choose a reason for hiding this comment

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

you can discard the dataVolumes (loading and all) from the vm template details. They are not needed anymore.

@@ -125,7 +125,7 @@ export const VMTemplateDetailsList: React.FC<VMTemplateResourceListProps> = ({
idValue={prefixedID(id, 'provisioning-source')}
isNotAvail={!isProvisionSource}
Copy link
Member

Choose a reason for hiding this comment

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

this construct will never show a provision source error

Copy link
Member

Choose a reason for hiding this comment

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

in case we care about them, which I think we should

};

export const TemplateSource: React.FC<TemplateSourceProps> = ({ template, detailed = false }) => {
const provisionSource = ProvisionSource.getProvisionSourceDetails(template);
Copy link
Member

Choose a reason for hiding this comment

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

this call will return errors without a type

Copy link
Member

Choose a reason for hiding this comment

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

I think we should enhance this call for some kind of NA flag and render Not Available here

export const resolveURL = ({ urlObj, maxHostnameParts, maxPathnameParts }) =>
`${resolveOrigin(urlObj, maxHostnameParts)}${resolvePathname(urlObj, maxPathnameParts)}`;

export const URLObj: React.FC<URLObjProps> = ({
Copy link
Member

Choose a reason for hiding this comment

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

IMO we shouldn't mix components with utils files

Copy link
Member

Choose a reason for hiding this comment

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

otherwise it would look better to git mv this file instead

return (
<>
<Type type={type.getValue()} source={source} error={error} />
<Source type={type.getValue()} source={source} />
Copy link
Member

Choose a reason for hiding this comment

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

why not just pass the type reference?

const { type, source, error } = provisionSource;

if (!provisionSource || !provisionSource.type) {
if (showError) {
Copy link
Member

Choose a reason for hiding this comment

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

still, 'No bootable device found.' error is the same as Not available. I would rather use just the later one to be 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.

Just to be clear, do you want: No bootable device found or Not available error message ?

Copy link
Member

Choose a reason for hiding this comment

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

Not available should be fine

@@ -0,0 +1,254 @@
export const urlTemplate = {
Copy link
Member

Choose a reason for hiding this comment

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

IMO, I would rather split these templates into three files and put them to a separate directory

@irosenzw irosenzw force-pushed the migrate-templateSource branch 3 times, most recently from ca57cc5 to c720ce0 Compare November 20, 2019 05:59
@irosenzw
Copy link
Contributor Author

/retest

1 similar comment
@irosenzw
Copy link
Contributor Author

/retest

@irosenzw irosenzw force-pushed the migrate-templateSource branch 3 times, most recently from 7a8e5a6 to ac28bf5 Compare November 21, 2019 15:04
@@ -103,9 +103,13 @@ export class ProvisionSource extends ValueEnum<string> {
return {
error: `Datavolume ${volumeWrapper.getDataVolumeName()} does not have a supported source (${type}).`,
};
case undefined:
Copy link
Member

Choose a reason for hiding this comment

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

we could have a special check like this here, but it should go right after the volume lookup.

}
return <div>Invalid source</div>;
}
return <div title={source}>{type.getValue()}</div>;
Copy link
Member

Choose a reason for hiding this comment

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

we should try to be consistent - this should also be a tooltip

if (!detailed) {
return (
<Tooltip position="bottom" enableFlip={false} content={<>{error}</>} exitDelay={0}>
<div>Invalid source</div>
Copy link
Member

Choose a reason for hiding this comment

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

something like this.. + different ifs above

Suggested change
<div>Invalid source</div>
<div>{error ? 'Invalid Source' : type}</div>

const sourceElem =
type.getValue() === ProvisionSource.URL.getValue() ? <URLObj urlPath={source} short /> : source;

return <div>{sourceElem}</div>;
Copy link
Member

Choose a reason for hiding this comment

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

again consistency - why div here and not for the error?

Copy link
Member

Choose a reason for hiding this comment

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

also, this component should return null if there is no source or an error

}

const sourceElem =
type.getValue() === ProvisionSource.URL.getValue() ? <URLObj urlPath={source} short /> : source;
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
type.getValue() === ProvisionSource.URL.getValue() ? <URLObj urlPath={source} short /> : source;
type.getValue() === ProvisionSource.URL.getValue() ? <URLObj urlPath={source} short /> : (source || error);

@irosenzw irosenzw force-pushed the migrate-templateSource branch 2 times, most recently from 15884eb to 901328b Compare November 21, 2019 16:40
}

const sourceElem =
!type || type.getValue() === ProvisionSource.URL.getValue() ? (
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
!type || type.getValue() === ProvisionSource.URL.getValue() ? (
type && type.getValue() === ProvisionSource.URL.getValue() ? (

it is not an URL by default

@irosenzw irosenzw force-pushed the migrate-templateSource branch 2 times, most recently from d4b3c86 to 82e6dd9 Compare November 21, 2019 16:59
…mponents

Signed-off-by: Ido Rosenzwig <irosenzw@redhat.com>
@atiratree
Copy link
Member

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 21, 2019
@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 Nov 21, 2019
@atiratree
Copy link
Member

/retest

2 similar comments
@atiratree
Copy link
Member

/retest

@atiratree
Copy link
Member

/retest

@jelkosz
Copy link

jelkosz commented Nov 22, 2019

/test e2e-gcp-console

@jelkosz
Copy link

jelkosz commented Nov 22, 2019

/retest

@openshift-merge-robot openshift-merge-robot merged commit ae52137 into openshift:master Nov 22, 2019
@openshift-ci-robot
Copy link
Contributor

@irosenzw: All pull requests linked via external trackers have merged. Bugzilla bug 1754478 has been moved to the MODIFIED state.

In response to this:

Bug 1754478: Migrate TemplateSource component

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.4 milestone Nov 22, 2019
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/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. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants