Skip to content
This repository has been archived by the owner on Apr 28, 2020. It is now read-only.

Create VmDetails component #135

Merged
merged 17 commits into from
Jan 2, 2019

Conversation

pcbailey
Copy link
Contributor

@pcbailey pcbailey commented Dec 5, 2018

This PR creates a VmDetails component for the VM details overview page.

@kubevirt-bot kubevirt-bot added size/XL needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Dec 5, 2018
@jelkosz jelkosz requested review from mareklibra and rawagner and removed request for mareklibra December 5, 2018 13:09
src/components/Details/VmDetails/VmDetails.js Outdated Show resolved Hide resolved
src/components/Details/VmDetails/VmDetails.js Outdated Show resolved Hide resolved
</dd>

<dt>Operating System</dt>
<dd>{get(vm, 'metadata.annotations["os.template.cnv.io"]', DASHES)}</dd>
Copy link
Contributor

Choose a reason for hiding this comment

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

can you extract this to https://github.com/kubevirt/web-ui-components/blob/master/src/utils/selectors.js ? Same for Workload Profile and Templates.

I also moved the OS/Flavor/Workload from annotations to labels just today. So its under vm/metadata.labels not vm/metadata.annotations

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please also show the OS icon? In common templates it is defined as iconClass which points to standard openshift icons defined here.
Pleas note this icon might not be defined in the template so you can not rely on it 100%, but in all standard templates it should be there.

src/components/Details/VmDetails/VmDetails.js Outdated Show resolved Hide resolved
src/components/Details/VmDetails/VmDetails.js Outdated Show resolved Hide resolved
src/components/Details/VmDetails/VmDetails.js Outdated Show resolved Hide resolved
@@ -0,0 +1,5 @@
// TODO Add valid tests
Copy link
Contributor

Choose a reason for hiding this comment

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

Agree :-)

@pcbailey pcbailey changed the title Create VmDetails component WIP: Create VmDetails component Dec 10, 2018
@pcbailey pcbailey force-pushed the create-vm-details-component branch from 0a5caf1 to 3d3d990 Compare December 10, 2018 02:39
@kubevirt-bot kubevirt-bot added size/L and removed size/XL needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Dec 10, 2018
@coveralls
Copy link

Pull Request Test Coverage Report for Build 387

  • 18 of 49 (36.73%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-2.7%) to 83.492%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/k8s/mock_pod/cloudInitTestPod.pod.js 0 1 0.0%
src/k8s/mock_vm/cloudInitTestVm.vm.js 0 1 0.0%
src/k8s/mock_vmi/cloudInitTestVmi.vmi.js 0 1 0.0%
src/components/Details/VmDetails/VmDetails.js 12 40 30.0%
Totals Coverage Status
Change from base Build 386: -2.7%
Covered Lines: 1240
Relevant Lines: 1402

💛 - Coveralls

@coveralls
Copy link

coveralls commented Dec 10, 2018

Pull Request Test Coverage Report for Build 534

  • 50 of 52 (96.15%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 85.956%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/k8s/mock_pod/cloudInitTestPod.pod.js 0 1 0.0%
src/k8s/mock_vm/cloudInitTestVm.vm.js 0 1 0.0%
Totals Coverage Status
Change from base Build 523: 0.2%
Covered Lines: 1332
Relevant Lines: 1477

💛 - Coveralls

@pcbailey
Copy link
Contributor Author

I haven't been able to fully test all the changes due to my environment malfunctioning, but I wanted to push it to give you guys a chance to run it for yourself if you'd like. I still have a few more changes coming in addition to the tests. It builds fine for me, but there is a test failure that seems to be unrelated as it also occurs on master.

@pcbailey pcbailey force-pushed the create-vm-details-component branch from 3d3d990 to 97312bb Compare December 17, 2018 06:21
@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 18, 2018
src/models/index.js Outdated Show resolved Hide resolved
src/k8s/request.js Outdated Show resolved Hide resolved
src/components/Details/VmDetails/VmDetails.js Outdated Show resolved Hide resolved
@pcbailey pcbailey force-pushed the create-vm-details-component branch from 97312bb to e235245 Compare December 18, 2018 13:07
@kubevirt-bot kubevirt-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 18, 2018
@pcbailey pcbailey force-pushed the create-vm-details-component branch from e235245 to 18f01bc Compare December 18, 2018 13:54
src/components/Details/VmDetails/VmDetails.js Outdated Show resolved Hide resolved
src/components/Details/VmDetails/VmDetails.js Outdated Show resolved Hide resolved
src/k8s/request.js Outdated Show resolved Hide resolved
This commit makes changes based on review feedback, including the
following items:

- Use VmStatus instead of StateColumn
- Extract selectors
- Use cloudInitData function
- Remove dashes when no description is provided
- Add CPU and Memory to Flavor field
- Organize mocks for the VmDetails fixture
@pcbailey pcbailey force-pushed the create-vm-details-component branch from 18f01bc to 657b8e3 Compare December 19, 2018 04:08
src/components/Details/VmDetails/VmDetails.js Outdated Show resolved Hide resolved
src/components/Details/VmDetails/VmDetails.js Outdated Show resolved Hide resolved
src/components/Details/VmDetails/VmDetails.js Outdated Show resolved Hide resolved
src/components/Details/VmDetails/VmDetails.js Outdated Show resolved Hide resolved
src/components/Details/VmDetails/VmDetails.js Outdated Show resolved Hide resolved
@pcbailey pcbailey force-pushed the create-vm-details-component branch from 25e3491 to 87c23c4 Compare December 19, 2018 11:14
@pcbailey pcbailey force-pushed the create-vm-details-component branch from 1fa2e21 to 9f50f67 Compare December 20, 2018 16:25
@pcbailey pcbailey force-pushed the create-vm-details-component branch from 9f50f67 to c748bd8 Compare December 20, 2018 16:55
@pcbailey pcbailey changed the title WIP: Create VmDetails component Create VmDetails component Dec 20, 2018
export const getLabelValue = (vm, label) => {
let value;
if (has(vm, 'metadata.labels')) {
forEach(Object.keys(vm.metadata.labels), key => {
Copy link
Contributor

@atiratree atiratree Dec 21, 2018

Choose a reason for hiding this comment

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

maybe using an array find function would be more readable here

const ipAddresses = getVmIpAddresses(vmi);

return (
<Fragment>
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really see a reason for using Fragment here


const DASHES = '---';

export const getVmIpAddresses = vmi => {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe it would be better to move this function into selectors? + also the tests

export const getVmIpAddresses = vmi => {
let ipAddresses = [];
if (has(vmi, 'status.interfaces')) {
ipAddresses = vmi.status.interfaces.map(iface => iface.ipAddress);
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer this as a ternary condition, but there is no real need for this change.

const memory = getMemory(vm);
let resourceStr = '';
resourceStr += cpu ? `${cpu} CPU` : '';
resourceStr += memory ? `, ${memory} Memory` : '';
Copy link
Contributor

Choose a reason for hiding this comment

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

this will build a string starting with , if there is no cpu by any chance

<div className="co-m-pane__body">
<h1 className="co-m-pane__heading">Virtual Machine Overview</h1>
<div>
<div className="row">
Copy link
Contributor

Choose a reason for hiding this comment

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

We could use pf-react (bootstrap) Row and Col components here. I personally do not mind this approach but we are already using Col in this project, so I guess it would be better to be consistent.

</dl>
</div>

{/* Details columns */}
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it would be more useful to use ids like this for the columns and the descriptiveness would be kept.

<dd>{launcherPod ? launcherPod.spec.hostname : DASHES}</dd>

<dt>Namespace</dt>
<dd>{NamespaceResourceLink}</dd>
Copy link
Contributor

Choose a reason for hiding this comment

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

this component sharing is really ugly, but I guess we don't have a choice here.

},
};

export default {
Copy link
Contributor

Choose a reason for hiding this comment

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

We could expose more fixtures (with more colorful set of data) to the cosmos. cloudInitTestVm would be nice

@rawagner
Copy link
Contributor

rawagner commented Jan 2, 2019

Since @pcbailey is on PTO until the end of the week, I will merge this and create a follow-up PR which addresses @suomiy's review comments

@rawagner rawagner merged commit 2ec13fe into kubevirt:master Jan 2, 2019
@pcbailey pcbailey deleted the create-vm-details-component branch April 22, 2019 21:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants