- the great reformat

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-02-06 18:20:58 -05:00
parent 30c530bcc4
commit e83badb454
912 changed files with 108516 additions and 107493 deletions

View File

@@ -1,66 +1,63 @@
import React from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import {
selectAuthLevel,
selectBodyshop,
} from "../../redux/user/user.selectors";
import {useTranslation} from "react-i18next";
import {connect} from "react-redux";
import {createStructuredSelector} from "reselect";
import {selectAuthLevel, selectBodyshop,} from "../../redux/user/user.selectors";
import AlertComponent from "../alert/alert.component";
import rbacDefaults from "./rbac-defaults";
const mapStateToProps = createStructuredSelector({
authLevel: selectAuthLevel,
bodyshop: selectBodyshop,
authLevel: selectAuthLevel,
bodyshop: selectBodyshop,
});
function RbacWrapper({
authLevel,
bodyshop,
requiredAuthLevel,
noauth,
children,
action,
dispatch,
...restProps
}) {
const { t } = useTranslation();
authLevel,
bodyshop,
requiredAuthLevel,
noauth,
children,
action,
dispatch,
...restProps
}) {
const {t} = useTranslation();
if (
(requiredAuthLevel && requiredAuthLevel <= authLevel) ||
((bodyshop.md_rbac && bodyshop.md_rbac[action]) || rbacDefaults[action]) <=
authLevel ||
(bodyshop.md_rbac &&
!bodyshop.md_rbac[action] &&
rbacDefaults[action] <= authLevel)
)
return children;
//return <div>{React.cloneElement(children, restProps)}</div>;
return (
noauth || (
<AlertComponent
message={t("general.messages.rbacunauth")}
type="warning"
/>
if (
(requiredAuthLevel && requiredAuthLevel <= authLevel) ||
((bodyshop.md_rbac && bodyshop.md_rbac[action]) || rbacDefaults[action]) <=
authLevel ||
(bodyshop.md_rbac &&
!bodyshop.md_rbac[action] &&
rbacDefaults[action] <= authLevel)
)
);
return children;
//return <div>{React.cloneElement(children, restProps)}</div>;
return (
noauth || (
<AlertComponent
message={t("general.messages.rbacunauth")}
type="warning"
/>
)
);
}
export function HasRbacAccess({
authLevel,
bodyshop,
requiredAuthLevel,
action,
}) {
return (
(requiredAuthLevel && requiredAuthLevel <= authLevel) ||
((bodyshop.md_rbac && bodyshop.md_rbac[action]) || rbacDefaults[action]) <=
authLevel ||
(bodyshop.md_rbac &&
!bodyshop.md_rbac[action] &&
rbacDefaults[action] <= authLevel)
);
authLevel,
bodyshop,
requiredAuthLevel,
action,
}) {
return (
(requiredAuthLevel && requiredAuthLevel <= authLevel) ||
((bodyshop.md_rbac && bodyshop.md_rbac[action]) || rbacDefaults[action]) <=
authLevel ||
(bodyshop.md_rbac &&
!bodyshop.md_rbac[action] &&
rbacDefaults[action] <= authLevel)
);
}
export default connect(mapStateToProps, null)(RbacWrapper);