the browser-facing portion of osu!
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 80 lines 2.4 kB view raw
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0. 2// See the LICENCE file in the repository root for full licence text. 3 4import BigButton from 'components/big-button'; 5import StringWithComponent from 'components/string-with-component'; 6import UserLink from 'components/user-link'; 7import { observer } from 'mobx-react'; 8import { Client } from 'models/oauth/client'; 9import * as React from 'react'; 10import { onError } from 'utils/ajax'; 11import { trans } from 'utils/lang'; 12 13interface Props { 14 client: Client; 15} 16 17@observer 18export class AuthorizedClient extends React.Component<Props> { 19 render() { 20 const client = this.props.client; 21 22 return ( 23 <div className='oauth-client'> 24 <div className='oauth-client__details'> 25 <div className='oauth-client__name'> 26 {client.name} 27 </div> 28 <span className='oauth-client__owner'> 29 <StringWithComponent 30 mappings={{ 31 user: <UserLink user={client.user} />, 32 }} 33 pattern={trans('oauth.authorized_clients.owned_by')} 34 /> 35 </span> 36 <div className='oauth-client__scopes'> 37 {this.renderPermissions()} 38 </div> 39 </div> 40 <div> 41 <BigButton 42 disabled={client.revoked} 43 icon={client.revoked ? 'fas fa-ban' : 'fas fa-trash'} 44 isBusy={client.isRevoking} 45 modifiers={['account-edit', 'account-edit-small', 'danger']} 46 props={{ 47 onClick: this.revokeClicked, 48 }} 49 text={trans(`oauth.authorized_clients.revoked.${client.revoked}`)} 50 /> 51 </div> 52 </div> 53 ); 54 } 55 56 renderPermissions() { 57 const scopes = Array.from(this.props.client.scopes).sort(); 58 return ( 59 <> 60 <div>{trans('oauth.authorized_clients.scopes_title')}</div> 61 <ul className='oauth-scopes'> 62 { 63 scopes.map((scope) => ( 64 <li key={scope}> 65 <span className='oauth-scopes__icon'><span className='fas fa-check' /></span> 66 {trans(`api.scopes.${scope}`)} 67 </li> 68 )) 69 } 70 </ul> 71 </> 72 ); 73 } 74 75 revokeClicked = () => { 76 if (!confirm(trans('oauth.authorized_clients.confirm_revoke'))) return; 77 78 this.props.client.revoke().fail(onError); 79 }; 80}