Fix regression on disabled elements for SecureComponent (#1478)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
This commit is contained in:
@@ -58,12 +58,15 @@ const SecureComponent = ({
|
|||||||
resource,
|
resource,
|
||||||
}: ISecureComponentProps) => {
|
}: ISecureComponentProps) => {
|
||||||
const permissionGranted = hasPermission(resource, scopes, matchAll);
|
const permissionGranted = hasPermission(resource, scopes, matchAll);
|
||||||
const childComponent = <>{children}</>;
|
|
||||||
if (!permissionGranted && !errorProps) return <RenderError />;
|
if (!permissionGranted && !errorProps) return <RenderError />;
|
||||||
if (!permissionGranted && errorProps) {
|
if (!permissionGranted && errorProps) {
|
||||||
return cloneElement(childComponent, { ...errorProps });
|
return Array.isArray(children) ? (
|
||||||
|
<>{children.map((child) => cloneElement(child, { ...errorProps }))}</>
|
||||||
|
) : (
|
||||||
|
cloneElement(children, { ...errorProps })
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return childComponent;
|
return <>{children}</>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SecureComponent;
|
export default SecureComponent;
|
||||||
|
|||||||
Reference in New Issue
Block a user