Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | 15x 64x 48x 124x 64x 124x 28x 56x 64x 124x | import { useMemo } from "react";
import type { ColumnDef, Row } from "@tanstack/react-table";
import type { RamResource } from "@/app/kvm/components/RamResources/RamResources";
import { memoryWithUnit } from "@/app/kvm/utils";
type RamResourceColumnDef = ColumnDef<RamResource, Partial<RamResource>>;
const useRamResourcesColumns = ({
pageSize,
showOthers,
}: {
pageSize: number;
showOthers: boolean;
}): RamResourceColumnDef[] => {
return useMemo(
() => [
{
id: "type",
accessorKey: "type",
enableSorting: false,
header: "",
cell: ({
row: {
original: { type },
},
}: {
row: Row<RamResource>;
}) =>
type === "Hugepage" ? (
<>
Hugepage
{pageSize > 0 && (
<>
<br />
<strong
className="p-text--x-small u-text--light"
data-testid="page-size"
>
{`(Size: ${memoryWithUnit(pageSize)})`}
</strong>
</>
)}
</>
) : (
"General"
),
},
{
id: "allocated",
accessorKey: "allocated",
enableSorting: false,
header: () => (
<span className="u-text--light u-truncate">
Allocated
<span className="u-nudge-right--small">
<i className="p-circle--link"></i>
</span>
</span>
),
cell: ({
row: {
original: { allocated },
},
}: {
row: Row<RamResource>;
}) => memoryWithUnit(allocated),
},
...(showOthers
? [
{
id: "others",
accessorKey: "others",
enableSorting: false,
header: () => (
<span className="u-text--light u-truncate">
Others
<span className="u-nudge-right--small">
<i className="p-circle--positive"></i>
</span>
</span>
),
cell: ({
row: {
original: { others },
},
}: {
row: Row<RamResource>;
}) => memoryWithUnit(others),
},
]
: []),
{
id: "free",
accessorKey: "free",
enableSorting: false,
header: () => (
<span className="u-text--light u-truncate">
Free
<span className="u-nudge-right--small">
<i className="p-circle--link-faded"></i>
</span>
</span>
),
cell: ({
row: {
original: { free },
},
}: {
row: Row<RamResource>;
}) => memoryWithUnit(free),
},
],
[pageSize, showOthers]
);
};
export default useRamResourcesColumns;
|