Skip to content

Commit bc27db4

Browse files
bexsoftBenjamin Perez
andauthored
Migrated tablewrapper to use react-virtualized (#387)
Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
1 parent dd8e2b1 commit bc27db4

File tree

20 files changed

+372
-357
lines changed

20 files changed

+372
-357
lines changed

portal-ui/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"@types/react-redux": "^7.1.5",
1818
"@types/react-router": "^5.1.3",
1919
"@types/react-router-dom": "^5.1.2",
20+
"@types/react-virtualized": "^9.21.10",
2021
"@types/recharts": "^1.8.9",
2122
"@types/superagent": "^4.1.4",
2223
"@types/webpack-env": "^1.14.1",
@@ -40,6 +41,8 @@
4041
"react-redux": "^7.1.3",
4142
"react-router-dom": "^5.1.2",
4243
"react-scripts": "3.4.4",
44+
"react-virtualized": "^9.22.2",
45+
"react-window-infinite-loader": "^1.0.5",
4346
"recharts": "^1.8.5",
4447
"redux": "^4.0.4",
4548
"redux-thunk": "^2.3.0",

portal-ui/src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import Routes from "./Routes";
2121
import configureStore from "./store";
2222
import * as serviceWorker from "./serviceWorker";
2323
import { ThemeProvider, withStyles } from "@material-ui/core/styles";
24+
import "react-virtualized/styles.css";
2425

2526
import "./index.css";
2627
import theme from "./theme/main";

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

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ const ListBuckets = ({
197197
}
198198
});
199199

200-
const showInPage = filteredRecords.slice(offset, offset + rowsPerPage);
200+
const showInPage = filteredRecords;
201201

202202
return (
203203
<React.Fragment>
@@ -266,26 +266,14 @@ const ListBuckets = ({
266266
label: "Size",
267267
elementKey: "size",
268268
renderFunction: niceBytes,
269+
width: 60,
270+
contentTextAlign: "right",
269271
},
270272
]}
271273
isLoading={loading}
272274
records={showInPage}
273275
entityName="Buckets"
274276
idField="name"
275-
paginatorConfig={{
276-
rowsPerPageOptions: [5, 10, 25],
277-
colSpan: 3,
278-
count: filteredRecords.length,
279-
rowsPerPage: rowsPerPage,
280-
page: page,
281-
SelectProps: {
282-
inputProps: { "aria-label": "rows per page" },
283-
native: true,
284-
},
285-
onChangePage: handleChangePage,
286-
onChangeRowsPerPage: handleChangeRowsPerPage,
287-
ActionsComponent: MinTablePaginationActions,
288-
}}
289277
/>
290278
</Grid>
291279
</Grid>

portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ListObjects/ListObjects.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ const styles = (theme: Theme) =>
103103
marginLeft: 10,
104104
},
105105
},
106+
browsePaper: {
107+
height: "calc(100vh - 280px)",
108+
},
106109
"@global": {
107110
".rowElementRaw:hover .iconFileElm": {
108111
backgroundImage: "url(/images/ob_file_filled.svg)",
@@ -485,12 +488,15 @@ const ListObjects = ({
485488
label: "Size",
486489
elementKey: "size",
487490
renderFunction: niceBytes,
491+
width: 60,
492+
contentTextAlign: "right",
488493
},
489494
]}
490495
isLoading={loading}
491496
entityName="Objects"
492497
idField="name"
493498
records={filteredRecords}
499+
customPaperHeight={classes.browsePaper}
494500
/>
495501
</Grid>
496502
</Grid>

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

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -642,20 +642,6 @@ class ViewBucket extends React.Component<IViewBucketProps, IViewBucketState> {
642642
records={filteredRecords}
643643
entityName="Events"
644644
idField="id"
645-
paginatorConfig={{
646-
rowsPerPageOptions: [5, 10, 25],
647-
colSpan: 3,
648-
count: totalRecords,
649-
rowsPerPage: rowsPerPage,
650-
page: page,
651-
SelectProps: {
652-
inputProps: { "aria-label": "rows per page" },
653-
native: true,
654-
},
655-
onChangePage: handleChangePage,
656-
onChangeRowsPerPage: handleChangeRowsPerPage,
657-
ActionsComponent: MinTablePaginationActions,
658-
}}
659645
/>
660646
</TabPanel>
661647
<TabPanel index={1} value={curTab}>
@@ -683,20 +669,6 @@ class ViewBucket extends React.Component<IViewBucketProps, IViewBucketState> {
683669
records={filteredRules}
684670
entityName="Replication Rules"
685671
idField="id"
686-
paginatorConfig={{
687-
rowsPerPageOptions: [5, 10, 25],
688-
colSpan: 3,
689-
count: totalRecords,
690-
rowsPerPage: rowsPerPage,
691-
page: page,
692-
SelectProps: {
693-
inputProps: { "aria-label": "rows per page" },
694-
native: true,
695-
},
696-
onChangePage: handleChangePage,
697-
onChangeRowsPerPage: handleChangeRowsPerPage,
698-
ActionsComponent: MinTablePaginationActions,
699-
}}
700672
/>
701673
</TabPanel>
702674
</Grid>

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ const radioBasic = {
104104
width: 12,
105105
height: 12,
106106
borderRadius: "100%",
107-
'input:disabled ~ &': {
107+
"input:disabled ~ &": {
108108
border: "1px solid #9C9C9C",
109109
},
110110
};
@@ -120,8 +120,7 @@ export const radioIcons = {
120120

121121
export const containerForHeader = (bottomSpacing: any) => ({
122122
container: {
123-
padding: "110px 33px 30px",
124-
paddingBottom: bottomSpacing,
123+
padding: "110px 33px 0",
125124
"& h6": {
126125
color: "#777777",
127126
fontSize: 14,
@@ -210,3 +209,9 @@ export const objectBrowserCommon = {
210209
},
211210
},
212211
};
212+
213+
export const selectorsCommon = {
214+
multiSelectTable: {
215+
height: 200,
216+
},
217+
};

portal-ui/src/screens/Console/Common/TableWrapper/TableActionButton.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ import ConsoleIcon from "./TableActionIcons/ConsoleIcon";
2525
import GetAppIcon from "@material-ui/icons/GetApp";
2626
import SvgIcon from "@material-ui/core/SvgIcon";
2727
import { Link } from "react-router-dom";
28+
import { createStyles, withStyles } from "@material-ui/core/styles";
29+
30+
const styles = () =>
31+
createStyles({
32+
spacing: {
33+
margin: "0 8px",
34+
},
35+
});
2836

2937
interface IActionButton {
3038
type: string;
@@ -34,6 +42,7 @@ interface IActionButton {
3442
selected: boolean;
3543
sendOnlyId?: boolean;
3644
idField: string;
45+
classes: any;
3746
}
3847

3948
const defineIcon = (type: string, selected: boolean) => {
@@ -67,6 +76,7 @@ const TableActionButton = ({
6776
selected,
6877
to,
6978
sendOnlyId = false,
79+
classes,
7080
}: IActionButton) => {
7181
const valueClick = sendOnlyId ? valueToSend[idField] : valueToSend;
7282

@@ -82,6 +92,7 @@ const TableActionButton = ({
8292
}
8393
: () => null
8494
}
95+
className={classes.spacing}
8596
>
8697
{defineIcon(type, selected)}
8798
</IconButton>
@@ -107,4 +118,4 @@ const TableActionButton = ({
107118
return null;
108119
};
109120

110-
export default TableActionButton;
121+
export default withStyles(styles)(TableActionButton);

0 commit comments

Comments
 (0)