2023-04-14 12:04:23 +02:00
|
|
|
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 SnapPermissionsList({
|
2023-07-06 22:54:27 +02:00
|
|
|
snapId,
|
2023-04-14 12:04:23 +02:00
|
|
|
permissions,
|
|
|
|
targetSubjectMetadata,
|
2023-07-06 22:54:27 +02:00
|
|
|
showOptions,
|
2023-04-14 12:04:23 +02:00
|
|
|
}) {
|
|
|
|
const t = useI18nContext();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Box paddingTop={2} paddingBottom={2} className="snap-permissions-list">
|
|
|
|
{getWeightedPermissions(t, permissions, targetSubjectMetadata).map(
|
|
|
|
(permission, index) => {
|
|
|
|
return (
|
|
|
|
<PermissionCell
|
2023-07-06 22:54:27 +02:00
|
|
|
snapId={snapId}
|
|
|
|
permissionName={permission.permissionName}
|
2023-04-14 12:04:23 +02:00
|
|
|
title={permission.label}
|
|
|
|
description={permission.description}
|
|
|
|
weight={permission.weight}
|
|
|
|
avatarIcon={permission.leftIcon}
|
|
|
|
dateApproved={permission?.permissionValue?.date}
|
|
|
|
key={`${permission.permissionName}-${index}`}
|
2023-07-06 22:54:27 +02:00
|
|
|
showOptions={showOptions}
|
2023-04-14 12:04:23 +02:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
)}
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
SnapPermissionsList.propTypes = {
|
2023-07-06 22:54:27 +02:00
|
|
|
snapId: PropTypes.string.isRequired,
|
2023-04-14 12:04:23 +02:00
|
|
|
permissions: PropTypes.object.isRequired,
|
|
|
|
targetSubjectMetadata: PropTypes.object.isRequired,
|
2023-07-06 22:54:27 +02:00
|
|
|
showOptions: PropTypes.bool,
|
2023-04-14 12:04:23 +02:00
|
|
|
};
|