permissionHandler intl

pull/3342/head
drafish 2 years ago committed by Aniket
parent f796c18727
commit 91b0d4f7be
  1. 2
      apps/remix-ide/src/app/tabs/locales/en/index.js
  2. 10
      apps/remix-ide/src/app/tabs/locales/en/permissionHandler.json
  3. 2
      apps/remix-ide/src/app/tabs/locales/zh/index.js
  4. 10
      apps/remix-ide/src/app/tabs/locales/zh/permissionHandler.json
  5. 18
      libs/remix-ui/permission-handler/src/lib/permission-dialog.tsx

@ -9,6 +9,7 @@ import solidityJson from './solidity.json';
import terminalJson from './terminal.json';
import udappJson from './udapp.json';
import solidityUnitTestingJson from './solidityUnitTesting.json';
import permissionHandlerJson from './permissionHandler.json';
export default {
...debuggerJson,
@ -22,4 +23,5 @@ export default {
...terminalJson,
...udappJson,
...solidityUnitTestingJson,
...permissionHandlerJson,
}

@ -0,0 +1,10 @@
{
"permissionHandler.allPermissionsReset": "All permisssions have been reset.",
"permissionHandler.rememberText": "has changed and",
"permissionHandler.permissionHandlerMessage": "\"{from}\" {rememberText} would like to access to \"{method}\" of \"{to}\"`",
"permissionHandler.description": "Description",
"permissionHandler.noDescriptionProvided": "No description Provided",
"permissionHandler.makeSureYouTrustThisPlugin": "Make sure you trust this plugin before processing this call.",
"permissionHandler.rememberThisChoice": "Remember this choice",
"permissionHandler.resetAllPermissions": "Reset all Permissions"
}

@ -9,6 +9,7 @@ import solidityJson from './solidity.json';
import terminalJson from './terminal.json';
import udappJson from './udapp.json';
import solidityUnitTestingJson from './solidityUnitTesting.json';
import permissionHandlerJson from './permissionHandler.json';
import enJson from '../en';
// There may have some un-translated content. Always fill in the gaps with EN JSON.
@ -25,4 +26,5 @@ export default Object.assign({}, enJson, {
...terminalJson,
...udappJson,
...solidityUnitTestingJson,
...permissionHandlerJson,
})

@ -0,0 +1,10 @@
{
"permissionHandler.allPermissionsReset": "已重置所有权限。",
"permissionHandler.rememberText": "已变更且",
"permissionHandler.permissionHandlerMessage": "\"{from}\" {rememberText}要访问 \"{to}\" 的 \"{method}\"",
"permissionHandler.description": "描述",
"permissionHandler.noDescriptionProvided": "没有提供描述",
"permissionHandler.makeSureYouTrustThisPlugin": "在处理此调用之前,请确保您信任此插件。",
"permissionHandler.rememberThisChoice": "记住此选项",
"permissionHandler.resetAllPermissions": "重置所有权限"
}

@ -1,4 +1,5 @@
import React, { ChangeEventHandler, useContext, useEffect, useRef, useState } from 'react' // eslint-disable-line
import { FormattedMessage, useIntl } from 'react-intl'
import { PermissionHandlerProps } from '../interface'
import './permission-dialog.css'
@ -6,6 +7,7 @@ const PermissionHandlerDialog = (props: PermissionHandlerProps) => {
const { from, to, remember, method, message, sensitiveCall } = props.value
const [feedback, setFeedback] = useState<string>('')
const theme = props.theme
const intl = useIntl()
const switchMode = (e: any) => {
props.plugin.switchMode(from, to, method, e.target.checked)
@ -16,7 +18,7 @@ const PermissionHandlerDialog = (props: PermissionHandlerProps) => {
}
const reset = () => {
props.plugin.clear()
setFeedback('All permisssions have been reset.')
setFeedback(intl.formatMessage({ id: 'permissionHandler.allPermissionsReset' }))
}
const imgFrom = () => { return <img className={`${theme === 'dark' ? 'invert' : ''}`} alt='' id='permissionModalImagesFrom' src={from.icon} /> }
@ -32,13 +34,13 @@ const PermissionHandlerDialog = (props: PermissionHandlerProps) => {
}
const text = () => {
return <>"{from.displayName}" {(remember ? 'has changed and' : '')} would like to access to "{method}" of "{to.displayName}"`</>
return <FormattedMessage id='permissionHandler.permissionHandlerMessage' values={{ from: from.displayName, to: to.displayName, method, rememberText: remember ? intl.formatMessage({ id: 'permissionHandler.rememberText' }) : '' }} />
}
const pluginMessage = () => {
return message
? <div>
<h6>Description</h6>
<h6><FormattedMessage id='permissionHandler.description' /></h6>
<p>{message}</p>
</div> : null
}
@ -48,19 +50,19 @@ const PermissionHandlerDialog = (props: PermissionHandlerProps) => {
<article>
<h4 data-id="permissionHandlerMessage">{text()} :</h4>
<h6>{from.displayName}</h6>
<p> {from.description || <i>No description Provided</i>}</p>
<p> {from.description || <i><FormattedMessage id='permissionHandler.noDescriptionProvided' /></i>}</p>
<h6>{to.displayName} :</h6>
<p> {to.description || <i>No description Provided</i>}</p>
<p> {to.description || <i><FormattedMessage id='permissionHandler.noDescriptionProvided' /></i>}</p>
{pluginMessage()}
{ sensitiveCall ? <p className='text-warning'><i className="fas fa-exclamation-triangle mr-2" aria-hidden="true"></i>Make sure you trust this plugin before processing this call.</p> : '' }
{ sensitiveCall ? <p className='text-warning'><i className="fas fa-exclamation-triangle mr-2" aria-hidden="true"></i><FormattedMessage id='permissionHandler.makeSureYouTrustThisPlugin' /></p> : '' }
</article>
<article className='remember'>
{ !sensitiveCall && <div className='form-check'>
{rememberSwitch()}
<label htmlFor='remember' className="form-check-label" data-id="permissionHandlerRememberChoice">Remember this choice</label>
<label htmlFor='remember' className="form-check-label" data-id="permissionHandlerRememberChoice"><FormattedMessage id='permissionHandler.rememberThisChoice' /></label>
</div>
}
<button className="btn btn-sm" onClick={reset}>Reset all Permissions</button>
<button className="btn btn-sm" onClick={reset}><FormattedMessage id='permissionHandler.resetAllPermissions' /></button>
</article>
<div>{feedback}</div>
</section>)

Loading…
Cancel
Save