Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | 1x 1x 1x | import React, { useEffect } from "react"; import { AppBar, Badge, createStyles, Grid, GridJustification, IconButton, makeStyles, Theme, Toolbar, Tooltip, Typography } from "@material-ui/core"; import { ArrowBack as BackIcon, NotificationsOutlined as NotificationsIcon } from "@material-ui/icons"; import { connect } from "react-redux"; import { addConceptsToDictionaryLoadingListSelector } from "../apps/dictionaries"; import { AppState } from "../redux"; import { Link, useHistory } from "react-router-dom"; const useStyles = makeStyles((theme: Theme) => createStyles({ appBar: { paddingLeft: theme.spacing(7) + 1 }, content: { marginTop: "32px", height: "100%" }, grow: { flexGrow: 1 }, icon: { color: theme.palette.background.default } }) ); interface Props { children?: React.ReactNode; title: string; justifyChildren?: GridJustification; loadingList: boolean[]; backUrl?: string; backText?: string; headerComponent?: React.ReactNode; allowImplicitNavigation?: boolean; } const Header: React.FC<Props> = ({ children, title, justifyChildren = "center", loadingList = [], backUrl, backText = "Go back", headerComponent, allowImplicitNavigation = false }) => { const loadingItemsLength = loadingList.filter((loading: boolean) => loading) .length; const classes = useStyles(); useEffect(() => { document.title = `${title} | OpenMRS Dictionary Manager`; }, [title]); const history = useHistory(); return ( <div data-testid="header"> <AppBar position="sticky" className={classes.appBar}> <Toolbar> {backUrl ? ( <Tooltip title={backText}> <Link to={backUrl}> <IconButton> <BackIcon className={classes.icon} /> </IconButton> </Link> </Tooltip> ) : allowImplicitNavigation ? ( <Tooltip title="Go back"> <IconButton onClick={history.goBack}> <BackIcon className={classes.icon} /> </IconButton> </Tooltip> ) : ( <span /> )} <Typography variant="h5" noWrap> {title} </Typography> <div className={classes.grow} /> {headerComponent ? headerComponent : null} <div> {!(loadingItemsLength > 0) ? null : ( <Link to="/actions/"> <Tooltip title="In progress"> <IconButton> <Badge badgeContent={loadingItemsLength} color="secondary"> <NotificationsIcon className={classes.icon} /> </Badge> </IconButton> </Tooltip> </Link> )} </div> </Toolbar> </AppBar> <Grid container className={classes.content} component="div" justify={justifyChildren} alignItems="flex-start" > {children} </Grid> </div> ); }; const mapStateToProps = (state: AppState) => ({ loadingList: addConceptsToDictionaryLoadingListSelector(state) }); export default connect(mapStateToProps)(Header); |