mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +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": {
|
"approveAndInstall": {
|
||||||
"message": "Genehmigen und installieren"
|
"message": "Genehmigen und installieren"
|
||||||
},
|
},
|
||||||
"approveAndUpdate": {
|
|
||||||
"message": "Genehmigen & aktualisieren"
|
|
||||||
},
|
|
||||||
"approveButtonText": {
|
"approveButtonText": {
|
||||||
"message": "Genehmigen"
|
"message": "Genehmigen"
|
||||||
},
|
},
|
||||||
|
3
app/_locales/el/messages.json
generated
3
app/_locales/el/messages.json
generated
@ -362,9 +362,6 @@
|
|||||||
"approveAndInstall": {
|
"approveAndInstall": {
|
||||||
"message": "Έγκριση και Εγκατάσταση"
|
"message": "Έγκριση και Εγκατάσταση"
|
||||||
},
|
},
|
||||||
"approveAndUpdate": {
|
|
||||||
"message": "Έγκριση και ενημέρωση"
|
|
||||||
},
|
|
||||||
"approveButtonText": {
|
"approveButtonText": {
|
||||||
"message": "Έγκριση"
|
"message": "Έγκριση"
|
||||||
},
|
},
|
||||||
|
11
app/_locales/en/messages.json
generated
11
app/_locales/en/messages.json
generated
@ -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"
|
||||||
|
3
app/_locales/es/messages.json
generated
3
app/_locales/es/messages.json
generated
@ -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"
|
||||||
},
|
},
|
||||||
|
3
app/_locales/fr/messages.json
generated
3
app/_locales/fr/messages.json
generated
@ -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"
|
||||||
},
|
},
|
||||||
|
3
app/_locales/hi/messages.json
generated
3
app/_locales/hi/messages.json
generated
@ -362,9 +362,6 @@
|
|||||||
"approveAndInstall": {
|
"approveAndInstall": {
|
||||||
"message": "स्वीकृत और इंस्टॉल करें"
|
"message": "स्वीकृत और इंस्टॉल करें"
|
||||||
},
|
},
|
||||||
"approveAndUpdate": {
|
|
||||||
"message": "स्वीकृत और अपडेट करें"
|
|
||||||
},
|
|
||||||
"approveButtonText": {
|
"approveButtonText": {
|
||||||
"message": "अनुमोदित करें"
|
"message": "अनुमोदित करें"
|
||||||
},
|
},
|
||||||
|
3
app/_locales/id/messages.json
generated
3
app/_locales/id/messages.json
generated
@ -362,9 +362,6 @@
|
|||||||
"approveAndInstall": {
|
"approveAndInstall": {
|
||||||
"message": "Setujui & instal"
|
"message": "Setujui & instal"
|
||||||
},
|
},
|
||||||
"approveAndUpdate": {
|
|
||||||
"message": "Setujui dan perbarui"
|
|
||||||
},
|
|
||||||
"approveButtonText": {
|
"approveButtonText": {
|
||||||
"message": "Setujui"
|
"message": "Setujui"
|
||||||
},
|
},
|
||||||
|
3
app/_locales/it/messages.json
generated
3
app/_locales/it/messages.json
generated
@ -293,9 +293,6 @@
|
|||||||
"approveAndInstall": {
|
"approveAndInstall": {
|
||||||
"message": "Approva & installa"
|
"message": "Approva & installa"
|
||||||
},
|
},
|
||||||
"approveAndUpdate": {
|
|
||||||
"message": "Approva & aggiorna"
|
|
||||||
},
|
|
||||||
"approveButtonText": {
|
"approveButtonText": {
|
||||||
"message": "Approva"
|
"message": "Approva"
|
||||||
},
|
},
|
||||||
|
3
app/_locales/ja/messages.json
generated
3
app/_locales/ja/messages.json
generated
@ -362,9 +362,6 @@
|
|||||||
"approveAndInstall": {
|
"approveAndInstall": {
|
||||||
"message": "承認してインストール"
|
"message": "承認してインストール"
|
||||||
},
|
},
|
||||||
"approveAndUpdate": {
|
|
||||||
"message": "承認して更新"
|
|
||||||
},
|
|
||||||
"approveButtonText": {
|
"approveButtonText": {
|
||||||
"message": "承認"
|
"message": "承認"
|
||||||
},
|
},
|
||||||
|
3
app/_locales/ko/messages.json
generated
3
app/_locales/ko/messages.json
generated
@ -362,9 +362,6 @@
|
|||||||
"approveAndInstall": {
|
"approveAndInstall": {
|
||||||
"message": "승인 및 설치"
|
"message": "승인 및 설치"
|
||||||
},
|
},
|
||||||
"approveAndUpdate": {
|
|
||||||
"message": "승인 및 업데이트"
|
|
||||||
},
|
|
||||||
"approveButtonText": {
|
"approveButtonText": {
|
||||||
"message": "승인"
|
"message": "승인"
|
||||||
},
|
},
|
||||||
|
3
app/_locales/pt/messages.json
generated
3
app/_locales/pt/messages.json
generated
@ -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"
|
||||||
},
|
},
|
||||||
|
3
app/_locales/ru/messages.json
generated
3
app/_locales/ru/messages.json
generated
@ -362,9 +362,6 @@
|
|||||||
"approveAndInstall": {
|
"approveAndInstall": {
|
||||||
"message": "Одобрить и установить"
|
"message": "Одобрить и установить"
|
||||||
},
|
},
|
||||||
"approveAndUpdate": {
|
|
||||||
"message": "Утвердить и обновить"
|
|
||||||
},
|
|
||||||
"approveButtonText": {
|
"approveButtonText": {
|
||||||
"message": "Одобрить"
|
"message": "Одобрить"
|
||||||
},
|
},
|
||||||
|
3
app/_locales/tl/messages.json
generated
3
app/_locales/tl/messages.json
generated
@ -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"
|
||||||
},
|
},
|
||||||
|
3
app/_locales/tr/messages.json
generated
3
app/_locales/tr/messages.json
generated
@ -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"
|
||||||
},
|
},
|
||||||
|
3
app/_locales/vi/messages.json
generated
3
app/_locales/vi/messages.json
generated
@ -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"
|
||||||
},
|
},
|
||||||
|
3
app/_locales/zh_CN/messages.json
generated
3
app/_locales/zh_CN/messages.json
generated
@ -362,9 +362,6 @@
|
|||||||
"approveAndInstall": {
|
"approveAndInstall": {
|
||||||
"message": "批准并安装"
|
"message": "批准并安装"
|
||||||
},
|
},
|
||||||
"approveAndUpdate": {
|
|
||||||
"message": "批准并更新"
|
|
||||||
},
|
|
||||||
"approveButtonText": {
|
"approveButtonText": {
|
||||||
"message": "批准"
|
"message": "批准"
|
||||||
},
|
},
|
||||||
|
@ -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',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -16,25 +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
|
|
||||||
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 (
|
|
||||||
<PermissionCell
|
<PermissionCell
|
||||||
title={permission.label}
|
title={permission.label}
|
||||||
description={permission.description}
|
description={permission.description}
|
||||||
@ -43,23 +25,35 @@ export default function UpdateSnapPermissionList({
|
|||||||
dateApproved={permission?.permissionValue?.date}
|
dateApproved={permission?.permissionValue?.date}
|
||||||
key={`${permission.permissionName}-${index}`}
|
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>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -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 && (
|
||||||
|
Loading…
Reference in New Issue
Block a user