Skip to content

Commit

Permalink
Update instance groups
Browse files Browse the repository at this point in the history
* Simplify criteria to instance group to be considered unavailable
* Round values for used capacity

See: ansible#7467
  • Loading branch information
nixocio committed Aug 28, 2020
1 parent aa637d5 commit 5c9908c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ function InstanceGroupDetails({ instanceGroup, i18n }) {

const { error, dismissError } = useDismissableError(deleteError);

const isAvailable = item => {
return (
(item.policy_instance_minimum || item.policy_instance_percentage) &&
item.capacity
);
};

const verifyIsIsolated = item => {
if (item.is_isolated) {
return (
Expand Down Expand Up @@ -89,10 +82,12 @@ function InstanceGroupDetails({ instanceGroup, i18n }) {
dataCy="instance-group-policy-instance-percentage"
content={`${instanceGroup.policy_instance_percentage} %`}
/>
{isAvailable(instanceGroup) ? (
{instanceGroup.capacity ? (
<DetailBadge
label={i18n._(t`Used capacity`)}
content={`${100 - instanceGroup.percent_capacity_remaining} %`}
content={`${Math.round(
100 - instanceGroup.percent_capacity_remaining
)} %`}
dataCy="instance-group-used-capacity"
/>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,21 @@ function InstanceGroupListItem({
}) {
const labelId = `check-action-${instanceGroup.id}`;

const isAvailable = item => {
return (
(item.policy_instance_minimum || item.policy_instance_percentage) &&
item.capacity
);
};

const isContainerGroup = item => {
return item.is_containerized;
};

function usedCapacity(item) {
if (!isContainerGroup(item)) {
if (isAvailable(item)) {
if (item.capacity) {
return (
<Progress
value={100 - item.percent_capacity_remaining}
value={Math.round(100 - item.percent_capacity_remaining)}
measureLocation={ProgressMeasureLocation.top}
size={ProgressSize.sm}
title={i18n._(t`Used capacity`)}
min={0}
max={100}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function InstanceListItem({
if (item.enabled) {
return (
<Progress
value={100 - item.percent_capacity_remaining}
value={Math.round(100 - item.percent_capacity_remaining)}
measureLocation={ProgressMeasureLocation.top}
size={ProgressSize.sm}
title={i18n._(t`Used capacity`)}
Expand Down

0 comments on commit 5c9908c

Please sign in to comment.