mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
[FLASK] Update permissions to use IconName and IconSize design system enum (#18786)
* Update permissions to use IconName and IconSize design system enum approach * Update webassembly to use IconName enum
This commit is contained in:
parent
16dabdf802
commit
41cf85e201
@ -20,11 +20,9 @@ import {
|
|||||||
Text,
|
Text,
|
||||||
Icon,
|
Icon,
|
||||||
///: END:ONLY_INCLUDE_IN
|
///: END:ONLY_INCLUDE_IN
|
||||||
|
IconName,
|
||||||
|
IconSize,
|
||||||
} from '../../components/component-library';
|
} from '../../components/component-library';
|
||||||
import {
|
|
||||||
ICON_NAMES,
|
|
||||||
ICON_SIZES,
|
|
||||||
} from '../../components/component-library/icon/deprecated';
|
|
||||||
///: BEGIN:ONLY_INCLUDE_IN(flask)
|
///: BEGIN:ONLY_INCLUDE_IN(flask)
|
||||||
import {
|
import {
|
||||||
Color,
|
Color,
|
||||||
@ -43,11 +41,7 @@ const UNKNOWN_PERMISSION = Symbol('unknown');
|
|||||||
|
|
||||||
///: BEGIN:ONLY_INCLUDE_IN(flask)
|
///: BEGIN:ONLY_INCLUDE_IN(flask)
|
||||||
const RIGHT_INFO_ICON = (
|
const RIGHT_INFO_ICON = (
|
||||||
<Icon
|
<Icon name={IconName.Info} size={IconSize.Sm} color={IconColor.iconMuted} />
|
||||||
name={ICON_NAMES.INFO}
|
|
||||||
size={ICON_SIZES.SM}
|
|
||||||
color={IconColor.iconMuted}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
///: END:ONLY_INCLUDE_IN
|
///: END:ONLY_INCLUDE_IN
|
||||||
|
|
||||||
@ -55,9 +49,9 @@ function getLeftIcon(iconName) {
|
|||||||
return (
|
return (
|
||||||
<AvatarIcon
|
<AvatarIcon
|
||||||
iconName={iconName}
|
iconName={iconName}
|
||||||
size={ICON_SIZES.SM}
|
size={IconSize.Sm}
|
||||||
iconProps={{
|
iconProps={{
|
||||||
size: ICON_SIZES.XS,
|
size: IconSize.Xs,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@ -66,7 +60,7 @@ function getLeftIcon(iconName) {
|
|||||||
export const PERMISSION_DESCRIPTIONS = deepFreeze({
|
export const PERMISSION_DESCRIPTIONS = deepFreeze({
|
||||||
[RestrictedMethods.eth_accounts]: ({ t }) => ({
|
[RestrictedMethods.eth_accounts]: ({ t }) => ({
|
||||||
label: t('permission_ethereumAccounts'),
|
label: t('permission_ethereumAccounts'),
|
||||||
leftIcon: getLeftIcon(ICON_NAMES.EYE),
|
leftIcon: getLeftIcon(IconName.Eye),
|
||||||
rightIcon: null,
|
rightIcon: null,
|
||||||
weight: 2,
|
weight: 2,
|
||||||
}),
|
}),
|
||||||
@ -74,13 +68,13 @@ export const PERMISSION_DESCRIPTIONS = deepFreeze({
|
|||||||
[RestrictedMethods.snap_dialog]: ({ t }) => ({
|
[RestrictedMethods.snap_dialog]: ({ t }) => ({
|
||||||
label: t('permission_dialog'),
|
label: t('permission_dialog'),
|
||||||
description: t('permission_dialogDescription'),
|
description: t('permission_dialogDescription'),
|
||||||
leftIcon: ICON_NAMES.MESSAGES,
|
leftIcon: IconName.Messages,
|
||||||
weight: 3,
|
weight: 3,
|
||||||
}),
|
}),
|
||||||
[RestrictedMethods.snap_notify]: ({ t }) => ({
|
[RestrictedMethods.snap_notify]: ({ t }) => ({
|
||||||
label: t('permission_notifications'),
|
label: t('permission_notifications'),
|
||||||
description: t('permission_notificationsDescription'),
|
description: t('permission_notificationsDescription'),
|
||||||
leftIcon: ICON_NAMES.NOTIFICATION,
|
leftIcon: IconName.Notification,
|
||||||
weight: 3,
|
weight: 3,
|
||||||
}),
|
}),
|
||||||
[RestrictedMethods.snap_getBip32PublicKey]: ({
|
[RestrictedMethods.snap_getBip32PublicKey]: ({
|
||||||
@ -90,7 +84,7 @@ export const PERMISSION_DESCRIPTIONS = deepFreeze({
|
|||||||
}) =>
|
}) =>
|
||||||
permissionValue.caveats[0].value.map(({ path, curve }, i) => {
|
permissionValue.caveats[0].value.map(({ path, curve }, i) => {
|
||||||
const baseDescription = {
|
const baseDescription = {
|
||||||
leftIcon: ICON_NAMES.SECURITY_SEARCH,
|
leftIcon: IconName.SecuritySearch,
|
||||||
weight: 1,
|
weight: 1,
|
||||||
id: `public-key-access-bip32-${path
|
id: `public-key-access-bip32-${path
|
||||||
.join('-')
|
.join('-')
|
||||||
@ -160,7 +154,7 @@ export const PERMISSION_DESCRIPTIONS = deepFreeze({
|
|||||||
}) =>
|
}) =>
|
||||||
permissionValue.caveats[0].value.map(({ path, curve }, i) => {
|
permissionValue.caveats[0].value.map(({ path, curve }, i) => {
|
||||||
const baseDescription = {
|
const baseDescription = {
|
||||||
leftIcon: ICON_NAMES.KEY,
|
leftIcon: IconName.Key,
|
||||||
weight: 1,
|
weight: 1,
|
||||||
id: `key-access-bip32-${path
|
id: `key-access-bip32-${path
|
||||||
.join('-')
|
.join('-')
|
||||||
@ -244,7 +238,7 @@ export const PERMISSION_DESCRIPTIONS = deepFreeze({
|
|||||||
t('unrecognizedProtocol', [coinType])}
|
t('unrecognizedProtocol', [coinType])}
|
||||||
</span>,
|
</span>,
|
||||||
]),
|
]),
|
||||||
leftIcon: ICON_NAMES.KEY,
|
leftIcon: IconName.Key,
|
||||||
weight: 1,
|
weight: 1,
|
||||||
id: `key-access-bip44-${coinType}-${i}`,
|
id: `key-access-bip44-${coinType}-${i}`,
|
||||||
message: t('snapInstallWarningKeyAccess', [
|
message: t('snapInstallWarningKeyAccess', [
|
||||||
@ -266,19 +260,19 @@ export const PERMISSION_DESCRIPTIONS = deepFreeze({
|
|||||||
[RestrictedMethods.snap_getEntropy]: ({ t }) => ({
|
[RestrictedMethods.snap_getEntropy]: ({ t }) => ({
|
||||||
label: t('permission_getEntropy'),
|
label: t('permission_getEntropy'),
|
||||||
description: t('permission_getEntropyDescription'),
|
description: t('permission_getEntropyDescription'),
|
||||||
leftIcon: ICON_NAMES.SECURITY_KEY,
|
leftIcon: IconName.SecurityKey,
|
||||||
weight: 3,
|
weight: 3,
|
||||||
}),
|
}),
|
||||||
[RestrictedMethods.snap_manageState]: ({ t }) => ({
|
[RestrictedMethods.snap_manageState]: ({ t }) => ({
|
||||||
label: t('permission_manageState'),
|
label: t('permission_manageState'),
|
||||||
description: t('permission_manageStateDescription'),
|
description: t('permission_manageStateDescription'),
|
||||||
leftIcon: ICON_NAMES.ADD_SQUARE,
|
leftIcon: IconName.AddSquare,
|
||||||
weight: 3,
|
weight: 3,
|
||||||
}),
|
}),
|
||||||
[RestrictedMethods.wallet_snap]: ({ t, permissionValue }) => {
|
[RestrictedMethods.wallet_snap]: ({ t, permissionValue }) => {
|
||||||
const snaps = permissionValue.caveats[0].value;
|
const snaps = permissionValue.caveats[0].value;
|
||||||
const baseDescription = {
|
const baseDescription = {
|
||||||
leftIcon: getLeftIcon(ICON_NAMES.FLASH),
|
leftIcon: getLeftIcon(IconName.Flash),
|
||||||
rightIcon: RIGHT_INFO_ICON,
|
rightIcon: RIGHT_INFO_ICON,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -306,20 +300,20 @@ export const PERMISSION_DESCRIPTIONS = deepFreeze({
|
|||||||
[EndowmentPermissions['endowment:network-access']]: ({ t }) => ({
|
[EndowmentPermissions['endowment:network-access']]: ({ t }) => ({
|
||||||
label: t('permission_accessNetwork'),
|
label: t('permission_accessNetwork'),
|
||||||
description: t('permission_accessNetworkDescription'),
|
description: t('permission_accessNetworkDescription'),
|
||||||
leftIcon: ICON_NAMES.GLOBAL,
|
leftIcon: IconName.Global,
|
||||||
weight: 2,
|
weight: 2,
|
||||||
}),
|
}),
|
||||||
[EndowmentPermissions['endowment:webassembly']]: ({ t }) => ({
|
[EndowmentPermissions['endowment:webassembly']]: ({ t }) => ({
|
||||||
label: t('permission_webAssembly'),
|
label: t('permission_webAssembly'),
|
||||||
description: t('permission_webAssemblyDescription'),
|
description: t('permission_webAssemblyDescription'),
|
||||||
leftIcon: ICON_NAMES.DOCUMENT_CODE,
|
leftIcon: IconName.DocumentCode,
|
||||||
rightIcon: null,
|
rightIcon: null,
|
||||||
weight: 2,
|
weight: 2,
|
||||||
}),
|
}),
|
||||||
[EndowmentPermissions['endowment:long-running']]: ({ t }) => ({
|
[EndowmentPermissions['endowment:long-running']]: ({ t }) => ({
|
||||||
label: t('permission_longRunning'),
|
label: t('permission_longRunning'),
|
||||||
description: t('permission_longRunningDescription'),
|
description: t('permission_longRunningDescription'),
|
||||||
leftIcon: ICON_NAMES.LINK,
|
leftIcon: IconName.Link,
|
||||||
weight: 3,
|
weight: 3,
|
||||||
}),
|
}),
|
||||||
[EndowmentPermissions['endowment:transaction-insight']]: ({
|
[EndowmentPermissions['endowment:transaction-insight']]: ({
|
||||||
@ -327,7 +321,7 @@ export const PERMISSION_DESCRIPTIONS = deepFreeze({
|
|||||||
permissionValue,
|
permissionValue,
|
||||||
}) => {
|
}) => {
|
||||||
const baseDescription = {
|
const baseDescription = {
|
||||||
leftIcon: ICON_NAMES.SPEEDOMETER,
|
leftIcon: IconName.Speedometer,
|
||||||
weight: 3,
|
weight: 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -348,7 +342,7 @@ export const PERMISSION_DESCRIPTIONS = deepFreeze({
|
|||||||
...baseDescription,
|
...baseDescription,
|
||||||
label: t('permission_transactionInsightOrigin'),
|
label: t('permission_transactionInsightOrigin'),
|
||||||
description: t('permission_transactionInsightOriginDescription'),
|
description: t('permission_transactionInsightOriginDescription'),
|
||||||
leftIcon: ICON_NAMES.EXPLORE,
|
leftIcon: IconName.Explore,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,7 +351,7 @@ export const PERMISSION_DESCRIPTIONS = deepFreeze({
|
|||||||
[EndowmentPermissions['endowment:cronjob']]: ({ t }) => ({
|
[EndowmentPermissions['endowment:cronjob']]: ({ t }) => ({
|
||||||
label: t('permission_cronjob'),
|
label: t('permission_cronjob'),
|
||||||
description: t('permission_cronjobDescription'),
|
description: t('permission_cronjobDescription'),
|
||||||
leftIcon: ICON_NAMES.CLOCK,
|
leftIcon: IconName.Clock,
|
||||||
weight: 2,
|
weight: 2,
|
||||||
}),
|
}),
|
||||||
[EndowmentPermissions['endowment:ethereum-provider']]: ({
|
[EndowmentPermissions['endowment:ethereum-provider']]: ({
|
||||||
@ -366,14 +360,14 @@ export const PERMISSION_DESCRIPTIONS = deepFreeze({
|
|||||||
}) => ({
|
}) => ({
|
||||||
label: t('permission_ethereumProvider'),
|
label: t('permission_ethereumProvider'),
|
||||||
description: t('permission_ethereumProviderDescription'),
|
description: t('permission_ethereumProviderDescription'),
|
||||||
leftIcon: ICON_NAMES.ETHEREUM,
|
leftIcon: IconName.Ethereum,
|
||||||
weight: 2,
|
weight: 2,
|
||||||
id: 'ethereum-provider-access',
|
id: 'ethereum-provider-access',
|
||||||
message: t('ethereumProviderAccess', [targetSubjectMetadata?.origin]),
|
message: t('ethereumProviderAccess', [targetSubjectMetadata?.origin]),
|
||||||
}),
|
}),
|
||||||
[EndowmentPermissions['endowment:rpc']]: ({ t, permissionValue }) => {
|
[EndowmentPermissions['endowment:rpc']]: ({ t, permissionValue }) => {
|
||||||
const baseDescription = {
|
const baseDescription = {
|
||||||
leftIcon: ICON_NAMES.HIERARCHY,
|
leftIcon: IconName.Hierarchy,
|
||||||
weight: 2,
|
weight: 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -401,7 +395,7 @@ export const PERMISSION_DESCRIPTIONS = deepFreeze({
|
|||||||
///: END:ONLY_INCLUDE_IN
|
///: END:ONLY_INCLUDE_IN
|
||||||
[UNKNOWN_PERMISSION]: ({ t, permissionName }) => ({
|
[UNKNOWN_PERMISSION]: ({ t, permissionName }) => ({
|
||||||
label: t('permission_unknown', [permissionName ?? 'undefined']),
|
label: t('permission_unknown', [permissionName ?? 'undefined']),
|
||||||
leftIcon: getLeftIcon(ICON_NAMES.QUESTION),
|
leftIcon: getLeftIcon(IconName.Question),
|
||||||
rightIcon: null,
|
rightIcon: null,
|
||||||
weight: 4,
|
weight: 4,
|
||||||
}),
|
}),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user