mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-02 22:24:27 +01:00
8603a4b067
* Add permission cell component Add storybook and handling for revoked permission colors * Fix things after conflict resolve after rebase * Add code refactoring and minor UI changes * Add permission cell component to snap-update flow * Update storybook * Add unit tests for permission cell * Update component padding * Fix spacing between permission cells * Fix main icon color for approved permissions * Update width value with constant
76 lines
2.3 KiB
JavaScript
76 lines
2.3 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { getWeightedPermissions } from '../../../../helpers/utils/permission';
|
|
import { useI18nContext } from '../../../../hooks/useI18nContext';
|
|
import PermissionCell from '../../permission-cell';
|
|
import Box from '../../../ui/box';
|
|
|
|
export default function UpdateSnapPermissionList({
|
|
approvedPermissions,
|
|
revokedPermissions,
|
|
newPermissions,
|
|
}) {
|
|
const t = useI18nContext();
|
|
|
|
return (
|
|
<Box paddingTop={1}>
|
|
{getWeightedPermissions(t, newPermissions).map((permission, index) => {
|
|
return (
|
|
<PermissionCell
|
|
title={permission.label}
|
|
description={permission.description}
|
|
weight={permission.weight}
|
|
avatarIcon={permission.leftIcon}
|
|
dateApproved={permission?.permissionValue?.date}
|
|
key={`${permission.permissionName}-${index}`}
|
|
/>
|
|
);
|
|
})}
|
|
{getWeightedPermissions(t, approvedPermissions).map(
|
|
(permission, index) => {
|
|
return (
|
|
<PermissionCell
|
|
title={permission.label}
|
|
description={permission.description}
|
|
weight={permission.weight}
|
|
avatarIcon={permission.leftIcon}
|
|
dateApproved={permission?.permissionValue?.date}
|
|
key={`${permission.permissionName}-${index}`}
|
|
/>
|
|
);
|
|
},
|
|
)}
|
|
{getWeightedPermissions(t, revokedPermissions).map(
|
|
(permission, index) => {
|
|
return (
|
|
<PermissionCell
|
|
title={permission.label}
|
|
description={permission.description}
|
|
weight={permission.weight}
|
|
avatarIcon={permission.leftIcon}
|
|
dateApproved={permission?.permissionValue?.date}
|
|
key={`${permission.permissionName}-${index}`}
|
|
revoked
|
|
/>
|
|
);
|
|
},
|
|
)}
|
|
</Box>
|
|
);
|
|
}
|
|
|
|
UpdateSnapPermissionList.propTypes = {
|
|
/**
|
|
* Permissions that have already been approved
|
|
*/
|
|
approvedPermissions: PropTypes.object.isRequired,
|
|
/**
|
|
* Previously used permissions that are now revoked
|
|
*/
|
|
revokedPermissions: PropTypes.object.isRequired,
|
|
/**
|
|
* New permissions that are being requested
|
|
*/
|
|
newPermissions: PropTypes.object.isRequired,
|
|
};
|