Skip to content

Commit

Permalink
refactor: update meter component
Browse files Browse the repository at this point in the history
  • Loading branch information
petermakowski committed Nov 8, 2023
1 parent 88f1c56 commit f7fe836
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 45 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"build-storybook": "storybook build"
},
"dependencies": {
"@canonical/maas-react-components": "1.3.0",
"@canonical/maas-react-components": "1.5.0",
"@canonical/macaroon-bakery": "1.3.2",
"@canonical/react-components": "0.46.0",
"@reduxjs/toolkit": "1.9.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,10 @@ const generateDropdownContent = (
value: free >= 0 ? free : 0,
},
]}
label={
free >= 0 ? (
max={pool.total}
>
<Meter.Label>
{free >= 0 ? (
<ul className="p-inline-list u-no-margin--bottom">
<li
className="p-inline-list__item"
Expand Down Expand Up @@ -163,10 +165,9 @@ const generateDropdownContent = (
Only {byteDisplay(freeBytes, true)} GB available in {name}
.
</div>
)
}
max={pool.total}
/>
)}
</Meter.Label>
</Meter>
</div>
</button>
);
Expand Down
18 changes: 9 additions & 9 deletions src/app/kvm/components/KVMResourceMeter/KVMResourceMeter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ const KVMResourceMeter = ({
value: free > 0 ? free : 0,
},
]}
label={
detailed ? (
max={total}
size="small"
variant={segmented ? "segmented" : "regular"}
>
<Meter.Label className="u-align--right">
{detailed ? (
<div>
<div className="p-text--x-small-capitalised u-text--muted u-sv-1">
Total
Expand All @@ -110,13 +114,9 @@ const KVMResourceMeter = ({
>
{`${formattedAllocated} of ${formattedTotal}${formattedUnit} allocated`}
</small>
)
}
labelClassName="u-align--right"
max={total}
segmented={segmented}
small
/>
)}
</Meter.Label>
</Meter>
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,35 +91,38 @@ const StoragePopover = ({
value: freeBytes > 0 ? freeBytes : 0,
},
]}
label={
<ul className="p-inline-list u-no-margin--bottom">
<li
className="p-inline-list__item"
data-testid="pool-allocated"
>
<i className="p-circle--link is-inline"></i>
{`${allocated.value}${allocated.unit}`}
</li>
{showOthers && (
max={pool.total}
>
<Meter.Label>
{
<ul className="p-inline-list u-no-margin--bottom">
<li
className="p-inline-list__item"
data-testid="pool-others"
data-testid="pool-allocated"
>
<i className="p-circle--positive is-inline"></i>
{`${other.value}${other.unit}`}
<i className="p-circle--link is-inline"></i>
{`${allocated.value}${allocated.unit}`}
</li>
)}
<li
className="p-inline-list__item"
data-testid="pool-free"
>
<i className="p-circle--link-faded is-inline"></i>
{`${free.value}${free.unit}`}
</li>
</ul>
}
max={pool.total}
/>
{showOthers && (
<li
className="p-inline-list__item"
data-testid="pool-others"
>
<i className="p-circle--positive is-inline"></i>
{`${other.value}${other.unit}`}
</li>
)}
<li
className="p-inline-list__item"
data-testid="pool-free"
>
<i className="p-circle--link-faded is-inline"></i>
{`${free.value}${free.unit}`}
</li>
</ul>
}
</Meter.Label>
</Meter>
</div>
</Fragment>
);
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2907,10 +2907,10 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==

"@canonical/maas-react-components@1.3.0":
version "1.3.0"
resolved "https://registry.yarnpkg.com/@canonical/maas-react-components/-/maas-react-components-1.3.0.tgz#5daa2302b7a1a061b4dad3aeb2337646810601cb"
integrity sha512-CVB0WHv1u0uViq0LGLvoa6dtbQEZlPP/+ovgHFJhEgbvLj9NxIfsfP/4P3OzmK/6BhGXFtwN5BKMvi55UcWlbg==
"@canonical/maas-react-components@1.5.0":
version "1.5.0"
resolved "https://registry.yarnpkg.com/@canonical/maas-react-components/-/maas-react-components-1.5.0.tgz#3cda970c9f95a1379f22fddd37e9c94eb7e345b2"
integrity sha512-pef2X+mf/W+/3q3kkIBrD9gHjb0z0S+JghDkd0mlmYuCbGxb+PqXk0vzlyEfzbIsltI0H/UEJLtNhM6kVTtD9A==

"@canonical/[email protected]":
version "1.3.2"
Expand Down

0 comments on commit f7fe836

Please sign in to comment.