1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +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": {
"message": "Genehmigen und installieren"
},
"approveAndUpdate": {
"message": "Genehmigen & aktualisieren"
},
"approveButtonText": {
"message": "Genehmigen"
},

View File

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

View File

@ -401,9 +401,6 @@
"approveAndInstall": {
"message": "Approve & install"
},
"approveAndUpdate": {
"message": "Approve & update"
},
"approveButtonText": {
"message": "Approve"
},
@ -3820,12 +3817,8 @@
"message": "Update snap"
},
"snapUpdateRequest": {
"message": "$1 wants to update $2. Make sure you trust the authors before you proceed.",
"description": "$1 is the dApp origin requesting the snap and $2 is the snap name"
},
"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"
"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, $2 is the snap name and $3 is the snap version."
},
"snaps": {
"message": "Snaps"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -48,19 +48,11 @@ export default function SnapUpdate({
const approvedPermissions = requestState.approvedPermissions ?? {};
const revokedPermissions = requestState.unusedPermissions ?? {};
const newPermissions = requestState.newPermissions ?? {};
const { newVersion } = requestState;
const isLoading = requestState.loading;
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(
newPermissions,
targetSubjectMetadata,
@ -121,7 +113,7 @@ export default function SnapUpdate({
{hasError && (
<InstallError error={requestState.error} title={t('requestFailed')} />
)}
{hasPermissions && (
{!hasError && !isLoading && (
<>
<Text
className="snap-update__content__permission-description"
@ -130,9 +122,10 @@ export default function SnapUpdate({
paddingRight={4}
textAlign={TEXT_ALIGN.CENTER}
>
{t('snapUpdateRequestsPermission', [
{t('snapUpdateRequest', [
<b key="1">{originMetadata?.hostname}</b>,
<b key="2">{snapName}</b>,
<b key="3">v{newVersion}</b>,
])}
</Text>
<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
className="snap-update__footer"
@ -171,10 +149,7 @@ export default function SnapUpdate({
onCancel={onCancel}
cancelText={t('cancel')}
onSubmit={handleSubmit}
submitText={t(
// eslint-disable-next-line no-nested-ternary
hasError ? 'ok' : hasPermissions ? 'approveAndUpdate' : 'update',
)}
submitText={t(hasError ? 'ok' : 'update')}
/>
</Box>
{isShowingWarning && (