Skip to content

Commit 1e59f13

Browse files
authored
Fix 1299: Tools menu not showing for Heal Only Policy (#1301)
* Fix 1299: Tools menu not showing for Heal Only Policy * Fix caching issue Signed-off-by: Daniel Valdivia <[email protected]>
1 parent dfcd49b commit 1e59f13

File tree

11 files changed

+121
-159
lines changed

11 files changed

+121
-159
lines changed

portal-ui/src/common/SecureComponent/permissions.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ export const IAM_SCOPES = {
122122
ADMIN_DELETE_POLICY: "admin:DeletePolicy",
123123
ADMIN_ATTACH_USER_OR_GROUP_POLICY: "admin:AttachUserOrGroupPolicy",
124124
ADMIN_HEAL_ACTION: "admin:Heal",
125+
ADMIN_HEALTH_ACTION: "admin:OBDInfo",
126+
ADMIN_CONSOLE_LOG_ACTION: "admin:ConsoleLog",
127+
ADMIN_TRACE_ACTION: "admin:ServerTrace",
125128
S3_ALL_ACTIONS: "s3:*",
126129
ADMIN_ALL_ACTIONS: "admin:*",
127130
};

portal-ui/src/icons/DiagnosticIcon.tsx

Lines changed: 0 additions & 44 deletions
This file was deleted.

portal-ui/src/icons/DiagnosticsIcon.tsx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,25 @@ import React, { SVGProps } from "react";
1919
const DiagnosticsIcon = (props: SVGProps<SVGSVGElement>) => {
2020
return (
2121
<svg
22-
{...props}
22+
xmlns="http://www.w3.org/2000/svg"
2323
className={`min-icon`}
2424
fill={"currentcolor"}
25-
xmlns="http://www.w3.org/2000/svg"
26-
viewBox="0 0 10.405 10.405"
25+
viewBox="0 0 256 256"
26+
{...props}
2727
>
28-
<path
29-
d="M9.932 4.778a.424.424 0 00-.424.424 4.31 4.31 0 01-4.305 4.3 4.309 4.309 0 01-4.3-4.3A4.311 4.311 0 014.784.918v1.259A3.06 3.06 0 002.15 5.202 3.062 3.062 0 005.208 8.26a3.062 3.062 0 003.058-3.058 3.06 3.06 0 00-2.634-3.025V.049h-.424A5.158 5.158 0 00.055 5.201a5.158 5.158 0 005.153 5.153 5.158 5.158 0 005.153-5.153.424.424 0 00-.429-.423zm-2.519.424a2.213 2.213 0 01-2.21 2.21 2.213 2.213 0 01-2.21-2.21A2.213 2.213 0 014.78 3.035v1.231a1.028 1.028 0 00-.606.936 1.03 1.03 0 001.03 1.03 1.03 1.03 0 001.03-1.03 1.028 1.028 0 00-.605-.936V3.035a2.212 2.212 0 011.784 2.167z"
30-
stroke="#000"
31-
strokeWidth={0.1}
32-
/>
28+
<defs>
29+
<clipPath id="prefix__a">
30+
<path d="M0 0h256v256H0z" />
31+
</clipPath>
32+
</defs>
33+
<g clipPath="url(#prefix__a)">
34+
<path fill="none" d="M0 0h256v256H0z" />
35+
<path
36+
data-name="Uni\xF3n 17"
37+
d="M.449 128.494A128.188 128.188 0 0 1 128.494.45h10.6v52.857a76.1 76.1 0 0 1 46.531 25.151 75.572 75.572 0 0 1 13.854 22.845 75.251 75.251 0 0 1 5.039 27.189 76.11 76.11 0 0 1-76.023 76.022 76.1 76.1 0 0 1-76.012-76.022 75.291 75.291 0 0 1 5.037-27.189 75.678 75.678 0 0 1 13.85-22.845 76.135 76.135 0 0 1 46.555-25.151v-31.18a106.369 106.369 0 0 0-19.6 3.814 106.378 106.378 0 0 0-18.193 7.25 107.579 107.579 0 0 0-16.385 10.312A108.253 108.253 0 0 0 49.54 56.524a108.229 108.229 0 0 0-11.676 15.37 107.348 107.348 0 0 0-8.787 17.356 106.17 106.17 0 0 0-7.459 39.244 107.008 107.008 0 0 0 106.877 106.892 107.017 107.017 0 0 0 106.9-106.892 10.5 10.5 0 0 1 3.1-7.479 10.49 10.49 0 0 1 7.475-3.1 10.593 10.593 0 0 1 10.584 10.58 128.2 128.2 0 0 1-128.057 128.057A128.2 128.2 0 0 1 .449 128.494Zm99.967-47.048a55.106 55.106 0 0 0-14.062 12.016 54.643 54.643 0 0 0-9.336 16.083 54.492 54.492 0 0 0-3.379 18.95 54.464 54.464 0 0 0 4.316 21.333 54.924 54.924 0 0 0 5.068 9.317 55.648 55.648 0 0 0 6.7 8.12 55.546 55.546 0 0 0 8.125 6.7 54.955 54.955 0 0 0 9.316 5.068 54.353 54.353 0 0 0 21.328 4.316 54.917 54.917 0 0 0 54.854-54.857 54.492 54.492 0 0 0-3.379-18.95 54.614 54.614 0 0 0-9.326-16.083 55.144 55.144 0 0 0-14.049-12.016 54.571 54.571 0 0 0-17.5-6.723v30.482a25.816 25.816 0 0 1 10.824 9.254 25.366 25.366 0 0 1 4.211 14.035 25.433 25.433 0 0 1-2.014 9.982 25.524 25.524 0 0 1-5.494 8.145 25.5 25.5 0 0 1-8.145 5.493 25.518 25.518 0 0 1-9.982 2.015 25.477 25.477 0 0 1-9.973-2.015 25.621 25.621 0 0 1-8.148-5.493 25.538 25.538 0 0 1-5.488-8.145 25.522 25.522 0 0 1-2.016-9.982 25.393 25.393 0 0 1 4.207-14.035 25.82 25.82 0 0 1 10.848-9.254V74.72a54.537 54.537 0 0 0-17.508 6.73Z"
38+
/>
39+
<path data-name="Rect\xE1ngulo 878" fill="none" d="M0 0h256v256H0z" />
40+
</g>
3341
</svg>
3442
);
3543
};

portal-ui/src/icons/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export { default as CopyIcon } from "./CopyIcon";
3434
export { default as CreateIcon } from "./CreateIcon";
3535
export { default as DashboardIcon } from "./DashboardIcon";
3636
export { default as DeleteIcon } from "./DeleteIcon";
37-
export { default as DiagnosticIcon } from "./DiagnosticIcon";
3837
export { default as DiagnosticsIcon } from "./DiagnosticsIcon";
3938
export { default as DocumentationIcon } from "./DocumentationIcon";
4039
export { default as DownloadIcon } from "./DownloadIcon";

portal-ui/src/screens/Console/Common/IconsScreen.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ import {
4141
CreateIcon,
4242
DashboardIcon,
4343
DeleteIcon,
44-
DiagnosticIcon,
4544
DiagnosticsIcon,
4645
DocumentationIcon,
4746
DownloadIcon,
@@ -225,10 +224,6 @@ const IconsScreen = ({ classes }: IIconsScreenSimple) => {
225224
<DeleteIcon /> <br />
226225
DeleteIcon
227226
</Grid>
228-
<Grid item xs={3} sm={2} md={1}>
229-
<DiagnosticIcon /> <br />
230-
DiagnosticIcon
231-
</Grid>
232227
<Grid item xs={3} sm={2} md={1}>
233228
<DiagnosticsIcon /> <br />
234229
DiagnosticsIcon

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ const Console = ({
270270
const allowedPages = !session
271271
? []
272272
: session.pages.reduce((result: any, item: any, index: any) => {
273+
if (item.startsWith("/tools")) {
274+
result["/tools"] = true;
275+
}
273276
result[item] = true;
274277
return result;
275278
}, {});

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

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,12 @@ import api from "../../../common/api";
4242

4343
import MenuIcon from "@mui/icons-material/Menu";
4444
import LogoutIcon from "../../../icons/LogoutIcon";
45+
import { resetSession } from "../actions";
4546

4647
const drawerWidth = 245;
4748

4849
const BucketsIcon = React.lazy(() => import("../../../icons/BucketsIcon"));
4950
const DashboardIcon = React.lazy(() => import("../../../icons/DashboardIcon"));
50-
const DiagnosticsIcon = React.lazy(
51-
() => import("../../../icons/DiagnosticsIcon")
52-
);
5351
const GroupsIcon = React.lazy(() => import("../../../icons/GroupsIcon"));
5452
const IAMPoliciesIcon = React.lazy(
5553
() => import("../../../icons/IAMPoliciesIcon")
@@ -61,7 +59,6 @@ const UsersIcon = React.lazy(() => import("../../../icons/UsersIcon"));
6159
const VersionIcon = React.lazy(() => import("../../../icons/VersionIcon"));
6260
const LicenseIcon = React.lazy(() => import("../../../icons/LicenseIcon"));
6361

64-
const HealIcon = React.lazy(() => import("../../../icons/HealIcon"));
6562
const AccountIcon = React.lazy(() => import("../../../icons/AccountIcon"));
6663
const DocumentationIcon = React.lazy(
6764
() => import("../../../icons/DocumentationIcon")
@@ -290,6 +287,7 @@ interface IMenuProps {
290287
distributedSetup: boolean;
291288
sidebarOpen: boolean;
292289
setMenuOpen: typeof setMenuOpen;
290+
resetSession: typeof resetSession;
293291
}
294292

295293
const Menu = ({
@@ -300,13 +298,14 @@ const Menu = ({
300298
distributedSetup,
301299
sidebarOpen,
302300
setMenuOpen,
301+
resetSession,
303302
}: IMenuProps) => {
304303
const logout = () => {
305304
const deleteSession = () => {
306305
clearSession();
307306
userLoggedIn(false);
308307
localStorage.setItem("userLoggedIn", "");
309-
308+
resetSession();
310309
history.push("/login");
311310
};
312311
api
@@ -402,23 +401,6 @@ const Menu = ({
402401
name: "Tools",
403402
icon: ToolsIcon,
404403
},
405-
{
406-
group: "Tools",
407-
type: "item",
408-
component: NavLink,
409-
to: "/heal",
410-
name: "Heal",
411-
icon: HealIcon,
412-
fsHidden: distributedSetup,
413-
},
414-
{
415-
group: "Tools",
416-
type: "item",
417-
component: NavLink,
418-
to: "/health-info",
419-
name: "Diagnostic",
420-
icon: DiagnosticsIcon,
421-
},
422404
{
423405
group: "Operator",
424406
type: "item",
@@ -438,6 +420,9 @@ const Menu = ({
438420
];
439421

440422
const allowedPages = pages.reduce((result: any, item: any) => {
423+
if (item.startsWith("/tools")) {
424+
result["/tools"] = true;
425+
}
441426
result[item] = true;
442427
return result;
443428
}, {});
@@ -643,6 +628,10 @@ const mapState = (state: AppState) => ({
643628
distributedSetup: state.system.distributedSetup,
644629
});
645630

646-
const connector = connect(mapState, { userLoggedIn, setMenuOpen });
631+
const connector = connect(mapState, {
632+
userLoggedIn,
633+
setMenuOpen,
634+
resetSession,
635+
});
647636

648637
export default connector(withStyles(styles)(Menu));

portal-ui/src/screens/Console/Tools/ToolsPanel/ToolsList.tsx

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import createStyles from "@mui/styles/createStyles";
2020
import withStyles from "@mui/styles/withStyles";
2121
import Grid from "@mui/material/Grid";
2222

23-
import { configurationElements } from "../utils";
2423
import {
2524
actionsTray,
2625
containerForHeader,
@@ -29,6 +28,21 @@ import {
2928
import PageHeader from "../../Common/PageHeader/PageHeader";
3029
import SettingsCard from "../../Common/SettingsCard/SettingsCard";
3130
import PageLayout from "../../Common/Layout/PageLayout";
31+
import { IElement } from "../types";
32+
import {
33+
DiagnosticsIcon,
34+
HealIcon,
35+
LogsIcon,
36+
SearchIcon,
37+
TraceIcon,
38+
WatchIcon,
39+
} from "../../../../icons";
40+
import { hasPermission } from "../../../../common/SecureComponent/SecureComponent";
41+
import {
42+
CONSOLE_UI_RESOURCE,
43+
IAM_SCOPES,
44+
} from "../../../../common/SecureComponent/permissions";
45+
import SpeedtestIcon from "../../../../icons/SpeedtestIcon";
3246

3347
interface IConfigurationOptions {
3448
classes: any;
@@ -76,6 +90,59 @@ const styles = (theme: Theme) =>
7690
});
7791

7892
const ToolsList = ({ classes }: IConfigurationOptions) => {
93+
const configurationElements: IElement[] = [
94+
{
95+
icon: <LogsIcon />,
96+
configuration_id: "logs",
97+
configuration_label: "Logs",
98+
disabled: !hasPermission(CONSOLE_UI_RESOURCE, [
99+
IAM_SCOPES.ADMIN_CONSOLE_LOG_ACTION,
100+
]),
101+
},
102+
{
103+
icon: <SearchIcon />,
104+
configuration_id: "audit-logs",
105+
configuration_label: "Audit Logs",
106+
},
107+
{
108+
icon: <WatchIcon />,
109+
configuration_id: "watch",
110+
configuration_label: "Watch",
111+
},
112+
{
113+
icon: <TraceIcon />,
114+
configuration_id: "trace",
115+
configuration_label: "trace",
116+
disabled: !hasPermission(CONSOLE_UI_RESOURCE, [
117+
IAM_SCOPES.ADMIN_TRACE_ACTION,
118+
]),
119+
},
120+
{
121+
icon: <HealIcon />,
122+
configuration_id: "heal",
123+
configuration_label: "heal",
124+
disabled: !hasPermission(CONSOLE_UI_RESOURCE, [
125+
IAM_SCOPES.ADMIN_HEAL_ACTION,
126+
]),
127+
},
128+
{
129+
icon: <DiagnosticsIcon />,
130+
configuration_id: "diagnostics",
131+
configuration_label: "Diagnostics",
132+
disabled: !hasPermission(CONSOLE_UI_RESOURCE, [
133+
IAM_SCOPES.ADMIN_HEALTH_ACTION,
134+
]),
135+
},
136+
{
137+
icon: <SpeedtestIcon />,
138+
configuration_id: "speedtest",
139+
configuration_label: "Speedtest",
140+
disabled: !hasPermission(CONSOLE_UI_RESOURCE, [
141+
IAM_SCOPES.ADMIN_HEAL_ACTION,
142+
]),
143+
},
144+
];
145+
79146
return (
80147
<Fragment>
81148
<PageHeader label={"Tools"} />

portal-ui/src/screens/Console/Tools/utils.tsx

Lines changed: 0 additions & 75 deletions
This file was deleted.

0 commit comments

Comments
 (0)