Skip to content

Commit

Permalink
[grid-ui] Rewriting components covered by tests to be classes instead…
Browse files Browse the repository at this point in the history
… of functions
  • Loading branch information
barancev committed Feb 18, 2021
1 parent 78d66e8 commit ce3a14d
Show file tree
Hide file tree
Showing 5 changed files with 504 additions and 444 deletions.
97 changes: 53 additions & 44 deletions javascript/grid-ui/src/components/Error/Error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,56 +15,65 @@
// specific language governing permissions and limitations
// under the License.

import * as React from 'react';
import {Box, Container, Typography} from "@material-ui/core";
import {makeStyles} from "@material-ui/core/styles";
import React from 'react';
import {Box, Container, createStyles, Typography} from "@material-ui/core";
import {Theme, withStyles} from "@material-ui/core";

const useStyles = makeStyles((theme) => ({
root: {
backgroundColor: theme.palette.secondary.main,
height: '100%',
paddingBottom: theme.spacing(3),
paddingTop: theme.spacing(3),
width: '100%',
justifyContent: "center",
},
}));
const useStyles = (theme: Theme) => createStyles(
{
root: {
backgroundColor: theme.palette.secondary.main,
height: '100%',
paddingBottom: theme.spacing(3),
paddingTop: theme.spacing(3),
width: '100%',
justifyContent: "center",
},
});

export default function Error(props) {
const classes = useStyles();
const {message, errorMessage} = props;
type ErrorProps = {
message: string;
errorMessage: string;
classes: any;
};

// noinspection HtmlUnknownAnchorTarget
return (
<div className={classes.root}>
<Box
display="flex"
flexDirection="column"
height="100%"
justifyContent="center"
>
<Container maxWidth="md">
<Box mb={3}>
class Error extends React.Component<ErrorProps, {}> {
render () {
const {message, errorMessage, classes} = this.props;
// noinspection HtmlUnknownAnchorTarget
return (
<div className={classes.root}>
<Box
display="flex"
flexDirection="column"
height="100%"
justifyContent="center"
>
<Container maxWidth="md">
<Box mb={3}>
<Typography
align="center"
color="textPrimary"
variant="h3"
>
{message}
</Typography>
</Box>
<Typography
align="center"
color="textPrimary"
variant="h3"
variant="h4"
component={"span"}
>
{message}
<pre>
{errorMessage}
</pre>
</Typography>
</Box>
<Typography
align="center"
color="textPrimary"
variant="h4"
component={"span"}
>
<pre>
{errorMessage}
</pre>
</Typography>
</Container>
</Box>
</div>
);
</Container>
</Box>
</div>
);
}
}

export default withStyles(useStyles)(Error)
53 changes: 29 additions & 24 deletions javascript/grid-ui/src/components/Loading/Loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,43 @@
// specific language governing permissions and limitations
// under the License.

import * as React from 'react';
import {createStyles, makeStyles, Theme} from '@material-ui/core/styles';
import React from 'react';
import LinearProgress from '@material-ui/core/LinearProgress';
import {Box, Typography} from "@material-ui/core";
import {Box, createStyles, Theme, Typography, withStyles} from "@material-ui/core";

const useStyles = makeStyles((theme: Theme) =>
createStyles({
const useStyles = (theme: Theme) => createStyles(
{
root: {
backgroundColor: theme.palette.secondary.main,
height: '100%',
paddingTop: theme.spacing(1),
width: '100%',
justifyContent: "center",
},
}),
);
}
});

export default function Loading() {
const classes = useStyles();
type LoadingProps = {
classes: any;
};

return (
<div className={classes.root}>
<Box mb={2}>
<Typography
align="center"
color="textPrimary"
variant="h3"
>
Loading...
</Typography>
</Box>
<LinearProgress/>
</div>
);
class Loading extends React.Component<LoadingProps, {}>{
render() {
const {classes} = this.props;
return (
<div className={classes.root}>
<Box mb={2}>
<Typography
align="center"
color="textPrimary"
variant="h3"
>
Loading...
</Typography>
</Box>
<LinearProgress/>
</div>
);
}
}

export default withStyles(useStyles)(Loading)
Loading

0 comments on commit ce3a14d

Please sign in to comment.