mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 20:39:08 +01:00
3eefe874a8
* Revert changes made to stable permission display (UI design) * Add test for new component * Update paddings for install flow * Fix missing icons on snap installation flow * Update storybook path * Add targetSubjectMetadata param --------- Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com> Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>
47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import {
|
|
getRightIcon,
|
|
getWeightedPermissions,
|
|
} from '../../../helpers/utils/permission';
|
|
import { useI18nContext } from '../../../hooks/useI18nContext';
|
|
|
|
/**
|
|
* Get one or more permission descriptions for a permission name.
|
|
*
|
|
* @param permission - The permission to render.
|
|
* @param index - The index of the permission.
|
|
* @returns {JSX.Element} A permission description node.
|
|
*/
|
|
function getDescriptionNode(permission, index) {
|
|
const { label, leftIcon, permissionName } = permission;
|
|
|
|
return (
|
|
<div className="permission" key={`${permissionName}-${index}`}>
|
|
{typeof leftIcon === 'string' ? <i className={leftIcon} /> : leftIcon}
|
|
{label}
|
|
{getRightIcon(permission)}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default function PermissionsConnectPermissionList({
|
|
permissions,
|
|
targetSubjectMetadata,
|
|
}) {
|
|
const t = useI18nContext();
|
|
|
|
return (
|
|
<div className="permissions-connect-permission-list">
|
|
{getWeightedPermissions(t, permissions, targetSubjectMetadata).map(
|
|
getDescriptionNode,
|
|
)}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
PermissionsConnectPermissionList.propTypes = {
|
|
permissions: PropTypes.object.isRequired,
|
|
targetSubjectMetadata: PropTypes.object.isRequired,
|
|
};
|