1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00

[FLASK] Update snap tweaks (#19410)

* Sort revoked permissions before existing permissions

* Simplify update screen logic and update copy

* Remove approve and update copy

* Reduce nesting
This commit is contained in:
Frederik Bolding 2023-06-05 14:31:11 +02:00 committed by GitHub
parent f03f2d3f79
commit 3b9e2eb5e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 38 additions and 121 deletions

View File

@ -362,9 +362,6 @@
"approveAndInstall": { "approveAndInstall": {
"message": "Genehmigen und installieren" "message": "Genehmigen und installieren"
}, },
"approveAndUpdate": {
"message": "Genehmigen & aktualisieren"
},
"approveButtonText": { "approveButtonText": {
"message": "Genehmigen" "message": "Genehmigen"
}, },

View File

@ -362,9 +362,6 @@
"approveAndInstall": { "approveAndInstall": {
"message": "Έγκριση και Εγκατάσταση" "message": "Έγκριση και Εγκατάσταση"
}, },
"approveAndUpdate": {
"message": "Έγκριση και ενημέρωση"
},
"approveButtonText": { "approveButtonText": {
"message": "Έγκριση" "message": "Έγκριση"
}, },

View File

@ -401,9 +401,6 @@
"approveAndInstall": { "approveAndInstall": {
"message": "Approve & install" "message": "Approve & install"
}, },
"approveAndUpdate": {
"message": "Approve & update"
},
"approveButtonText": { "approveButtonText": {
"message": "Approve" "message": "Approve"
}, },
@ -3820,12 +3817,8 @@
"message": "Update snap" "message": "Update snap"
}, },
"snapUpdateRequest": { "snapUpdateRequest": {
"message": "$1 wants to update $2. Make sure you trust the authors before you proceed.", "message": "$1 wants to update $2 to $3 which gives it the following permissions. Only continue if you trust $2.",
"description": "$1 is the dApp origin requesting the snap and $2 is the snap name" "description": "$1 is the dApp origin requesting the snap, $2 is the snap name and $3 is the snap version."
},
"snapUpdateRequestsPermission": {
"message": "$1 wants to update $2, which is requesting the following permissions. Make sure you trust the authors before you proceed.",
"description": "$1 is the dApp origin requesting the snap and $2 is the snap name"
}, },
"snaps": { "snaps": {
"message": "Snaps" "message": "Snaps"

View File

@ -362,9 +362,6 @@
"approveAndInstall": { "approveAndInstall": {
"message": "Aprobar e instalar" "message": "Aprobar e instalar"
}, },
"approveAndUpdate": {
"message": "Aprobar y actualizar"
},
"approveButtonText": { "approveButtonText": {
"message": "Aprobar" "message": "Aprobar"
}, },

View File

@ -362,9 +362,6 @@
"approveAndInstall": { "approveAndInstall": {
"message": "Approuver et installer" "message": "Approuver et installer"
}, },
"approveAndUpdate": {
"message": "Approuver et mettre à jour"
},
"approveButtonText": { "approveButtonText": {
"message": "Approuver" "message": "Approuver"
}, },

View File

@ -362,9 +362,6 @@
"approveAndInstall": { "approveAndInstall": {
"message": "स्वीकृत और इंस्टॉल करें" "message": "स्वीकृत और इंस्टॉल करें"
}, },
"approveAndUpdate": {
"message": "स्वीकृत और अपडेट करें"
},
"approveButtonText": { "approveButtonText": {
"message": "अनुमोदित करें" "message": "अनुमोदित करें"
}, },

View File

@ -362,9 +362,6 @@
"approveAndInstall": { "approveAndInstall": {
"message": "Setujui & instal" "message": "Setujui & instal"
}, },
"approveAndUpdate": {
"message": "Setujui dan perbarui"
},
"approveButtonText": { "approveButtonText": {
"message": "Setujui" "message": "Setujui"
}, },

View File

@ -293,9 +293,6 @@
"approveAndInstall": { "approveAndInstall": {
"message": "Approva & installa" "message": "Approva & installa"
}, },
"approveAndUpdate": {
"message": "Approva & aggiorna"
},
"approveButtonText": { "approveButtonText": {
"message": "Approva" "message": "Approva"
}, },

View File

@ -362,9 +362,6 @@
"approveAndInstall": { "approveAndInstall": {
"message": "承認してインストール" "message": "承認してインストール"
}, },
"approveAndUpdate": {
"message": "承認して更新"
},
"approveButtonText": { "approveButtonText": {
"message": "承認" "message": "承認"
}, },

View File

@ -362,9 +362,6 @@
"approveAndInstall": { "approveAndInstall": {
"message": "승인 및 설치" "message": "승인 및 설치"
}, },
"approveAndUpdate": {
"message": "승인 및 업데이트"
},
"approveButtonText": { "approveButtonText": {
"message": "승인" "message": "승인"
}, },

View File

@ -362,9 +362,6 @@
"approveAndInstall": { "approveAndInstall": {
"message": "Aprovar e instalar" "message": "Aprovar e instalar"
}, },
"approveAndUpdate": {
"message": "Aprovar e atualizar"
},
"approveButtonText": { "approveButtonText": {
"message": "Aprovar" "message": "Aprovar"
}, },

View File

@ -362,9 +362,6 @@
"approveAndInstall": { "approveAndInstall": {
"message": "Одобрить и установить" "message": "Одобрить и установить"
}, },
"approveAndUpdate": {
"message": "Утвердить и обновить"
},
"approveButtonText": { "approveButtonText": {
"message": "Одобрить" "message": "Одобрить"
}, },

View File

@ -362,9 +362,6 @@
"approveAndInstall": { "approveAndInstall": {
"message": "Aprubahan at I-install" "message": "Aprubahan at I-install"
}, },
"approveAndUpdate": {
"message": "Aprubahan at i-update"
},
"approveButtonText": { "approveButtonText": {
"message": "Aprubahan" "message": "Aprubahan"
}, },

View File

@ -362,9 +362,6 @@
"approveAndInstall": { "approveAndInstall": {
"message": "Onayla ve Yükle" "message": "Onayla ve Yükle"
}, },
"approveAndUpdate": {
"message": "Onayla ve güncelle"
},
"approveButtonText": { "approveButtonText": {
"message": "Onayla" "message": "Onayla"
}, },

View File

@ -362,9 +362,6 @@
"approveAndInstall": { "approveAndInstall": {
"message": "Chấp nhận và cài đặt" "message": "Chấp nhận và cài đặt"
}, },
"approveAndUpdate": {
"message": "Phê duyệt và cập nhật"
},
"approveButtonText": { "approveButtonText": {
"message": "Phê duyệt" "message": "Phê duyệt"
}, },

View File

@ -362,9 +362,6 @@
"approveAndInstall": { "approveAndInstall": {
"message": "批准并安装" "message": "批准并安装"
}, },
"approveAndUpdate": {
"message": "批准并更新"
},
"approveButtonText": { "approveButtonText": {
"message": "批准" "message": "批准"
}, },

View File

@ -103,10 +103,10 @@ describe('Test Snap update', function () {
windowHandles, windowHandles,
); );
await driver.waitForSelector({ text: 'Approve & update' }); await driver.waitForSelector({ text: 'Update' });
await driver.clickElement({ await driver.clickElement({
text: 'Approve & update', text: 'Update',
tag: 'button', tag: 'button',
}); });

View File

@ -16,8 +16,7 @@ export default function UpdateSnapPermissionList({
return ( return (
<Box paddingTop={1}> <Box paddingTop={1}>
{getWeightedPermissions(t, newPermissions, targetSubjectMetadata).map( {getWeightedPermissions(t, newPermissions, targetSubjectMetadata).map(
(permission, index) => { (permission, index) => (
return (
<PermissionCell <PermissionCell
title={permission.label} title={permission.label}
description={permission.description} description={permission.description}
@ -26,28 +25,10 @@ export default function UpdateSnapPermissionList({
dateApproved={permission?.permissionValue?.date} dateApproved={permission?.permissionValue?.date}
key={`${permission.permissionName}-${index}`} key={`${permission.permissionName}-${index}`}
/> />
); ),
},
)} )}
{getWeightedPermissions(
t,
approvedPermissions,
targetSubjectMetadata,
).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, targetSubjectMetadata).map( {getWeightedPermissions(t, revokedPermissions, targetSubjectMetadata).map(
(permission, index) => { (permission, index) => (
return (
<PermissionCell <PermissionCell
title={permission.label} title={permission.label}
description={permission.description} description={permission.description}
@ -57,9 +38,22 @@ export default function UpdateSnapPermissionList({
key={`${permission.permissionName}-${index}`} key={`${permission.permissionName}-${index}`}
revoked revoked
/> />
); ),
},
)} )}
{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}`}
/>
))}
</Box> </Box>
); );
} }

View File

@ -48,19 +48,11 @@ export default function SnapUpdate({
const approvedPermissions = requestState.approvedPermissions ?? {}; const approvedPermissions = requestState.approvedPermissions ?? {};
const revokedPermissions = requestState.unusedPermissions ?? {}; const revokedPermissions = requestState.unusedPermissions ?? {};
const newPermissions = requestState.newPermissions ?? {}; const newPermissions = requestState.newPermissions ?? {};
const { newVersion } = requestState;
const isLoading = requestState.loading; const isLoading = requestState.loading;
const hasError = !isLoading && requestState.error; const hasError = !isLoading && requestState.error;
const hasPermissions =
!hasError &&
Object.keys(approvedPermissions).length +
Object.keys(revokedPermissions).length +
Object.keys(newPermissions).length >
0;
const isEmpty = !isLoading && !hasError && !hasPermissions;
const warnings = getSnapInstallWarnings( const warnings = getSnapInstallWarnings(
newPermissions, newPermissions,
targetSubjectMetadata, targetSubjectMetadata,
@ -121,7 +113,7 @@ export default function SnapUpdate({
{hasError && ( {hasError && (
<InstallError error={requestState.error} title={t('requestFailed')} /> <InstallError error={requestState.error} title={t('requestFailed')} />
)} )}
{hasPermissions && ( {!hasError && !isLoading && (
<> <>
<Text <Text
className="snap-update__content__permission-description" className="snap-update__content__permission-description"
@ -130,9 +122,10 @@ export default function SnapUpdate({
paddingRight={4} paddingRight={4}
textAlign={TEXT_ALIGN.CENTER} textAlign={TEXT_ALIGN.CENTER}
> >
{t('snapUpdateRequestsPermission', [ {t('snapUpdateRequest', [
<b key="1">{originMetadata?.hostname}</b>, <b key="1">{originMetadata?.hostname}</b>,
<b key="2">{snapName}</b>, <b key="2">{snapName}</b>,
<b key="3">v{newVersion}</b>,
])} ])}
</Text> </Text>
<UpdateSnapPermissionList <UpdateSnapPermissionList
@ -143,21 +136,6 @@ export default function SnapUpdate({
/> />
</> </>
)} )}
{isEmpty && (
<Box
flexDirection={FLEX_DIRECTION.COLUMN}
height={BLOCK_SIZES.FULL}
alignItems={AlignItems.center}
justifyContent={JustifyContent.center}
>
<Text textAlign={TEXT_ALIGN.CENTER}>
{t('snapUpdateRequest', [
<b key="1">{originMetadata?.hostname}</b>,
<b key="2">{snapName}</b>,
])}
</Text>
</Box>
)}
</Box> </Box>
<Box <Box
className="snap-update__footer" className="snap-update__footer"
@ -171,10 +149,7 @@ export default function SnapUpdate({
onCancel={onCancel} onCancel={onCancel}
cancelText={t('cancel')} cancelText={t('cancel')}
onSubmit={handleSubmit} onSubmit={handleSubmit}
submitText={t( submitText={t(hasError ? 'ok' : 'update')}
// eslint-disable-next-line no-nested-ternary
hasError ? 'ok' : hasPermissions ? 'approveAndUpdate' : 'update',
)}
/> />
</Box> </Box>
{isShowingWarning && ( {isShowingWarning && (