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,
|
2023-04-05 15:34:33 +02:00
|
|
|
targetSubjectMetadata,
|
2022-08-03 18:02:44 +02:00
|
|
|
}) {
|
|
|
|
const t = useI18nContext();
|
|
|
|
|
|
|
|
return (
|
2023-04-03 19:33:54 +02:00
|
|
|
<Box paddingTop={1}>
|
2023-04-05 15:34:33 +02:00
|
|
|
{getWeightedPermissions(t, newPermissions, targetSubjectMetadata).map(
|
2023-06-05 14:31:11 +02:00
|
|
|
(permission, index) => (
|
2023-04-05 15:34:33 +02:00
|
|
|
<PermissionCell
|
|
|
|
title={permission.label}
|
|
|
|
description={permission.description}
|
|
|
|
weight={permission.weight}
|
|
|
|
avatarIcon={permission.leftIcon}
|
|
|
|
dateApproved={permission?.permissionValue?.date}
|
|
|
|
key={`${permission.permissionName}-${index}`}
|
|
|
|
/>
|
2023-06-05 14:31:11 +02:00
|
|
|
),
|
|
|
|
)}
|
2023-04-05 15:34:33 +02:00
|
|
|
{getWeightedPermissions(t, revokedPermissions, targetSubjectMetadata).map(
|
2023-06-05 14:31:11 +02:00
|
|
|
(permission, index) => (
|
|
|
|
<PermissionCell
|
|
|
|
title={permission.label}
|
|
|
|
description={permission.description}
|
|
|
|
weight={permission.weight}
|
|
|
|
avatarIcon={permission.leftIcon}
|
|
|
|
dateApproved={permission?.permissionValue?.date}
|
|
|
|
key={`${permission.permissionName}-${index}`}
|
|
|
|
revoked
|
|
|
|
/>
|
|
|
|
),
|
2023-04-03 19:33:54 +02:00
|
|
|
)}
|
2023-06-05 14:31:11 +02:00
|
|
|
{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}`}
|
|
|
|
/>
|
|
|
|
))}
|
2023-04-03 19:33:54 +02:00
|
|
|
</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,
|
2023-04-05 15:34:33 +02:00
|
|
|
targetSubjectMetadata: PropTypes.object.isRequired,
|
2022-08-03 18:02:44 +02:00
|
|
|
};
|