Skip to content

Commit

Permalink
OS-7009: Pools page issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ab-hystax authored Nov 14, 2023
1 parent 2754e9d commit d86be6f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
9 changes: 7 additions & 2 deletions ngui/ui/src/components/PoolsTable/columns/expenses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ const expenses = () => ({
}

if (cost > limit) {
const timesMoreValue = round(percentXofY(cost, limit), 1);
const timesMore = timesMoreValue !== 1 ? ` (x${timesMoreValue})` : "";
const getTimesMore = () => {
const timesMoreValue = round(percentXofY(cost, limit), 1);
return timesMoreValue !== 1 ? ` (x${timesMoreValue})` : "";
};
// self assigned pool can have 0 limit
const timesMore = limit !== 0 ? getTimesMore() : "";

return (
<Tooltip
title={
Expand Down
26 changes: 14 additions & 12 deletions ngui/ui/src/components/PoolsTable/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const getSelfAssignedItem = (item, allPools, selfAssignedName) => {

return {
...itemInfo,
remain: unallocatedLimit - selfCost,
parent_id: item.id,
name: selfAssignedName,
purpose: undefined,
Expand All @@ -40,20 +41,21 @@ export const patchPools = (rootPool, selfAssignedNameFn) => {

const selfAssignedChildren = [];

const childrenUpdated = rootPool.children?.map((pool) => {
const patchedPool = {
...pool,
hasChildren: rootPool.children.some(({ parent_id: parentId }) => parentId === pool.id),
hasLimit: getHasLimit(pool),
remain: getRemain(pool)
};
const childrenUpdated =
rootPool.children?.map((pool) => {
const patchedPool = {
...pool,
hasChildren: rootPool.children.some(({ parent_id: parentId }) => parentId === pool.id),
hasLimit: getHasLimit(pool),
remain: getRemain(pool)
};

if (patchedPool.hasChildren) {
selfAssignedChildren.push(getSelfAssignedItem(patchedPool, rootPool.children, selfAssignedNameFn(patchedPool.name)));
}
if (patchedPool.hasChildren) {
selfAssignedChildren.push(getSelfAssignedItem(patchedPool, rootPool.children, selfAssignedNameFn(patchedPool.name)));
}

return patchedPool;
});
return patchedPool;
}) ?? [];

const rootPoolPatched = {
...rootPool,
Expand Down

0 comments on commit d86be6f

Please sign in to comment.