Skip to content

Commit

Permalink
Fix regression on disabled elements for SecureComponent (#1478)
Browse files Browse the repository at this point in the history
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
  • Loading branch information
Alevsk authored Jan 27, 2022
1 parent 382e315 commit 0286010
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions portal-ui/src/common/SecureComponent/SecureComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,15 @@ const SecureComponent = ({
resource,
}: ISecureComponentProps) => {
const permissionGranted = hasPermission(resource, scopes, matchAll);
const childComponent = <>{children}</>;
if (!permissionGranted && !errorProps) return <RenderError />;
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;

0 comments on commit 0286010

Please sign in to comment.