Skip to content

Commit 1311b17

Browse files
authored
UX menu toggle and license badge icon (#2127)
1 parent 7ecc102 commit 1311b17

File tree

6 files changed

+111
-2
lines changed

6 files changed

+111
-2
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// This file is part of MinIO Console Server
2+
// Copyright (c) 2022 MinIO, Inc.
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
import * as React from "react";
18+
import { SVGProps } from "react";
19+
20+
const MenuToggleIcon = (props: SVGProps<SVGSVGElement>) => (
21+
<svg
22+
xmlns="http://www.w3.org/2000/svg"
23+
className={`min-icon`}
24+
fill={"currentcolor"}
25+
viewBox="0 0 10 14"
26+
{...props}
27+
>
28+
<g transform="translate(19825 -11601) rotate(-90)">
29+
<path
30+
d="M-21-212v-2H-7v2Zm0-4v-2H-7v2Zm0-4v-2H-7v2Z"
31+
transform="translate(-11594 -19603)"
32+
fill="#fff"
33+
/>
34+
</g>
35+
</svg>
36+
);
37+
38+
export default MenuToggleIcon;
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// This file is part of MinIO Console Server
2+
// Copyright (c) 2022 MinIO, Inc.
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
import React from "react";
18+
import { useSelector } from "react-redux";
19+
import { AppState } from "../../../store";
20+
import { Box } from "@mui/material";
21+
import { CircleIcon } from "../../../icons";
22+
23+
const LicenseBadge = () => {
24+
const licenseInfo = useSelector(
25+
(state: AppState) => state?.system?.licenseInfo
26+
);
27+
28+
const { plan = "" } = licenseInfo || {};
29+
30+
if (plan) {
31+
return null;
32+
}
33+
34+
return (
35+
<Box
36+
sx={{
37+
position: "absolute",
38+
border: 0,
39+
}}
40+
>
41+
<Box
42+
sx={{
43+
position: "absolute",
44+
right: -19,
45+
top: -29,
46+
zIndex: 400,
47+
border: 0,
48+
}}
49+
style={{
50+
border: 0,
51+
}}
52+
>
53+
<CircleIcon
54+
style={{
55+
fill: "#c83b51",
56+
border: "1px solid #002148",
57+
borderRadius: "100%",
58+
width: 12,
59+
height: 12,
60+
}}
61+
/>
62+
</Box>
63+
</Box>
64+
);
65+
};
66+
67+
export default LicenseBadge;

portal-ui/src/screens/Console/Menu/MenuItem.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ const MenuItem = ({
150150
<Suspense fallback={<div>...</div>}>
151151
<page.icon />
152152
</Suspense>
153+
{page.badge ? <page.badge /> : null}
153154
</ListItemIcon>
154155
</Tooltip>
155156
)}

portal-ui/src/screens/Console/Menu/MenuToggle.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ import React, { Fragment, Suspense, useEffect } from "react";
1818
import OperatorLogo from "../../../icons/OperatorLogo";
1919
import { LoginMinIOLogo, VersionIcon } from "../../../icons";
2020
import { Box, IconButton } from "@mui/material";
21-
import { ChevronLeft } from "@mui/icons-material";
2221
import MenuIcon from "@mui/icons-material/Menu";
2322
import LicensedConsoleLogo from "../Common/Components/LicensedConsoleLogo";
2423
import { useSelector } from "react-redux";
2524
import useApi from "../Common/Hooks/useApi";
2625
import { setLicenseInfo } from "../../../systemSlice";
2726
import { AppState, useAppDispatch } from "../../../store";
27+
import MenuToggleIcon from "../../../icons/MenuToggleIcon";
2828

2929
type MenuToggleProps = {
3030
isOpen: boolean;
@@ -151,7 +151,7 @@ const MenuToggle = ({ isOpen, onToggle }: MenuToggleProps) => {
151151
}}
152152
size="small"
153153
>
154-
{isOpen ? <ChevronLeft /> : <MenuIcon />}
154+
{isOpen ? <MenuToggleIcon /> : <MenuIcon />}
155155
</IconButton>
156156
</Box>
157157
);

portal-ui/src/screens/Console/Menu/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export interface IMenuItem {
2828
fsHidden?: boolean;
2929
customPermissionFnc?: any;
3030
children?: IMenuItem[];
31+
badge?: any;
3132
}
3233

3334
export interface IRouteRule {

portal-ui/src/screens/Console/valid-routes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import {
5555
} from "../../icons";
5656
import SettingsIcon from "../../icons/SettingsIcon";
5757
import React from "react";
58+
import LicenseBadge from "./Menu/LicenseBadge";
5859

5960
export const validRoutes = (
6061
features: string[] | null | undefined,
@@ -247,6 +248,7 @@ export const validRoutes = (
247248
name: "License",
248249
id: "license",
249250
icon: LicenseIcon,
251+
badge: LicenseBadge,
250252
forceDisplay: true,
251253
},
252254
{

0 commit comments

Comments
 (0)