Skip to content
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

OM-115: fix sidebar, layout adjustments #193

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 26 additions & 17 deletions src/components/RequireAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { useBoolean, useAuthentication } from "../helpers/hooks";
import FormControlLabel from '@material-ui/core/FormControlLabel';
import { Switch } from "@material-ui/core";
import { useTranslations } from "../helpers/i18n";
import { DEFAULT } from "../constants";

export const APP_BAR_CONTRIBUTION_KEY = "core.AppBar";
export const MAIN_MENU_CONTRIBUTION_KEY = "core.MainMenu";
Expand Down Expand Up @@ -200,8 +201,16 @@ const useStyles = makeStyles((theme) => ({
}));

const RequireAuth = (props) => {
const { children, logo, redirectTo, isSecondaryCalendar, setSecondaryCalendar, onEconomicDialogOpen, ...others } = props;
const [isOpen, setOpen] = useBoolean();
const {
children,
logo,
whiteLogo,
redirectTo,
isSecondaryCalendar,
setSecondaryCalendar,
onEconomicDialogOpen,
...others
} = props; const [isOpen, setOpen] = useBoolean();
const [isDrawerOpen, setDrawerOpen] = useBoolean();
const theme = useTheme();
const classes = useStyles();
Expand All @@ -214,6 +223,7 @@ const RequireAuth = (props) => {
"allowSecondCalendar",
false,
);
const isWorker = modulesManager.getConf("fe-insuree", "isWorker", DEFAULT.IS_WORKER);

const isAppBarMenu = useMemo(() => theme.menu.variant.toUpperCase() === "APPBAR", [theme.menu.variant]);

Expand Down Expand Up @@ -243,7 +253,7 @@ const RequireAuth = (props) => {
<Button className={classes.appName} onClick={(e) => (window.location.href = "/front")}>
{isAppBarMenu && (
<Hidden smDown implementation="css">
<img className={classes.logo} src={logo} />
<img className={classes.logo} src={isWorker && !!whiteLogo ? whiteLogo : logo} alt="Logo of openIMIS" />
</Hidden>
)}
<FormattedMessage module="core" id="appName" defaultMessage={<FormattedMessage id="root.appName" />} />
Expand Down Expand Up @@ -291,10 +301,12 @@ const RequireAuth = (props) => {
<Button className={classes.appName} onClick={(e) => history.push("/")}>
{isAppBarMenu && (
<Hidden smDown implementation="css">
<img className={classes.logo} src={logo} />
<img className={classes.logo} src={isWorker && !!whiteLogo ? whiteLogo : logo} alt="Logo of openIMIS" />
</Hidden>
)}
<FormattedMessage module="core" id="appName" defaultMessage={<FormattedMessage id="root.appName" />} />
{!isWorker && (
<FormattedMessage module="core" id="appName" defaultMessage={<FormattedMessage id="root.appName" />} />
)}
</Button>
<Hidden smDown implementation="css">
<Tooltip title={modulesManager.getModulesVersions().join(", ")}>
Expand All @@ -313,18 +325,15 @@ const RequireAuth = (props) => {
<Contributions {...others} contributionKey={APP_BAR_CONTRIBUTION_KEY}>
<div className={classes.grow} />
</Contributions>
{!!calendarSwitch &&
<FormControlLabel
control={
<Switch
color="secondary"
checked={isSecondaryCalendar}
onChange={setSecondaryCalendar.toggle}
/>}
label={formatMessage("core.calendarSwitcher")}
labelPlacement="start"
/>
}
{!!calendarSwitch && (
<FormControlLabel
control={
<Switch color="secondary" checked={isSecondaryCalendar} onChange={setSecondaryCalendar.toggle} />
}
label={formatMessage("core.calendarSwitcher")}
labelPlacement="start"
/>
)}
<Contributions
contributionKey={ECONOMIC_UNIT_BUTTON_CONTRIBUTION_KEY}
onEconomicDialogOpen={onEconomicDialogOpen}
Expand Down
16 changes: 10 additions & 6 deletions src/components/generics/MainMenuContribution.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const styles = (theme) => ({
drawerHeading: {
fontSize: theme.menu.drawer.fontSize,
color: theme.menu.drawer.textColor,
paddingTop: theme.menu.drawer.fontSize / 2,
},
drawerDivider: {
// width: 100
Expand Down Expand Up @@ -68,22 +67,27 @@ const Accordion = withStyles({
expanded: {},
})(MuiAccordion);

const AccordionSummary = withStyles({
const AccordionSummary = withStyles((theme) => ({
root: {
backgroundColor: "#006273",

backgroundColor: theme.palette.primary.main,
color: theme.palette.secondary.main,
minHeight: 56,
"&$expanded": {
minHeight: 56,
},
},
content: {
margin: "0",
padding: "0",
alignItems: 'center',
justifyContent: 'start',
"&$expanded": {
margin: "12px 0",
margin: "0",
},
color: theme.palette.secondary.main
},
expanded: {},
})(MuiAccordionSummary);
}))(MuiAccordionSummary);

const AccordionDetails = withStyles((theme) => ({
root: {
Expand Down
5 changes: 1 addition & 4 deletions src/components/generics/Searcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ const styles = (theme) => ({
paperHeaderAction: {
paddingInline: 5,
},
paperDivider: theme.paper.divider,
tableHeaderAction: theme.table.headerAction,
processing: {
margin: theme.spacing(1),
Expand Down Expand Up @@ -518,9 +517,7 @@ class Searcher extends Component {
</Grid>
)}
</Grid>
<Grid item xs={12} className={classes.paperDivider}>
<Divider />
</Grid>
<Divider />
<Grid item xs={12}>
<Table
size="small"
Expand Down
4 changes: 4 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,7 @@ export const SAML_LOGIN_PATH = "/msystems/saml/login/";
export const SAML_LOGOUT_PATH = "/msystems/saml/logout/";

export const RIGHT_VIEW_EU_MODAL = 203000;

export const DEFAULT = {
IS_WORKER: false,
}
11 changes: 7 additions & 4 deletions src/pages/LoginPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useAuthentication } from "../helpers/hooks";
import Contributions from "./../components/generics/Contributions";
import MPassLogo from "./../mPassLogoColor.svg";
import { baseApiUrl } from "../actions";
import { SAML_LOGIN_PATH } from "../constants";
import { DEFAULT, SAML_LOGIN_PATH } from "../constants";

const useStyles = makeStyles((theme) => ({
container: {
Expand Down Expand Up @@ -44,6 +44,7 @@ const LoginPage = ({ logo }) => {
const auth = useAuthentication();
const [isAuthenticating, setAuthenticating] = useState(false);
const showMPassProvider = modulesManager.getConf("fe-core", "LoginPage.showMPassProvider", false);
const isWorker = modulesManager.getConf("fe-insuree", "isWorker", DEFAULT.IS_WORKER);

useEffect(() => {
if (auth.isAuthenticated) {
Expand Down Expand Up @@ -98,9 +99,11 @@ const LoginPage = ({ logo }) => {
<Grid container spacing={2} direction="column" alignItems="stretch">
<Grid item container direction="row" alignItems="center">
<img className={classes.logo} src={logo} />
<Box pl={2} fontWeight="fontWeightMedium" fontSize="h4.fontSize">
{formatMessage("appName")}
</Box>
{!isWorker && (
<Box pl={2} fontWeight="fontWeightMedium" fontSize="h4.fontSize">
{formatMessage("appName")}
</Box>
)}
</Grid>
{showMPassProvider ? (
<>
Expand Down