1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-02 14:15:06 +01:00
metamask-extension/ui/components/app/snaps/update-snap-permission-list/update-snap-permission-list.js
Frederik Bolding 3b9e2eb5e5
[FLASK] Update snap tweaks (#19410)
* Sort revoked permissions before existing permissions

* Simplify update screen logic and update copy

* Remove approve and update copy

* Reduce nesting
2023-06-05 14:31:11 +02:00

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,
targetSubjectMetadata,
}) {
const t = useI18nContext();
return (
<Box paddingTop={1}>
{getWeightedPermissions(t, newPermissions, targetSubjectMetadata).map(
(permission, index) => (
<PermissionCell
title={permission.label}
description={permission.description}
weight={permission.weight}
avatarIcon={permission.leftIcon}
dateApproved={permission?.permissionValue?.date}
key={`${permission.permissionName}-${index}`}
/>
),
)}
{getWeightedPermissions(t, revokedPermissions, targetSubjectMetadata).map(
(permission, index) => (
<PermissionCell
title={permission.label}
description={permission.description}
weight={permission.weight}
avatarIcon={permission.leftIcon}
dateApproved={permission?.permissionValue?.date}
key={`${permission.permissionName}-${index}`}
revoked
/>
),
)}
{getWeightedPermissions(
t,
approvedPermissions,
targetSubjectMetadata,
).map((permission, index) => (
<PermissionCell
title={permission.label}
description={permission.description}
weight={permission.weight}
avatarIcon={permission.leftIcon}
dateApproved={permission?.permissionValue?.date}
key={`${permission.permissionName}-${index}`}
/>
))}
</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,
targetSubjectMetadata: PropTypes.object.isRequired,
};