Skip to content

Commit

Permalink
Merge pull request #431 from arconnectio/arc-419/update-settings-copy
Browse files Browse the repository at this point in the history
fix: update settings copy
  • Loading branch information
nicholaswma authored Jul 12, 2024
2 parents c5358cc + 52bf07e commit 85bdc73
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 81 deletions.
18 changes: 9 additions & 9 deletions assets/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,39 +252,39 @@
"description": "Send transaction button"
},
"permissionDescriptionAccessAddress": {
"message": "Access the current address selected in ArConnect",
"message": "Allows access to the active address",
"description": "Description for the \"ACCESS_ADDRESS\" permission"
},
"permissionDescriptionAccessPublicKey": {
"message": "Access the public key of the current address selected in ArConnect",
"message": "Allows access to the active address public key",
"description": "Description for the \"ACCESS_PUBLIC_KEY\" permission"
},
"permissionDescriptionAccessAllAddresses": {
"message": "Access all addresses added to ArConnect",
"message": "Allows access to all the active and non-active wallet addresses",
"description": "Description for the \"ACCESS_ALL_ADDRESSES\" permission"
},
"permissionDescriptionSign": {
"message": "Sign a transaction",
"message": "Allows the signing of a transaction.",
"description": "Description for the \"SIGN_TRANSACTION\" permission"
},
"permissionDescriptionEncrypt": {
"message": "Encrypt data using the user's keyfile",
"message": "Allows encrypting data using wallet's keyfile. It does not grant access to keyfile.",
"description": "Description for the \"ENCRYPT\" permission"
},
"permissionDescriptionDecrypt": {
"message": "Decrypt data using the user's keyfile",
"message": "Allows decrypting data using wallet's keyfile. It does not grant access to keyfile.",
"description": "Description for the \"DECRYPT\" permission"
},
"permissionDescriptionSignature": {
"message": "Sign data using the user's keyfile",
"message": "Allows the signing of data.",
"description": "Description for the \"SIGNATURE\" permission"
},
"permissionDescriptionArweaveConfig": {
"message": "Access the user's custom Arweave config",
"message": "Access read access to ArConnect configuration file",
"description": "Description for the \"ACCESS_ARWEAVE_CONFIG\" permission"
},
"permissionDescriptionDispatch": {
"message": "Dispatch an Arweave transaction or interaction",
"message": "Allows using dispatch transactions.",
"description": "Description for the \"DISPATCH\" permission"
},
"copyId": {
Expand Down
18 changes: 9 additions & 9 deletions assets/_locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,39 +252,39 @@
"description": "Send transaction button"
},
"permissionDescriptionAccessAddress": {
"message": "访问 ArConnect 中选择的当前地址",
"message": "允许访问活动地址",
"description": "Description for the \"ACCESS_ADDRESS\" permission"
},
"permissionDescriptionAccessPublicKey": {
"message": "访问 ArConnect 中选择的当前地址的公钥",
"message": "允许访问活动地址的公钥",
"description": "Description for the \"ACCESS_PUBLIC_KEY\" permission"
},
"permissionDescriptionAccessAllAddresses": {
"message": "访问添加到 ArConnect 的所有地址",
"message": "允许访问所有活动和非活动钱包地址",
"description": "Description for the \"ACCESS_ALL_ADDRESSES\" permission"
},
"permissionDescriptionSign": {
"message": "签署交易",
"message": "允许签署交易。",
"description": "Description for the \"SIGN_TRANSACTION\" permission"
},
"permissionDescriptionEncrypt": {
"message": "使用用户的密钥文件加密数据",
"message": "允许使用钱包的密钥文件加密数据。这并不授予对密钥文件的访问权限",
"description": "Description for the \"ENCRYPT\" permission"
},
"permissionDescriptionDecrypt": {
"message": "使用用户的密钥文件解密数据",
"message": "允许使用钱包的密钥文件解密数据。这并不授予对密钥文件的访问权限",
"description": "Description for the \"DECRYPT\" permission"
},
"permissionDescriptionSignature": {
"message": "使用用户的密钥文件签署数据",
"message": "允许签署数据。",
"description": "Description for the \"SIGNATURE\" permission"
},
"permissionDescriptionArweaveConfig": {
"message": "访问用户的自定义 Arweave 配置",
"message": "允许读取 ArConnect 配置文件",
"description": "Description for the \"ACCESS_ARWEAVE_CONFIG\" permission"
},
"permissionDescriptionDispatch": {
"message": "发送 Arweave 交易或互动",
"message": "允许使用调度交易。",
"description": "Description for the \"DISPATCH\" permission"
},
"copyId": {
Expand Down
65 changes: 38 additions & 27 deletions src/components/dashboard/subsettings/AppSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,34 +111,45 @@ export default function AppSettings({ app, showTitle = false }: Props) {
</>
)}
<Title>{browser.i18n.getMessage("permissions")}</Title>
{Object.keys(permissionData).map((permissionName: PermissionType, i) => (
<div key={i}>
<PermissionCheckbox
onChange={(checked) =>
updateSettings((val) => {
// toggle permission
if (checked && !val.permissions.includes(permissionName)) {
val.permissions.push(permissionName);
} else if (!checked) {
val.permissions = val.permissions.filter(
(p) => p !== permissionName
);
}
{Object.keys(permissionData).map((permissionName: PermissionType, i) => {
let formattedPermissionName = permissionName
.split("_")
.map((word) => word.charAt(0) + word.slice(1).toLowerCase())
.join(" ");

if (permissionName === "SIGNATURE") {
formattedPermissionName = "Sign Data";
}

return val;
})
}
checked={settings.permissions.includes(permissionName)}
>
{permissionName}
<br />
<PermissionDescription>
{browser.i18n.getMessage(permissionData[permissionName])}
</PermissionDescription>
</PermissionCheckbox>
{i !== Object.keys(permissionData).length - 1 && <Spacer y={0.8} />}
</div>
))}
return (
<div key={i}>
<PermissionCheckbox
onChange={(checked) =>
updateSettings((val) => {
// toggle permission
if (checked && !val.permissions.includes(permissionName)) {
val.permissions.push(permissionName);
} else if (!checked) {
val.permissions = val.permissions.filter(
(p) => p !== permissionName
);
}

return val;
})
}
checked={settings.permissions.includes(permissionName)}
>
{formattedPermissionName}
<br />
<PermissionDescription>
{browser.i18n.getMessage(permissionData[permissionName])}
</PermissionDescription>
</PermissionCheckbox>
{i !== Object.keys(permissionData).length - 1 && <Spacer y={0.8} />}
</div>
);
})}
<Spacer y={1} />
<Title>{browser.i18n.getMessage("allowance")}</Title>
<PermissionCheckbox
Expand Down
83 changes: 47 additions & 36 deletions src/routes/popup/settings/apps/[url]/permissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useLocation } from "wouter";

export default function AppPermissions({ url }: Props) {
// app settings
const app = new Application(url);
const app = new Application(decodeURIComponent(url));
const [settings, updateSettings] = app.hook();
const [, setLocation] = useLocation();

Expand All @@ -24,42 +24,53 @@ export default function AppPermissions({ url }: Props) {
<Wrapper>
<Title noMargin>{browser.i18n.getMessage("permissions")}</Title>
{Object.keys(permissionData).map(
(permissionName: PermissionType, i) => (
<div key={i}>
<Permission>
<Checkbox
size={16}
onChange={(checked) =>
updateSettings((val) => {
// toggle permission
if (
checked &&
!val.permissions.includes(permissionName)
) {
val.permissions.push(permissionName);
} else if (!checked) {
val.permissions = val.permissions.filter(
(p) => p !== permissionName
);
}
(permissionName: PermissionType, i) => {
let formattedPermissionName = permissionName
.split("_")
.map((word) => word.charAt(0) + word.slice(1).toLowerCase())
.join(" ");

return val;
})
}
checked={settings.permissions.includes(permissionName)}
/>
<div>
<PermissionTitle>{permissionName}</PermissionTitle>
<PermissionDescription>
{browser.i18n.getMessage(permissionData[permissionName])}
</PermissionDescription>
</div>
</Permission>
{i !== Object.keys(permissionData).length - 1 && (
<Spacer y={0.8} />
)}
</div>
)
if (permissionName === "SIGNATURE") {
formattedPermissionName = "Sign Data";
}

return (
<div key={i}>
<Permission>
<Checkbox
size={16}
onChange={(checked) =>
updateSettings((val) => {
// toggle permission
if (
checked &&
!val.permissions.includes(permissionName)
) {
val.permissions.push(permissionName);
} else if (!checked) {
val.permissions = val.permissions.filter(
(p) => p !== permissionName
);
}

return val;
})
}
checked={settings.permissions.includes(permissionName)}
/>
<div>
<PermissionTitle>{formattedPermissionName}</PermissionTitle>
<PermissionDescription>
{browser.i18n.getMessage(permissionData[permissionName])}
</PermissionDescription>
</div>
</Permission>
{i !== Object.keys(permissionData).length - 1 && (
<Spacer y={0.8} />
)}
</div>
);
}
)}
<Spacer y={1} />
</Wrapper>
Expand Down

0 comments on commit 85bdc73

Please sign in to comment.