mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 01:39:44 +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:
parent
f03f2d3f79
commit
3b9e2eb5e5
3
app/_locales/de/messages.json
generated
3
app/_locales/de/messages.json
generated
@ -362,9 +362,6 @@
|
||||
"approveAndInstall": {
|
||||
"message": "Genehmigen und installieren"
|
||||
},
|
||||
"approveAndUpdate": {
|
||||
"message": "Genehmigen & aktualisieren"
|
||||
},
|
||||
"approveButtonText": {
|
||||
"message": "Genehmigen"
|
||||
},
|
||||
|
3
app/_locales/el/messages.json
generated
3
app/_locales/el/messages.json
generated
@ -362,9 +362,6 @@
|
||||
"approveAndInstall": {
|
||||
"message": "Έγκριση και Εγκατάσταση"
|
||||
},
|
||||
"approveAndUpdate": {
|
||||
"message": "Έγκριση και ενημέρωση"
|
||||
},
|
||||
"approveButtonText": {
|
||||
"message": "Έγκριση"
|
||||
},
|
||||
|
11
app/_locales/en/messages.json
generated
11
app/_locales/en/messages.json
generated
@ -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"
|
||||
|
3
app/_locales/es/messages.json
generated
3
app/_locales/es/messages.json
generated
@ -362,9 +362,6 @@
|
||||
"approveAndInstall": {
|
||||
"message": "Aprobar e instalar"
|
||||
},
|
||||
"approveAndUpdate": {
|
||||
"message": "Aprobar y actualizar"
|
||||
},
|
||||
"approveButtonText": {
|
||||
"message": "Aprobar"
|
||||
},
|
||||
|
3
app/_locales/fr/messages.json
generated
3
app/_locales/fr/messages.json
generated
@ -362,9 +362,6 @@
|
||||
"approveAndInstall": {
|
||||
"message": "Approuver et installer"
|
||||
},
|
||||
"approveAndUpdate": {
|
||||
"message": "Approuver et mettre à jour"
|
||||
},
|
||||
"approveButtonText": {
|
||||
"message": "Approuver"
|
||||
},
|
||||
|
3
app/_locales/hi/messages.json
generated
3
app/_locales/hi/messages.json
generated
@ -362,9 +362,6 @@
|
||||
"approveAndInstall": {
|
||||
"message": "स्वीकृत और इंस्टॉल करें"
|
||||
},
|
||||
"approveAndUpdate": {
|
||||
"message": "स्वीकृत और अपडेट करें"
|
||||
},
|
||||
"approveButtonText": {
|
||||
"message": "अनुमोदित करें"
|
||||
},
|
||||
|
3
app/_locales/id/messages.json
generated
3
app/_locales/id/messages.json
generated
@ -362,9 +362,6 @@
|
||||
"approveAndInstall": {
|
||||
"message": "Setujui & instal"
|
||||
},
|
||||
"approveAndUpdate": {
|
||||
"message": "Setujui dan perbarui"
|
||||
},
|
||||
"approveButtonText": {
|
||||
"message": "Setujui"
|
||||
},
|
||||
|
3
app/_locales/it/messages.json
generated
3
app/_locales/it/messages.json
generated
@ -293,9 +293,6 @@
|
||||
"approveAndInstall": {
|
||||
"message": "Approva & installa"
|
||||
},
|
||||
"approveAndUpdate": {
|
||||
"message": "Approva & aggiorna"
|
||||
},
|
||||
"approveButtonText": {
|
||||
"message": "Approva"
|
||||
},
|
||||
|
3
app/_locales/ja/messages.json
generated
3
app/_locales/ja/messages.json
generated
@ -362,9 +362,6 @@
|
||||
"approveAndInstall": {
|
||||
"message": "承認してインストール"
|
||||
},
|
||||
"approveAndUpdate": {
|
||||
"message": "承認して更新"
|
||||
},
|
||||
"approveButtonText": {
|
||||
"message": "承認"
|
||||
},
|
||||
|
3
app/_locales/ko/messages.json
generated
3
app/_locales/ko/messages.json
generated
@ -362,9 +362,6 @@
|
||||
"approveAndInstall": {
|
||||
"message": "승인 및 설치"
|
||||
},
|
||||
"approveAndUpdate": {
|
||||
"message": "승인 및 업데이트"
|
||||
},
|
||||
"approveButtonText": {
|
||||
"message": "승인"
|
||||
},
|
||||
|
3
app/_locales/pt/messages.json
generated
3
app/_locales/pt/messages.json
generated
@ -362,9 +362,6 @@
|
||||
"approveAndInstall": {
|
||||
"message": "Aprovar e instalar"
|
||||
},
|
||||
"approveAndUpdate": {
|
||||
"message": "Aprovar e atualizar"
|
||||
},
|
||||
"approveButtonText": {
|
||||
"message": "Aprovar"
|
||||
},
|
||||
|
3
app/_locales/ru/messages.json
generated
3
app/_locales/ru/messages.json
generated
@ -362,9 +362,6 @@
|
||||
"approveAndInstall": {
|
||||
"message": "Одобрить и установить"
|
||||
},
|
||||
"approveAndUpdate": {
|
||||
"message": "Утвердить и обновить"
|
||||
},
|
||||
"approveButtonText": {
|
||||
"message": "Одобрить"
|
||||
},
|
||||
|
3
app/_locales/tl/messages.json
generated
3
app/_locales/tl/messages.json
generated
@ -362,9 +362,6 @@
|
||||
"approveAndInstall": {
|
||||
"message": "Aprubahan at I-install"
|
||||
},
|
||||
"approveAndUpdate": {
|
||||
"message": "Aprubahan at i-update"
|
||||
},
|
||||
"approveButtonText": {
|
||||
"message": "Aprubahan"
|
||||
},
|
||||
|
3
app/_locales/tr/messages.json
generated
3
app/_locales/tr/messages.json
generated
@ -362,9 +362,6 @@
|
||||
"approveAndInstall": {
|
||||
"message": "Onayla ve Yükle"
|
||||
},
|
||||
"approveAndUpdate": {
|
||||
"message": "Onayla ve güncelle"
|
||||
},
|
||||
"approveButtonText": {
|
||||
"message": "Onayla"
|
||||
},
|
||||
|
3
app/_locales/vi/messages.json
generated
3
app/_locales/vi/messages.json
generated
@ -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"
|
||||
},
|
||||
|
3
app/_locales/zh_CN/messages.json
generated
3
app/_locales/zh_CN/messages.json
generated
@ -362,9 +362,6 @@
|
||||
"approveAndInstall": {
|
||||
"message": "批准并安装"
|
||||
},
|
||||
"approveAndUpdate": {
|
||||
"message": "批准并更新"
|
||||
},
|
||||
"approveButtonText": {
|
||||
"message": "批准"
|
||||
},
|
||||
|
@ -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',
|
||||
});
|
||||
|
||||
|
@ -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>
|
||||
);
|
||||
}
|
||||
|
@ -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 && (
|
||||
|
Loading…
Reference in New Issue
Block a user