mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-01 21:57:06 +01:00
a7179a6b88
* added snap-update folder * addded update route, snap update component, updated permissions connect components * added actions and selectors * updated permissions selectors and updated permissions connect container to have update snap logic * updated translations, added selector, updated request object * updated translations, added update snap permission list component * more fixes * added CSS, redid some HTML * lint fixes * Add missing grantPermissions action * updated button padding * fixes * removed prop type * fix Update & Install wrapping * made changes for forthcoming snap controller PR * removed ununsed imports * updated css * re-added padding rule and removed unused translation messages * addressed comments * add subtext for new permissions * lint fix * removed unused translations * some more changes * fix e2e tests * lint fix * added in delay for e2e tests * Revert "added in delay for e2e tests" This reverts commit 095962a2c0c9de0b0b343d3134bb0787044dd8ce. * fixed routing logic Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com> Co-authored-by: Guillaume Roux <guillaumeroux123@gmail.com>
113 lines
3.4 KiB
JavaScript
113 lines
3.4 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { getPermissionDescription } from '../../../../helpers/utils/permission';
|
|
import { useI18nContext } from '../../../../hooks/useI18nContext';
|
|
import { formatDate } from '../../../../helpers/utils/util';
|
|
import Typography from '../../../ui/typography/typography';
|
|
import { COLORS } from '../../../../helpers/constants/design-system';
|
|
|
|
export default function UpdateSnapPermissionList({
|
|
approvedPermissions,
|
|
revokedPermissions,
|
|
newPermissions,
|
|
}) {
|
|
const t = useI18nContext();
|
|
|
|
const ApprovedPermissions = () => {
|
|
return Object.keys(approvedPermissions).map((approvedPermission) => {
|
|
const { label, rightIcon } = getPermissionDescription(
|
|
t,
|
|
approvedPermission,
|
|
);
|
|
const { date } = approvedPermissions[approvedPermission];
|
|
const formattedDate = formatDate(date, 'yyyy-MM-dd');
|
|
return (
|
|
<div className="approved-permission" key={approvedPermission}>
|
|
<i className="fas fa-check" />
|
|
<div className="permission-description">
|
|
{label}
|
|
<Typography
|
|
color={COLORS.TEXT_ALTERNATIVE}
|
|
className="permission-description-subtext"
|
|
boxProps={{ paddingTop: 1 }}
|
|
>
|
|
{t('approvedOn', [formattedDate])}
|
|
</Typography>
|
|
</div>
|
|
{rightIcon && <i className={rightIcon} />}
|
|
</div>
|
|
);
|
|
});
|
|
};
|
|
|
|
const RevokedPermissions = () => {
|
|
return Object.keys(revokedPermissions).map((revokedPermission) => {
|
|
const { label, rightIcon } = getPermissionDescription(
|
|
t,
|
|
revokedPermission,
|
|
);
|
|
return (
|
|
<div className="revoked-permission" key={revokedPermission}>
|
|
<i className="fas fa-x" />
|
|
<div className="permission-description">
|
|
{label}
|
|
<Typography
|
|
color={COLORS.TEXT_ALTERNATIVE}
|
|
boxProps={{ paddingTop: 1 }}
|
|
className="permission-description-subtext"
|
|
>
|
|
{t('permissionRevoked')}
|
|
</Typography>
|
|
</div>
|
|
{rightIcon && <i className={rightIcon} />}
|
|
</div>
|
|
);
|
|
});
|
|
};
|
|
|
|
const NewPermissions = () => {
|
|
return Object.keys(newPermissions).map((newPermission) => {
|
|
const { label, rightIcon } = getPermissionDescription(t, newPermission);
|
|
return (
|
|
<div className="new-permission" key={newPermission}>
|
|
<i className="fas fa-arrow-right" />
|
|
<div className="permission-description">
|
|
{label}
|
|
<Typography
|
|
color={COLORS.TEXT_ALTERNATIVE}
|
|
boxProps={{ paddingTop: 1 }}
|
|
className="permission-description-subtext"
|
|
>
|
|
{t('permissionRequested')}
|
|
</Typography>
|
|
</div>
|
|
{rightIcon && <i className={rightIcon} />}
|
|
</div>
|
|
);
|
|
});
|
|
};
|
|
|
|
return (
|
|
<div className="update-snap-permission-list">
|
|
<NewPermissions />
|
|
<ApprovedPermissions />
|
|
<RevokedPermissions />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
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,
|
|
};
|