2020-09-06 16:15:25 +00:00
|
|
|
import { Component } from 'inferno';
|
2020-09-07 22:24:48 +00:00
|
|
|
import { GetSiteResponse } from 'lemmy-js-client';
|
|
|
|
import { setIsoData } from '../utils';
|
2020-09-06 16:15:25 +00:00
|
|
|
import { i18n } from '../i18next';
|
2020-09-11 18:09:21 +00:00
|
|
|
import { HtmlTags } from './html-tags';
|
2020-09-06 16:15:25 +00:00
|
|
|
|
|
|
|
interface InstancesState {
|
|
|
|
siteRes: GetSiteResponse;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class Instances extends Component<any, InstancesState> {
|
2020-09-07 22:24:48 +00:00
|
|
|
private isoData = setIsoData(this.context);
|
2020-09-06 16:15:25 +00:00
|
|
|
private emptyState: InstancesState = {
|
2020-12-24 01:58:27 +00:00
|
|
|
siteRes: this.isoData.site_res,
|
2020-09-06 16:15:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
constructor(props: any, context: any) {
|
|
|
|
super(props, context);
|
|
|
|
this.state = this.emptyState;
|
|
|
|
}
|
|
|
|
|
|
|
|
get documentTitle(): string {
|
2020-12-24 01:58:27 +00:00
|
|
|
return `${i18n.t('instances')} - ${this.state.siteRes.site_view.site.name}`;
|
2020-09-06 16:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2021-02-01 18:08:45 +00:00
|
|
|
let federated_instances = this.state.siteRes?.federated_instances;
|
2020-09-06 16:15:25 +00:00
|
|
|
return (
|
2021-02-01 18:08:45 +00:00
|
|
|
federated_instances && (
|
|
|
|
<div class="container">
|
|
|
|
<HtmlTags
|
|
|
|
title={this.documentTitle}
|
|
|
|
path={this.context.router.route.match.url}
|
|
|
|
/>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-6">
|
|
|
|
<h5>{i18n.t('linked_instances')}</h5>
|
|
|
|
{this.itemList(federated_instances.linked)}
|
|
|
|
</div>
|
|
|
|
{federated_instances.allowed.length > 0 && (
|
|
|
|
<div class="col-md-6">
|
|
|
|
<h5>{i18n.t('allowed_instances')}</h5>
|
|
|
|
{this.itemList(federated_instances.allowed)}
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{federated_instances.blocked.length > 0 && (
|
|
|
|
<div class="col-md-6">
|
|
|
|
<h5>{i18n.t('blocked_instances')}</h5>
|
|
|
|
{this.itemList(federated_instances.blocked)}
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
2020-09-07 22:24:48 +00:00
|
|
|
</div>
|
2021-02-01 18:08:45 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
itemList(items: string[]) {
|
|
|
|
return items.length > 0 ? (
|
|
|
|
<ul>
|
|
|
|
{items.map(i => (
|
|
|
|
<li>
|
2021-02-12 17:55:07 +00:00
|
|
|
<a href={`https://${i}`} rel="noopener">
|
2021-02-01 18:08:45 +00:00
|
|
|
{i}
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
) : (
|
|
|
|
<div>{i18n.t('none_found')}</div>
|
2020-09-06 16:15:25 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|