Skip to content

Commit

Permalink
OAuth - Web clients, app download modal
Browse files Browse the repository at this point in the history
  • Loading branch information
1aerostorm committed Aug 1, 2024
1 parent 0bc52a8 commit e2f4274
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 1 deletion.
48 changes: 48 additions & 0 deletions src/elements/WebClients.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React from 'react'
import tt from 'counterpart'

class WebClients extends React.Component {
static propTypes = {
}

state = {
}

render() {
const { web_clients } = this.props

let appList
const webs = Object.entries(web_clients || {})
if (webs.length) {
appList = []
for (const [en, data] of webs) {
if (en === '_desktop') continue
const { img, ru, url } = data
appList.push(<a href={url} target='_blank' rel='noopener noreferrer'>
<img src={img} />
{ru}
</a>)
}

let desktop
const { _desktop } = web_clients
if (_desktop) {
desktop = <div>
{tt('web_clients_jx.or_desktop')}
<a href='#'>{tt('web_clients_jx.or_desktop_link')}</a>
{tt('web_clients_jx.or_desktop2')}
</div>
}

appList = <React.Fragment>
<h3>{tt('web_clients_jx.title')}</h3>
{appList}
{desktop}
<hr/>
</React.Fragment>
}
return appList
}
}

export default WebClients
6 changes: 6 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@
"memo_is_public": "This memo is public.",
"submit": "Transfer"
},
"web_clients_jx": {
"title": "Web-clients",
"or_desktop": "Or ",
"or_desktop_link": "download desktop app",
"or_desktop2": ", which combines all these applications."
},
"oauth_transfer_nft": {
"no_tokens": "You have not yet any NFT-tokens.",
"token_not_exist": "No such token in your wallet. You can transfer any of these tokens:",
Expand Down
7 changes: 7 additions & 0 deletions src/locales/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,18 @@
"unfreeze": "Активировать аккаунт",
"apps_title": "Приложения",
"apps_empty": "Вы пока не авторизованы ни в одном приложении.",
"web_clients": "Веб-клиенты",
"link": "Ссылка: ",
"edit": "Настроить",
"remove_authority": "Отменить доступ OAuth к моему аккаунту",
"remove_authority_confirm": "Вы действительно хотите отменить доступ GolosSigner к вашему аккаунту?"
},
"web_clients_jx": {
"title": "Веб-клиенты",
"or_desktop": "Или ",
"or_desktop_link": "скачайте десктоп-клиент",
"or_desktop2": ", где объединены все эти приложения."
},
"oauth_transfer": {
"from": "От",
"to": "Отправить аккаунту",
Expand Down
5 changes: 4 additions & 1 deletion src/pages/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import tt from 'counterpart';
import { api } from 'golos-lib-js'

import RemoveAuthority from '@/elements/RemoveAuthority';
import WebClients from '@/elements/WebClients'
import Header from '@/modules/Header';
import { callApi, } from '@/utils/OAuthClient';
import { withRouterHelpers, } from '@/utils/routing';
Expand Down Expand Up @@ -51,7 +52,7 @@ class Index extends React.Component {
render() {
const { session, oauthCfg, } = this.props;
const { account, clients, } = session;
const { service_account, sign_endpoint, } = oauthCfg;
const { service_account, sign_endpoint, web_clients, } = oauthCfg;
let actions = [];
for (let action of [
'transfer', 'donate', 'delegate_vs', 'transfer_nft']) {
Expand Down Expand Up @@ -102,6 +103,7 @@ class Index extends React.Component {
} else {
clientList = <div className='callout'>{tt('oauth_main_jsx.apps_empty')}</div>
}

return (
<div className='Signer_page'>
<Head>
Expand All @@ -122,6 +124,7 @@ class Index extends React.Component {
<h3>{tt('oauth_main_jsx.apps_title')}</h3>
{clientList}
<hr/>
<WebClients web_clients={web_clients} />
<RemoveAuthority
account={account}
service_account={service_account}
Expand Down
1 change: 1 addition & 0 deletions src/server/oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ function getOAuthCfg() {
ws_connection_client: config.get('oauth.ws_connection_client'),
chain_id: config.has('oauth.chain_id') && config.get('oauth.chain_id'),
service_account: config.get('oauth.service_account.name'),
web_clients: config.has('oauth.web_clients') && config.get('oauth.web_clients'),
sign_endpoint: new URL('/api/oauth/sign', config.get('oauth.rest_api')).toString(),
};
}
Expand Down

0 comments on commit e2f4274

Please sign in to comment.