1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/ui/components/app/permissions-connect-permission-list/permissions-connect-permission-list.js
Maarten Zuidhoorn c59e2b4d44
[FLASK] Add tooltips to show info about a permission (#17685)
* Add tooltips to show info about a permission

* Make Tooltip component in scope regardless of build type

* Add descriptions

* Add translation variables and fix tooltip

* Use new icons

* Add missing description after rebase

* Fix build issues

* Fix icons

* Fix translation

* Add missing description

* Fix Ethereum icon

* Update coverage
2023-03-20 12:32:03 +01:00

41 lines
1.1 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 }) {
const t = useI18nContext();
return (
<div className="permissions-connect-permission-list">
{getWeightedPermissions(t, permissions).map(getDescriptionNode)}
</div>
);
}
PermissionsConnectPermissionList.propTypes = {
permissions: PropTypes.object.isRequired,
};