Localize permission descriptions (#8661)

feature/default_network_editable
Whymarrh Whitby 4 years ago committed by GitHub
parent a0d64c7932
commit 4802ed1df5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/_locales/en/messages.json
  2. 2
      app/scripts/controllers/permissions/restrictedMethods.js
  3. 5
      ui/app/components/app/connected-accounts-list/connected-accounts-list-permissions/connected-accounts-list-permissions.component.js
  4. 1
      ui/app/components/app/connected-accounts-list/connected-accounts-list.component.js
  5. 9
      ui/app/components/app/permission-page-container/permission-page-container-content/permission-page-container-content.component.js
  6. 3
      ui/app/components/app/permission-page-container/permission-page-container.component.js
  7. 2
      ui/app/components/app/permission-page-container/permission-page-container.container.js
  8. 3
      ui/app/selectors/permissions.js
  9. 4
      ui/app/selectors/selectors.js
  10. 4
      ui/app/selectors/tests/permissions.test.js

@ -1,4 +1,8 @@
{
"eth_accounts": {
"message": "View your public address (required)",
"description": "The description for the `eth_accounts` permission"
},
"connectedSites": {
"message": "Connected sites"
},

@ -1,8 +1,6 @@
export default function getRestrictedMethods ({ getIdentities, getKeyringAccounts }) {
return {
'eth_accounts': {
description: `View your public address (required)`,
method: (_, res, __, end) => {
getKeyringAccounts()
.then((accounts) => {

@ -14,7 +14,6 @@ export default class ConnectedAccountsListPermissions extends PureComponent {
static propTypes = {
permissions: PropTypes.arrayOf(PropTypes.shape({
key: PropTypes.string.isRequired,
description: PropTypes.string.isRequired,
})),
}
@ -56,9 +55,9 @@ export default class ConnectedAccountsListPermissions extends PureComponent {
>
<p>{t('authorizedPermissions')}:</p>
<ul className="connected-accounts-permissions__list">
{permissions.map(({ key, description }) => (
{permissions.map(({ key }) => (
<li key={key} className="connected-accounts-permissions__list-item">
<i className="fas fa-check-square" />&nbsp;{description}
<i className="fas fa-check-square" />&nbsp;{t(key)}
</li>
))}
</ul>

@ -28,7 +28,6 @@ export default class ConnectedAccountsList extends PureComponent {
})).isRequired,
permissions: PropTypes.arrayOf(PropTypes.shape({
key: PropTypes.string.isRequired,
description: PropTypes.string.isRequired,
})),
selectedAddress: PropTypes.string.isRequired,
addPermittedAccount: PropTypes.func.isRequired,

@ -10,7 +10,6 @@ export default class PermissionPageContainerContent extends PureComponent {
static propTypes = {
domainMetadata: PropTypes.object.isRequired,
selectedPermissions: PropTypes.object.isRequired,
permissionsDescriptions: PropTypes.object.isRequired,
onPermissionToggle: PropTypes.func.isRequired,
selectedIdentities: PropTypes.array,
allIdentitiesSelected: PropTypes.bool,
@ -64,17 +63,13 @@ export default class PermissionPageContainerContent extends PureComponent {
renderRequestedPermissions () {
const {
selectedPermissions, permissionsDescriptions, onPermissionToggle,
selectedPermissions, onPermissionToggle,
} = this.props
const { t } = this.context
const items = Object.keys(selectedPermissions).map((methodName) => {
// the request will almost certainly be reject by rpc-cap if this happens
if (!permissionsDescriptions[methodName]) {
console.warn(`Unknown permission requested: ${methodName}`)
}
const description = permissionsDescriptions[methodName] || methodName
const description = t(methodName)
// don't allow deselecting eth_accounts
const isDisabled = methodName === 'eth_accounts'

@ -12,7 +12,6 @@ export default class PermissionPageContainer extends Component {
rejectPermissionsRequest: PropTypes.func.isRequired,
selectedIdentities: PropTypes.array,
allIdentitiesSelected: PropTypes.bool,
permissionsDescriptions: PropTypes.object.isRequired,
request: PropTypes.object,
redirect: PropTypes.bool,
permissionRejected: PropTypes.bool,
@ -116,7 +115,6 @@ export default class PermissionPageContainer extends Component {
const {
requestMetadata,
targetDomainMetadata,
permissionsDescriptions,
selectedIdentities,
redirect,
permissionRejected,
@ -129,7 +127,6 @@ export default class PermissionPageContainer extends Component {
requestMetadata={requestMetadata}
domainMetadata={targetDomainMetadata}
selectedPermissions={this.state.selectedPermissions}
permissionsDescriptions={permissionsDescriptions}
onPermissionToggle={this.onPermissionToggle}
selectedIdentities={selectedIdentities}
redirect={redirect}

@ -1,7 +1,6 @@
import { connect } from 'react-redux'
import PermissionPageContainer from './permission-page-container.component'
import {
getPermissionsDescriptions,
getTargetDomainMetadata,
getMetaMaskIdentities,
} from '../../../selectors'
@ -14,7 +13,6 @@ const mapStateToProps = (state, ownProps) => {
const allIdentitiesSelected = Object.keys(selectedIdentities).length === Object.keys(allIdentities).length && selectedIdentities.length > 1
return {
permissionsDescriptions: getPermissionsDescriptions(state),
targetDomainMetadata,
allIdentitiesSelected,
}

@ -241,14 +241,11 @@ export function getPermissionsForActiveTab (state) {
const { activeTab, metamask } = state
const {
domains = {},
permissionsDescriptions,
} = metamask
return domains[activeTab.origin]?.permissions?.map(({ parentCapability }) => {
const description = permissionsDescriptions[parentCapability]
return {
key: parentCapability,
description,
}
})
}

@ -302,10 +302,6 @@ export function getCustomNonceValue (state) {
return String(state.metamask.customNonceValue)
}
export function getPermissionsDescriptions (state) {
return state.metamask.permissionsDescriptions
}
export function getPermissionsRequests (state) {
return state.metamask.permissionsRequests || []
}

@ -428,16 +428,12 @@ describe('selectors', function () {
},
},
},
permissionsDescriptions: {
'eth_accounts': "View the addresses of the user's chosen accounts.",
},
},
}
it('should return a list of permissions strings', function () {
assert.deepEqual(getPermissionsForActiveTab(mockState), [{
key: 'eth_accounts',
description: "View the addresses of the user's chosen accounts.",
}])
})
})

Loading…
Cancel
Save