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

Do not map vm status off to status ok #340

Merged
merged 8 commits into from
Apr 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions sass/components/Dashboard/inventory.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,11 @@
.kubevirt-inventory__row-status-item-icon--warn {
color: goldenrod;
}

.kubevirt-inventory__row-status-item-icon--off {
font-size: 1.7em;
}

.kubevirt-inventory__row-status-item-icon--in-progress {
font-size: 1.6em;
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ exports[`<Capacity /> renders correctly 1`] = `
Storage
</h3>
<h6>
5 KB available out of 10 KB
5 Ki available out of 10 Ki
</h6>
<div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,19 @@ exports[`<Inventory /> renders correctly 1`] = `
<div
class="kubevirt-inventory__row-status"
>
<div
class="kubevirt-inventory__row-status-item"
>
<span
aria-hidden="true"
class="pficon pficon-off kubevirt-inventory__row-status-item-icon--off"
/>
<span
class="kubevirt-inventory__row-status-item-text"
>
1
</span>
</div>
<div
class="kubevirt-inventory__row-status-item"
>
Expand All @@ -143,7 +156,7 @@ exports[`<Inventory /> renders correctly 1`] = `
<span
class="kubevirt-inventory__row-status-item-text"
>
2
1
</span>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ exports[`<Utilization /> renders correctly 1`] = `
<div
class="kubevirt-utilization__item-actual col-lg-6 col-md-6 col-sm-6 col-xs-6"
>
5 KB
5 Ki
</div>
</div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,19 @@ exports[`<ClusterOverview /> renders correctly with Provider 1`] = `
<div
class="kubevirt-inventory__row-status"
>
<div
class="kubevirt-inventory__row-status-item"
>
<span
aria-hidden="true"
class="pficon pficon-off kubevirt-inventory__row-status-item-icon--off"
/>
<span
class="kubevirt-inventory__row-status-item-text"
>
1
</span>
</div>
<div
class="kubevirt-inventory__row-status-item"
>
Expand All @@ -230,7 +243,7 @@ exports[`<ClusterOverview /> renders correctly with Provider 1`] = `
<span
class="kubevirt-inventory__row-status-item-text"
>
2
1
</span>
</div>
</div>
Expand Down
16 changes: 14 additions & 2 deletions src/components/Dashboard/Inventory/InventoryItemStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,30 @@ ErrorStatus.propTypes = StatusPropTypes;

const InProgressStatus = ({ count }) => (
<div className="kubevirt-inventory__row-status-item">
<Icon type="pf" name="in-progress" size="2x" />
<Icon type="pf" name="in-progress" className="kubevirt-inventory__row-status-item-icon--in-progress" />
<span className="kubevirt-inventory__row-status-item-text">{count}</span>
</div>
);

Copy link
Contributor

Choose a reason for hiding this comment

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

InProgressStatus is also type="pf" component. Please try the sizes.

InProgressStatus.propTypes = StatusPropTypes;

const OffStatus = ({ count }) => (
<div className="kubevirt-inventory__row-status-item">
<Icon type="pf" name="off" className="kubevirt-inventory__row-status-item-icon--off" />
<span className="kubevirt-inventory__row-status-item-text">{count}</span>
</div>
);

OffStatus.propTypes = StatusPropTypes;

const Status = ({ Component, count, ...props }) => count > 0 && <Component count={count} {...props} />;

export const InventoryItemStatus = ({ ok, warn, error, inProgress }) => (
export const InventoryItemStatus = ({ ok, warn, error, inProgress, off }) => (
Copy link
Contributor

Choose a reason for hiding this comment

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

please showcase this in the fixture

<div className="kubevirt-inventory__row-status">
<Status Component={InProgressStatus} count={inProgress} />
<Status Component={ErrorStatus} count={error} />
<Status Component={WarnStatus} count={warn} />
<Status Component={OffStatus} count={off} />
yaacov marked this conversation as resolved.
Show resolved Hide resolved
<Status Component={OkStatus} count={ok} />
</div>
);
Expand All @@ -58,11 +68,13 @@ InventoryItemStatus.defaultProps = {
warn: 0,
error: 0,
inProgress: 0,
off: 0,
};

InventoryItemStatus.propTypes = {
ok: PropTypes.number,
warn: PropTypes.number,
error: PropTypes.number,
inProgress: PropTypes.number,
off: PropTypes.number,
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default [
warn: 3,
error: 2,
inProgress: 1,
off: 3,
},
},
{
Expand All @@ -18,6 +19,7 @@ export default [
warn: 0,
error: 0,
inProgress: 0,
off: 0,
},
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports[`<InventoryItemStatus /> renders correctly 1`] = `
>
<span
aria-hidden="true"
class="pficon pficon-in-progress"
class="pficon pficon-in-progress kubevirt-inventory__row-status-item-icon--in-progress"
/>
<span
class="kubevirt-inventory__row-status-item-text"
Expand Down Expand Up @@ -43,6 +43,19 @@ exports[`<InventoryItemStatus /> renders correctly 1`] = `
3
</span>
</div>
<div
class="kubevirt-inventory__row-status-item"
>
<span
aria-hidden="true"
class="pficon pficon-off kubevirt-inventory__row-status-item-icon--off"
/>
<span
class="kubevirt-inventory__row-status-item-text"
>
3
</span>
</div>
<div
class="kubevirt-inventory__row-status-item"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exports[`<InventoryRow /> renders correctly 1`] = `
>
<span
aria-hidden="true"
class="pficon pficon-in-progress"
class="pficon pficon-in-progress kubevirt-inventory__row-status-item-icon--in-progress"
/>
<span
class="kubevirt-inventory__row-status-item-text"
Expand Down Expand Up @@ -52,6 +52,19 @@ exports[`<InventoryRow /> renders correctly 1`] = `
3
</span>
</div>
<div
class="kubevirt-inventory__row-status-item"
>
<span
aria-hidden="true"
class="pficon pficon-off kubevirt-inventory__row-status-item-icon--off"
/>
<span
class="kubevirt-inventory__row-status-item-text"
>
3
</span>
</div>
<div
class="kubevirt-inventory__row-status-item"
>
Expand Down
12 changes: 11 additions & 1 deletion src/components/Dashboard/Inventory/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { getVmStatus, VM_STATUS_ALL_ERROR, VM_STATUS_ALL_PROGRESS } from '../../../utils/status/vm';
import {
getVmStatus,
VM_STATUS_ALL_WARNING,
VM_STATUS_ALL_ERROR,
VM_STATUS_ALL_PROGRESS,
VM_STATUS_ALL_OFF,
} from '../../../utils/status/vm';
import { getPodStatus, POD_STATUS_ALL_ERROR, POD_STATUS_ALL_PROGRESS } from '../../../utils/status/pod';
import { getNodeStatus, NODE_STATUS_ALL_ERROR, NODE_STATUS_ALL_WARN } from '../../../utils/status/node';
import { getPvcStatus, PVC_STATUS_ALL_ERROR, PVC_STATUS_ALL_PROGRESS } from '../../../utils/status/pvc';
Expand All @@ -10,13 +16,15 @@ export const STATUS_RESULT_OK = 'ok';
export const STATUS_RESULT_WARN = 'warn';
export const STATUS_RESULT_ERROR = 'error';
export const STATUS_RESULT_IN_PROGRESS = 'inProgress';
export const STATUS_RESULT_OFF = 'off';

const mapStatuses = (entities, mapEntityToStatusResult) => {
const result = {
[STATUS_RESULT_OK]: 0,
[STATUS_RESULT_WARN]: 0,
[STATUS_RESULT_ERROR]: 0,
[STATUS_RESULT_IN_PROGRESS]: 0,
[STATUS_RESULT_OFF]: 0,
count: null,
};

Expand Down Expand Up @@ -45,8 +53,10 @@ export const mapNodesToProps = nodes =>
export const mapVmsToProps = (vms, pods, migrations) =>
mapStatuses(vms, vm =>
resolveStatusResult(getVmStatus(vm, pods, migrations).status, {
[STATUS_RESULT_WARN]: VM_STATUS_ALL_WARNING,
[STATUS_RESULT_ERROR]: VM_STATUS_ALL_ERROR,
[STATUS_RESULT_IN_PROGRESS]: VM_STATUS_ALL_PROGRESS,
[STATUS_RESULT_OFF]: VM_STATUS_ALL_OFF,
})
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ exports[`<Utilization /> renders correctly 1`] = `
<div
class="kubevirt-utilization__item-actual col-lg-6 col-md-6 col-sm-6 col-xs-6"
>
30 KiB/s
30 Ki/s
</div>
</div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ exports[`<StorageOverview /> renders correctly with Provider 1`] = `
class="card-pf kubevirt-dashboard__card"
>
<div
class="card-pf-heading kubevirt-dashboard__card-heading kubevirt-events__card-header"
class="card-pf-heading kubevirt-dashboard__card-heading"
>
<h2
class="card-pf-title"
Expand Down Expand Up @@ -313,7 +313,7 @@ exports[`<StorageOverview /> renders correctly with Provider 1`] = `
<div
class="kubevirt-utilization__item-actual col-lg-6 col-md-6 col-sm-6 col-xs-6"
>
30 KiB/s
30 Ki/s
</div>
</div>
<div
Expand All @@ -339,7 +339,7 @@ exports[`<StorageOverview /> renders correctly with Provider 1`] = `
class="card-pf kubevirt-dashboard__card"
>
<div
class="card-pf-heading kubevirt-dashboard__card-heading"
class="card-pf-heading kubevirt-dashboard__card-heading kubevirt-events__card-header"
>
<h2
class="card-pf-title"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ exports[`<DesktopViewerSelector /> renders correctly 1`] = `
},
},
],
"running": false,
"running": true,
"template": Object {
"spec": Object {
"domain": Object {
Expand Down Expand Up @@ -198,6 +198,10 @@ hostname: cloudinit-test
},
},
},
"status": Object {
"created": true,
"ready": true,
},
}
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ exports[`<ResultTabRow /> renders correctly 2`] = `
"selfLink": "/apis/kubevirt.io/v1alpha3/namespaces/default/virtualmachines/cloudinit-test-vm",
"uid": "bcc1d0b1-e1d0-11e8-82b4-54ee7586b9c3"
},
"status": {
"created": true,
"ready": false
},
"spec": {
"running": false,
"template": {
Expand Down
4 changes: 4 additions & 0 deletions src/tests/mocks/vm/cloudInitTestVm.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export const cloudInitTestVm = {
selfLink: '/apis/kubevirt.io/v1alpha3/namespaces/default/virtualmachines/cloudinit-test-vm',
uid: 'bcc1d0b1-e1d0-11e8-82b4-54ee7586b9c3',
},
status: {
created: true,
ready: false,
},
spec: {
running: false,
template: {
Expand Down
6 changes: 5 additions & 1 deletion src/tests/mocks/vm/vm.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export const fullVm = {
selfLink: '/apis/kubevirt.io/v1alpha3/namespaces/default/virtualmachines/cloudinit-test-vm',
uid: 'bcc1d0b1-e1d0-11e8-82b4-54ee7586b9c3',
},
status: {
created: true,
ready: true,
},
spec: {
dataVolumeTemplates: [
{
Expand All @@ -51,7 +55,7 @@ export const fullVm = {
},
},
],
running: false,
running: true,
template: {
spec: {
domain: {
Expand Down
11 changes: 6 additions & 5 deletions src/utils/status/vm/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ export const VM_STATUS_ERROR = 'VM_STATUS_ERROR';
export const VM_STATUS_IMPORT_ERROR = 'VM_STATUS_IMPORT_ERROR';
export const VM_STATUS_UNKNOWN = 'VM_STATUS_UNKNOWN';
export const VM_STATUS_MIGRATING = 'VM_STATUS_MIGRATING';
export const VM_STATUS_OTHER = 'VM_STATUS_OTHER'; // used for grouping filters

export const VM_STATUS_ALL = [VM_STATUS_RUNNING, VM_STATUS_OFF, VM_STATUS_OTHER];

export const VM_STATUS_ALL_OFF = [VM_STATUS_OFF];
export const VM_STATUS_ALL_WARNING = [VM_STATUS_UNKNOWN];
export const VM_STATUS_ALL_ERROR = [VM_STATUS_POD_ERROR, VM_STATUS_ERROR, VM_STATUS_IMPORT_ERROR];
export const VM_STATUS_ALL_PROGRESS = [
VM_STATUS_STARTING,
Expand All @@ -20,8 +19,10 @@ export const VM_STATUS_ALL_PROGRESS = [
VM_STATUS_MIGRATING,
];

export const VM_STATUS_TO_TEXT = {
export const VM_SIMPLE_STATUS_OTHER = 'VM_SIMPLE_STATUS_OTHER'; // used for grouping filters
export const VM_SIMPLE_STATUS_ALL = [VM_STATUS_RUNNING, VM_STATUS_OFF, VM_SIMPLE_STATUS_OTHER];
export const VM_SIMPLE_STATUS_TO_TEXT = {
[VM_STATUS_RUNNING]: 'Running',
[VM_STATUS_OFF]: 'Off',
[VM_STATUS_OTHER]: 'Other',
[VM_SIMPLE_STATUS_OTHER]: 'Other',
};
Loading