2022-08-03 18:02:44 +02:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2023-04-03 19:33:54 +02:00
|
|
|
import { getWeightedPermissions } from '../../../../helpers/utils/permission';
|
2022-08-03 18:02:44 +02:00
|
|
|
import { useI18nContext } from '../../../../hooks/useI18nContext';
|
2023-04-03 19:33:54 +02:00
|
|
|
import PermissionCell from '../../permission-cell';
|
|
|
|
import Box from '../../../ui/box';
|
2022-08-03 18:02:44 +02:00
|
|
|
|
|
|
|
export default function UpdateSnapPermissionList({
|
|
|
|
approvedPermissions,
|
|
|
|
revokedPermissions,
|
|
|
|
newPermissions,
|
|
|
|
}) {
|
|
|
|
const t = useI18nContext();
|
|
|
|
|
|
|
|
return (
|
2023-04-03 19:33:54 +02:00
|
|
|
<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>
|
2022-08-03 18:02:44 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
};
|