-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat#38/change material-ui version to mui 5 #41
Changes from 6 commits
7b9dc1f
6b7b6fa
0ecc0f5
34fec71
e481f68
c3a36d1
4a44f86
d3f3741
bcc0fde
f4621e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
import React from 'react'; | ||
import React, { useContext } from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import { connect } from 'react-redux'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import AppBar from '@material-ui/core/AppBar'; | ||
import Toolbar from '@material-ui/core/Toolbar'; | ||
import IconButton from '@material-ui/core/IconButton'; | ||
import ExitToAppIcon from '@material-ui/icons/ExitToApp'; | ||
import GroupIcon from '@material-ui/icons/Group'; | ||
import makeStyles from '@mui/styles/makeStyles'; | ||
import AppBar from '@mui/material/AppBar'; | ||
import Toolbar from '@mui/material/Toolbar'; | ||
import IconButton from '@mui/material/IconButton'; | ||
import { TextField, MenuItem } from '@mui/material'; | ||
import ExitToAppIcon from '@mui/icons-material/ExitToApp'; | ||
import GroupIcon from '@mui/icons-material/Group'; | ||
import logo from '@assets/topbar-logo.png'; | ||
import { logout } from '@redux/authuser/authuser.actions'; | ||
import { routes } from '@routes/routesConstants'; | ||
import { UserContext } from '@context/User.context'; | ||
import { hasGlobalAdminRights, hasAdminRights } from '@utils/permissions'; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
appBar: { | ||
|
@@ -29,6 +32,35 @@ const useStyles = makeStyles((theme) => ({ | |
paper: { | ||
border: '1px solid', | ||
}, | ||
globalFilter: { | ||
width: theme.spacing(24), | ||
marginTop: theme.spacing(1.5), | ||
'& .MuiOutlinedInput-input': { | ||
padding: theme.spacing(1, 3.5, 1, 2), | ||
}, | ||
'& label.MuiInputLabel-outlined': { | ||
color: '#fff', | ||
}, | ||
'& label.Mui-focused': { | ||
color: '#fff', | ||
}, | ||
'&:hover': { | ||
'&& fieldset': { | ||
borderColor: '#fff', | ||
}, | ||
}, | ||
'& .MuiOutlinedInput-root': { | ||
'& fieldset': { | ||
borderColor: '#fff', | ||
}, | ||
'&.Mui-focused fieldset': { | ||
borderColor: '#fff', | ||
}, | ||
'& .MuiSelect-icon': { | ||
color: '#fff', | ||
}, | ||
}, | ||
}, | ||
})); | ||
|
||
/** | ||
|
@@ -41,6 +73,10 @@ function TopBar({ | |
}) { | ||
const classes = useStyles(); | ||
const [anchorEl, setAnchorEl] = React.useState(null); | ||
const user = useContext(UserContext); | ||
let isSuperAdmin = false; | ||
const isAdmin = hasAdminRights(user) || hasGlobalAdminRights(user); | ||
isSuperAdmin = hasGlobalAdminRights(user); | ||
|
||
const handleLogoutClick = () => { | ||
dispatch(logout()); | ||
|
@@ -55,12 +91,33 @@ function TopBar({ | |
</Link> | ||
|
||
<div className={classes.menuRight}> | ||
<Link to={routes.USER_MANAGEMENT}> | ||
<IconButton aria-label="user-management" color="inherit"> | ||
<GroupIcon fontSize="large" className={classes.menuIcon} /> | ||
</IconButton> | ||
</Link> | ||
<IconButton aria-label="logout" color="inherit" onClick={handleLogoutClick}> | ||
{isSuperAdmin && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Radhika can you tell me screen resolution, for me all medium and large screens placement is proper There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1320 x 1000 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
<TextField | ||
className={classes.globalFilter} | ||
variant="outlined" | ||
fullWidth | ||
id="org" | ||
label="Organization" | ||
select | ||
> | ||
<MenuItem> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is only None option hard coded here for Super Admin? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we don't have any api to fetch all org names There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should be an API that we already use in TP as well as Insights code. So it should be similar here as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried and it was throwing 404 confirmed with BE as well that there's no API in buildly.io to fetch all orgs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we want a global admin filter we need to have a list of organizations. Without it, you cannot create a dropdown for global admin. |
||
None | ||
</MenuItem> | ||
</TextField> | ||
)} | ||
{isAdmin && ( | ||
<Link to={routes.USER_MANAGEMENT}> | ||
<IconButton aria-label="user-management" color="inherit" size="large"> | ||
<GroupIcon fontSize="large" className={classes.menuIcon} /> | ||
</IconButton> | ||
</Link> | ||
)} | ||
<IconButton | ||
aria-label="logout" | ||
color="inherit" | ||
onClick={handleLogoutClick} | ||
size="large" | ||
> | ||
<ExitToAppIcon fontSize="large" className={classes.menuIcon} /> | ||
</IconButton> | ||
</div> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need StyledEngineProvider?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It gives custom styles precedence over MUI