Skip to content

Commit a0a6b33

Browse files
authored
Add HelpTip to clarify Usage calculation (#3143)
1 parent d4c5e1b commit a0a6b33

File tree

3 files changed

+70
-11
lines changed

3 files changed

+70
-11
lines changed

web-app/src/screens/Console/Buckets/ListBuckets/BucketListItem.tsx

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16-
import React, { Fragment } from "react";
16+
import React, { Fragment, useState } from "react";
1717
import get from "lodash/get";
1818
import styled from "styled-components";
1919
import { Link, useNavigate } from "react-router-dom";
@@ -23,6 +23,7 @@ import {
2323
BucketsIcon,
2424
Checkbox,
2525
Grid,
26+
HelpTip,
2627
ReportedUsageIcon,
2728
TotalObjectsIcon,
2829
} from "mds";
@@ -37,6 +38,7 @@ import {
3738
} from "../../../../common/SecureComponent/permissions";
3839
import { hasPermission } from "../../../../common/SecureComponent";
3940
import { Bucket } from "../../../../api/consoleApi";
41+
import { usageClarifyingContent } from "screens/Console/Dashboard/BasicDashboard/ReportedUsage";
4042

4143
const BucketItemMain = styled.div(({ theme }) => ({
4244
border: `${get(theme, "borderColor", "#eaeaea")} 1px solid`,
@@ -129,6 +131,8 @@ const BucketListItem = ({
129131
}: IBucketListItem) => {
130132
const navigate = useNavigate();
131133

134+
const [clickOverride, setClickOverride] = useState<boolean>(false);
135+
132136
const usage = niceBytes(`${bucket.size}` || "0");
133137
const usageScalar = usage.split(" ")[0];
134138
const usageUnit = usage.split(" ")[1];
@@ -157,7 +161,7 @@ const BucketListItem = ({
157161
return (
158162
<BucketItemMain
159163
onClick={() => {
160-
navigate(`/buckets/${bucket.name}/admin`);
164+
!clickOverride && navigate(`/buckets/${bucket.name}/admin`);
161165
}}
162166
id={`manageBucket-${bucket.name}`}
163167
className={`bucket-item ${manageAllowed ? "disabled" : ""}`}
@@ -205,8 +209,22 @@ const BucketListItem = ({
205209
/>
206210
</Link>
207211

208-
<Grid item className={"metric"}>
209-
<ReportedUsageIcon />
212+
<Grid
213+
item
214+
className={"metric"}
215+
onMouseEnter={() =>
216+
bucket.details?.versioning && setClickOverride(true)
217+
}
218+
onMouseLeave={() =>
219+
bucket.details?.versioning && setClickOverride(false)
220+
}
221+
>
222+
{bucket.details?.versioning && (
223+
<HelpTip content={usageClarifyingContent} placement="top">
224+
<ReportedUsageIcon />{" "}
225+
</HelpTip>
226+
)}
227+
{!bucket.details?.versioning && <ReportedUsageIcon />}
210228
<span className={"metricLabel"}>Usage</span>
211229
<div className={"metricText"}>
212230
{usageScalar}

web-app/src/screens/Console/Dashboard/BasicDashboard/ReportedUsage.tsx

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
import React from "react";
17+
import React, { Fragment } from "react";
1818
import get from "lodash/get";
1919
import styled from "styled-components";
20-
import { Box, Tooltip } from "mds";
20+
import { Box, HelpTip } from "mds";
2121
import { Cell, Pie, PieChart } from "recharts";
2222

2323
const ReportedUsageMain = styled.div(({ theme }) => ({
@@ -53,6 +53,31 @@ const ReportedUsageMain = styled.div(({ theme }) => ({
5353
},
5454
},
5555
}));
56+
export const usageClarifyingContent = (
57+
<Fragment>
58+
<div>
59+
<strong> Not what you expected?</strong>
60+
<br />
61+
This Usage value is comparable to <strong>mc du --versions</strong> which
62+
represents the size of all object versions that exist in the buckets.
63+
<br />
64+
Running{" "}
65+
<a
66+
target="_blank"
67+
href="https://min.io/docs/minio/linux/reference/minio-mc/mc-du.html"
68+
>
69+
mc du
70+
</a>{" "}
71+
without the <strong>--versions</strong> flag or{" "}
72+
<a target="_blank" href="https://man7.org/linux/man-pages/man1/df.1.html">
73+
df
74+
</a>{" "}
75+
will provide different values corresponding to the size of all{" "}
76+
<strong>current</strong> versions and the physical disk space occupied
77+
respectively.
78+
</div>
79+
</Fragment>
80+
);
5681

5782
const ReportedUsage = ({
5883
usageValue,
@@ -79,7 +104,7 @@ const ReportedUsage = ({
79104
<span>Reported Usage</span>
80105
</div>
81106

82-
<Tooltip tooltip={`${usageValue} Bytes`}>
107+
<HelpTip content={usageClarifyingContent} placement="left">
83108
<label
84109
className={"unit-value"}
85110
style={{
@@ -88,8 +113,8 @@ const ReportedUsage = ({
88113
>
89114
{total}
90115
</label>
91-
</Tooltip>
92-
<label className={"unit-type"}>{unit}</label>
116+
<label className={"unit-type"}>{unit}</label>
117+
</HelpTip>
93118
</Box>
94119

95120
<Box>

web-app/src/screens/Console/ObjectBrowser/OBBucketList.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
ProgressBar,
2828
RefreshIcon,
2929
Grid,
30+
HelpTip,
3031
} from "mds";
3132
import { actionsTray } from "../Common/FormComponents/common/styleLibrary";
3233
import { SecureComponent } from "../../../common/SecureComponent";
@@ -50,13 +51,15 @@ import { Bucket } from "../../../api/consoleApi";
5051
import { api } from "../../../api";
5152
import { errorToHandler } from "../../../api/errors";
5253
import HelpMenu from "../HelpMenu";
54+
import { usageClarifyingContent } from "../Dashboard/BasicDashboard/ReportedUsage";
5355

5456
const OBListBuckets = () => {
5557
const dispatch = useAppDispatch();
5658
const navigate = useNavigate();
5759

5860
const [records, setRecords] = useState<Bucket[]>([]);
5961
const [loading, setLoading] = useState<boolean>(true);
62+
const [clickOverride, setClickOverride] = useState<boolean>(false);
6063
const [filterBuckets, setFilterBuckets] = useState<string>("");
6164

6265
const features = useSelector(selFeatures);
@@ -102,7 +105,8 @@ const OBListBuckets = () => {
102105
{
103106
type: "view",
104107
onClick: (bucket: Bucket) => {
105-
navigate(`${IAM_PAGES.OBJECT_BROWSER_VIEW}/${bucket.name}`);
108+
!clickOverride &&
109+
navigate(`${IAM_PAGES.OBJECT_BROWSER_VIEW}/${bucket.name}`);
106110
},
107111
},
108112
];
@@ -213,7 +217,19 @@ const OBListBuckets = () => {
213217
{
214218
label: "Size",
215219
elementKey: "size",
216-
renderFunction: (size: number) => niceBytesInt(size || 0),
220+
renderFunction: (size: number) => (
221+
<div
222+
onMouseEnter={() => setClickOverride(true)}
223+
onMouseLeave={() => setClickOverride(false)}
224+
>
225+
<HelpTip
226+
content={usageClarifyingContent}
227+
placement="right"
228+
>
229+
{niceBytesInt(size || 0)}
230+
</HelpTip>
231+
</div>
232+
),
217233
},
218234
{
219235
label: "Access",

0 commit comments

Comments
 (0)