From 8f30e036137fd37c2f9a574cf76e27503cbfd447 Mon Sep 17 00:00:00 2001 From: Frederik Bolding Date: Mon, 14 Nov 2022 11:50:17 +0100 Subject: [PATCH] [FLASK] Fix an issue with updating snaps that have caveat permissions (#16473) --- .../update-snap-permission-list.js | 136 ++++++++++-------- 1 file changed, 74 insertions(+), 62 deletions(-) diff --git a/ui/components/app/flask/update-snap-permission-list/update-snap-permission-list.js b/ui/components/app/flask/update-snap-permission-list/update-snap-permission-list.js index 3ecfa91c7..105574d1d 100644 --- a/ui/components/app/flask/update-snap-permission-list/update-snap-permission-list.js +++ b/ui/components/app/flask/update-snap-permission-list/update-snap-permission-list.js @@ -14,77 +14,89 @@ export default function UpdateSnapPermissionList({ 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 ( -
- -
- {label} - - {t('approvedOn', [formattedDate])} - + return Object.entries(approvedPermissions).map( + ([permissionName, permissionValue]) => { + const { label, rightIcon } = getPermissionDescription( + t, + permissionName, + permissionValue, + ); + const { date } = permissionValue; + const formattedDate = formatDate(date, 'yyyy-MM-dd'); + return ( +
+ +
+ {label} + + {t('approvedOn', [formattedDate])} + +
+ {rightIcon && }
- {rightIcon && } -
- ); - }); + ); + }, + ); }; const RevokedPermissions = () => { - return Object.keys(revokedPermissions).map((revokedPermission) => { - const { label, rightIcon } = getPermissionDescription( - t, - revokedPermission, - ); - return ( -
- -
- {label} - - {t('permissionRevoked')} - + return Object.entries(revokedPermissions).map( + ([permissionName, permissionValue]) => { + const { label, rightIcon } = getPermissionDescription( + t, + permissionName, + permissionValue, + ); + return ( +
+ +
+ {label} + + {t('permissionRevoked')} + +
+ {rightIcon && }
- {rightIcon && } -
- ); - }); + ); + }, + ); }; const NewPermissions = () => { - return Object.keys(newPermissions).map((newPermission) => { - const { label, rightIcon } = getPermissionDescription(t, newPermission); - return ( -
- -
- {label} - - {t('permissionRequested')} - + return Object.entries(newPermissions).map( + ([permissionName, permissionValue]) => { + const { label, rightIcon } = getPermissionDescription( + t, + permissionName, + permissionValue, + ); + return ( +
+ +
+ {label} + + {t('permissionRequested')} + +
+ {rightIcon && }
- {rightIcon && } -
- ); - }); + ); + }, + ); }; return (