Skip to content

Commit 21f20bb

Browse files
authored
Migrated Policies module to mds (#2911)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
1 parent df93746 commit 21f20bb

File tree

7 files changed

+356
-414
lines changed

7 files changed

+356
-414
lines changed

portal-ui/src/screens/Console/Common/FormComponents/common/styleLibrary.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ export const actionsTray = {
197197
actionsTray: {
198198
display: "flex" as const,
199199
justifyContent: "space-between" as const,
200-
marginBottom: "1rem",
201200
alignItems: "center",
201+
marginBottom: "1rem",
202202
"& button": {
203203
flexGrow: 0,
204204
marginLeft: 8,

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ type SearchBoxProps = {
2323
value: string;
2424
onChange: (value: string) => void;
2525
overrideClass?: any;
26+
id?: string;
2627
sx?: CSSObject;
2728
};
2829

@@ -31,23 +32,20 @@ const SearchBox = ({
3132
onChange,
3233
overrideClass,
3334
value,
35+
id = "search-resource",
3436
sx,
3537
}: SearchBoxProps) => {
3638
return (
3739
<InputBox
3840
placeholder={placeholder}
3941
className={overrideClass ? overrideClass : ""}
40-
id="search-resource"
42+
id={id}
4143
label=""
4244
onChange={(e) => {
4345
onChange(e.target.value);
4446
}}
4547
value={value}
46-
overlayObject={
47-
<SearchIcon
48-
style={{ width: 16, height: 16, marginTop: 5, marginRight: 5 }}
49-
/>
50-
}
48+
startIcon={<SearchIcon />}
5149
sx={sx}
5250
/>
5351
);

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

1717
import React, { Fragment, useEffect, useState } from "react";
18-
import Grid from "@mui/material/Grid";
19-
import { Box } from "@mui/material";
2018
import {
2119
AddAccessRuleIcon,
2220
BackLink,
2321
Button,
2422
FormLayout,
2523
PageLayout,
24+
Box,
25+
Grid,
26+
InputBox,
2627
} from "mds";
27-
import InputBoxWrapper from "../Common/FormComponents/InputBoxWrapper/InputBoxWrapper";
2828
import AddPolicyHelpBox from "./AddPolicyHelpBox";
2929
import CodeMirrorWrapper from "../Common/FormComponents/CodeMirrorWrapper/CodeMirrorWrapper";
30+
import PageHeaderWrapper from "../Common/PageHeaderWrapper/PageHeaderWrapper";
31+
import HelpMenu from "../HelpMenu";
3032
import { IAM_PAGES } from "../../../common/SecureComponent/permissions";
3133
import { setErrorSnackMessage, setHelpName } from "../../../systemSlice";
3234
import { useNavigate } from "react-router-dom";
3335
import { useAppDispatch } from "../../../store";
3436
import { emptyPolicy } from "./utils";
35-
import PageHeaderWrapper from "../Common/PageHeaderWrapper/PageHeaderWrapper";
3637
import { api } from "../../../api";
3738
import { Error, HttpResponse, Policy } from "../../../api/consoleApi";
38-
import HelpMenu from "../HelpMenu";
3939

4040
const AddPolicyScreen = () => {
4141
const dispatch = useAppDispatch();
@@ -119,9 +119,9 @@ const AddPolicyScreen = () => {
119119
addRecord(e);
120120
}}
121121
>
122-
<Grid container item spacing={1}>
122+
<Grid container>
123123
<Grid item xs={12}>
124-
<InputBoxWrapper
124+
<InputBox
125125
id="policy-name"
126126
name="policy-name"
127127
label="Policy Name"
@@ -143,7 +143,7 @@ const AddPolicyScreen = () => {
143143
editorHeight={"350px"}
144144
/>
145145
</Grid>
146-
<Grid item xs={12} textAlign={"right"}>
146+
<Grid item xs={12} sx={{ textAlign: "right" }}>
147147
<Box
148148
sx={{
149149
display: "flex",

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
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";
18-
19-
import { DialogContentText } from "@mui/material";
17+
import React, { Fragment } from "react";
2018
import { ErrorResponseHandler } from "../../../common/types";
2119
import useApi from "../Common/Hooks/useApi";
2220
import ConfirmDialog from "../Common/ModalWrapper/ConfirmDialog";
@@ -65,10 +63,10 @@ const DeletePolicy = ({
6563
onConfirm={onConfirmDelete}
6664
onClose={onClose}
6765
confirmationContent={
68-
<DialogContentText>
66+
<Fragment>
6967
Are you sure you want to delete policy <br />
7068
<b>{selectedPolicy}</b>?
71-
</DialogContentText>
69+
</Fragment>
7270
}
7371
/>
7472
);

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

Lines changed: 39 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,18 @@
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

1717
import React, { Fragment, useEffect, useState } from "react";
18-
import { AddIcon, Button, HelpBox, IAMPoliciesIcon, PageLayout } from "mds";
19-
import { useNavigate } from "react-router-dom";
20-
import { Theme } from "@mui/material/styles";
21-
import createStyles from "@mui/styles/createStyles";
22-
import withStyles from "@mui/styles/withStyles";
23-
import Grid from "@mui/material/Grid";
24-
2518
import {
26-
actionsTray,
27-
containerForHeader,
28-
searchField,
29-
} from "../Common/FormComponents/common/styleLibrary";
19+
AddIcon,
20+
Button,
21+
DataTable,
22+
Grid,
23+
HelpBox,
24+
IAMPoliciesIcon,
25+
PageLayout,
26+
} from "mds";
27+
import { useNavigate } from "react-router-dom";
28+
import { actionsTray } from "../Common/FormComponents/common/styleLibrary";
3029
import { ErrorResponseHandler } from "../../../common/types";
31-
32-
import TableWrapper from "../Common/TableWrapper/TableWrapper";
3330
import {
3431
CONSOLE_UI_RESOURCE,
3532
createPolicyPermissions,
@@ -44,42 +41,25 @@ import {
4441
hasPermission,
4542
SecureComponent,
4643
} from "../../../common/SecureComponent";
47-
import SearchBox from "../Common/SearchBox";
48-
49-
import withSuspense from "../Common/Components/withSuspense";
50-
51-
import { encodeURLString } from "../../../common/utils";
52-
import { setErrorSnackMessage, setHelpName } from "../../../systemSlice";
53-
import { useAppDispatch } from "../../../store";
54-
import TooltipWrapper from "../Common/TooltipWrapper/TooltipWrapper";
55-
import PageHeaderWrapper from "../Common/PageHeaderWrapper/PageHeaderWrapper";
56-
import { api } from "../../../api";
5744
import {
5845
Error,
5946
HttpResponse,
6047
ListPoliciesResponse,
6148
Policy,
6249
} from "../../../api/consoleApi";
50+
import { encodeURLString } from "../../../common/utils";
51+
import { setErrorSnackMessage, setHelpName } from "../../../systemSlice";
52+
import { useAppDispatch } from "../../../store";
53+
import { api } from "../../../api";
54+
import SearchBox from "../Common/SearchBox";
55+
import withSuspense from "../Common/Components/withSuspense";
56+
import TooltipWrapper from "../Common/TooltipWrapper/TooltipWrapper";
57+
import PageHeaderWrapper from "../Common/PageHeaderWrapper/PageHeaderWrapper";
6358
import HelpMenu from "../HelpMenu";
6459

6560
const DeletePolicy = withSuspense(React.lazy(() => import("./DeletePolicy")));
6661

67-
const styles = (theme: Theme) =>
68-
createStyles({
69-
...actionsTray,
70-
...searchField,
71-
searchField: {
72-
...searchField.searchField,
73-
maxWidth: 380,
74-
},
75-
...containerForHeader,
76-
});
77-
78-
interface IPoliciesProps {
79-
classes: any;
80-
}
81-
82-
const ListPolicies = ({ classes }: IPoliciesProps) => {
62+
const ListPolicies = () => {
8363
const dispatch = useAppDispatch();
8464
const navigate = useNavigate();
8565

@@ -194,7 +174,7 @@ const ListPolicies = ({ classes }: IPoliciesProps) => {
194174
}, []);
195175

196176
return (
197-
<React.Fragment>
177+
<Fragment>
198178
{deleteOpen && (
199179
<DeletePolicy
200180
deleteOpen={deleteOpen}
@@ -204,14 +184,14 @@ const ListPolicies = ({ classes }: IPoliciesProps) => {
204184
)}
205185
<PageHeaderWrapper label="IAM Policies" actions={<HelpMenu />} />
206186

207-
<PageLayout className={classes.pageContainer}>
208-
<Grid container spacing={1}>
209-
<Grid item xs={12} className={classes.actionsTray}>
187+
<PageLayout>
188+
<Grid container sx={{ gap: 15 }}>
189+
<Grid item xs={12} sx={actionsTray.actionsTray}>
210190
<SearchBox
211191
onChange={setFilterPolicies}
212192
placeholder="Search Policies"
213-
overrideClass={classes.searchField}
214193
value={filterPolicies}
194+
sx={{ maxWidth: 380 }}
215195
/>
216196

217197
<SecureComponent
@@ -242,19 +222,13 @@ const ListPolicies = ({ classes }: IPoliciesProps) => {
242222
</TooltipWrapper>
243223
</SecureComponent>
244224
</Grid>
245-
<Grid item xs={12} className={classes.tableBlock}>
225+
<Grid item xs={12}>
246226
<SecureComponent
247227
scopes={[IAM_SCOPES.ADMIN_LIST_USER_POLICIES]}
248228
resource={CONSOLE_UI_RESOURCE}
249229
errorProps={{ disabled: true }}
250230
>
251-
<TableWrapper
252-
itemActions={tableActions}
253-
columns={[{ label: "Name", elementKey: "name" }]}
254-
isLoading={loading}
255-
records={filteredRecords}
256-
entityName="Policies"
257-
idField="name"
231+
<TooltipWrapper
258232
tooltip={
259233
canViewPolicy
260234
? ""
@@ -263,10 +237,19 @@ const ListPolicies = ({ classes }: IPoliciesProps) => {
263237
"view Policy details"
264238
)
265239
}
266-
/>
240+
>
241+
<DataTable
242+
itemActions={tableActions}
243+
columns={[{ label: "Name", elementKey: "name" }]}
244+
isLoading={loading}
245+
records={filteredRecords}
246+
entityName="Policies"
247+
idField="name"
248+
/>
249+
</TooltipWrapper>
267250
</SecureComponent>
268251
</Grid>
269-
<Grid item xs={12}>
252+
<Grid item xs={12} sx={{ marginTop: 15 }}>
270253
<HelpBox
271254
title={"Learn more about IAM POLICIES"}
272255
iconComponent={<IAMPoliciesIcon />}
@@ -301,8 +284,8 @@ const ListPolicies = ({ classes }: IPoliciesProps) => {
301284
</Grid>
302285
</Grid>
303286
</PageLayout>
304-
</React.Fragment>
287+
</Fragment>
305288
);
306289
};
307290

308-
export default withStyles(styles)(ListPolicies);
291+
export default ListPolicies;

0 commit comments

Comments
 (0)