Merge pull request #158 from LemmyNet/add_federated_instances_details

Add federated instances details
This commit is contained in:
Dessalines 2021-02-01 13:36:47 -05:00 committed by GitHub
commit e8a7c68ba4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 57 additions and 39 deletions

@ -1 +1 @@
Subproject commit b914a9696bc4fadc46fdca655c94c3b4cedf3e8c Subproject commit c2d3ef3350d0b5ba2fe9cc4148af553374a1e4ec

View file

@ -67,7 +67,7 @@
"eslint": "^7.18.0", "eslint": "^7.18.0",
"eslint-plugin-jane": "^9.0.6", "eslint-plugin-jane": "^9.0.6",
"husky": "^4.3.8", "husky": "^4.3.8",
"lemmy-js-client": "0.9.1", "lemmy-js-client": "0.9.4-rc.1",
"lint-staged": "^10.5.3", "lint-staged": "^10.5.3",
"mini-css-extract-plugin": "^1.3.4", "mini-css-extract-plugin": "^1.3.4",
"node-fetch": "^2.6.1", "node-fetch": "^2.6.1",

View file

@ -28,11 +28,13 @@ export class Footer extends Component<FooterProps, FooterState> {
{i18n.t('modlog')} {i18n.t('modlog')}
</Link> </Link>
</li> </li>
<li class="nav-item"> {this.props.site.federated_instances && (
<Link className="nav-link" to="/instances"> <li class="nav-item">
{i18n.t('instances')} <Link className="nav-link" to="/instances">
</Link> {i18n.t('instances')}
</li> </Link>
</li>
)}
<li class="nav-item"> <li class="nav-item">
<a className="nav-link" href={docsUrl}> <a className="nav-link" href={docsUrl}>
{i18n.t('docs')} {i18n.t('docs')}

View file

@ -24,30 +24,50 @@ export class Instances extends Component<any, InstancesState> {
} }
render() { render() {
let federated_instances = this.state.siteRes?.federated_instances;
return ( return (
<div class="container"> federated_instances && (
<HtmlTags <div class="container">
title={this.documentTitle} <HtmlTags
path={this.context.router.route.match.url} title={this.documentTitle}
/> path={this.context.router.route.match.url}
<div> />
<h5>{i18n.t('linked_instances')}</h5> <div class="row">
{this.state.siteRes && <div class="col-md-6">
this.state.siteRes.federated_instances.length ? ( <h5>{i18n.t('linked_instances')}</h5>
<ul> {this.itemList(federated_instances.linked)}
{this.state.siteRes.federated_instances.map(i => ( </div>
<li> {federated_instances.allowed.length > 0 && (
<a href={`https://${i}`} target="_blank" rel="noopener"> <div class="col-md-6">
{i} <h5>{i18n.t('allowed_instances')}</h5>
</a> {this.itemList(federated_instances.allowed)}
</li> </div>
))} )}
</ul> {federated_instances.blocked.length > 0 && (
) : ( <div class="col-md-6">
<div>{i18n.t('none_found')}</div> <h5>{i18n.t('blocked_instances')}</h5>
)} {this.itemList(federated_instances.blocked)}
</div>
)}
</div>
</div> </div>
</div> )
);
}
itemList(items: string[]) {
return items.length > 0 ? (
<ul>
{items.map(i => (
<li>
<a href={`https://${i}`} target="_blank" rel="noopener">
{i}
</a>
</li>
))}
</ul>
) : (
<div>{i18n.t('none_found')}</div>
); );
} }
} }

View file

@ -637,10 +637,7 @@ export class Main extends Component<any, MainState> {
} }
get showLocal(): boolean { get showLocal(): boolean {
return ( return this.isoData.site_res.federated_instances?.linked.length > 0;
this.isoData.site_res.federated_instances !== null &&
this.isoData.site_res.federated_instances.length > 0
);
} }
get canAdmin(): boolean { get canAdmin(): boolean {

View file

@ -560,8 +560,7 @@ export class User extends Component<any, UserState> {
] ]
} }
showLocal={ showLocal={
this.state.siteRes.federated_instances && this.state.siteRes.federated_instances?.linked.length > 0
this.state.siteRes.federated_instances.length > 0
} }
onChange={this.handleUserSettingsListingTypeChange} onChange={this.handleUserSettingsListingTypeChange}
/> />

View file

@ -5629,10 +5629,10 @@ lcid@^1.0.0:
dependencies: dependencies:
invert-kv "^1.0.0" invert-kv "^1.0.0"
lemmy-js-client@0.9.1: lemmy-js-client@0.9.4-rc.1:
version "0.9.1" version "0.9.4-rc.1"
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.9.1.tgz#2f87666eba74e980d05421042661fb57b673e6b6" resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.9.4-rc.1.tgz#3898a61adc72e8741f3db02f8f595e33dcf37b97"
integrity sha512-Oo/sirk3l/JIN0yQVBCRwGhV3LcXk8WGf2g+42VPsatc4P9Ii/Vrgf9/Eo1M3kEV1aqTJXjTq5+ywaKJB5PUJw== integrity sha512-Z3EnaBe6xglv+5l5mjfPoEpd7FpoP67IPLKBOE8nItQ4CKyE20Sc9gjIc2yUjf/zOmf97XnHvTeZo86Jm458Rg==
levn@^0.4.1: levn@^0.4.1:
version "0.4.1" version "0.4.1"