From 57c803037430631bf5ce44f4a3f396f1595b9480 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 9 May 2022 21:49:53 -0500 Subject: [PATCH] InstanceInfoPanel: convert to TSX --- .../ui/components/instance_info_panel.js | Bin 2651 -> 0 bytes .../ui/components/instance_info_panel.tsx | 68 ++++++++++++++++++ app/soapbox/pages/remote_instance_page.tsx | 8 ++- 3 files changed, 73 insertions(+), 3 deletions(-) delete mode 100644 app/soapbox/features/ui/components/instance_info_panel.js create mode 100644 app/soapbox/features/ui/components/instance_info_panel.tsx diff --git a/app/soapbox/features/ui/components/instance_info_panel.js b/app/soapbox/features/ui/components/instance_info_panel.js deleted file mode 100644 index 20582ddcfd8da27ecaaeac7f46abaedced2ac1d2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2651 zcma)8!EWO=5WV{=ra%G7fF<9xQ5v8Hx;|_XWVffq!b?jdn_Y=?Nh(Pp=-)ddk&N&S*^A_=k#EVNP-d4)1qwyy*W#dmO)>Z7)91FiC3rx2^f`Ji97q>0qZ zZVfit;oivxYa+6|?TGF(Iw#d}=5-xzJz$RejbtnJi~5AB^~HoBqVEJ7Wrm@ON}i1HqlLPN)KJ>abXoBHFO|E6QUX5bvv?{Ox4%dWva+0r{09akqk? zX9nb5nL*@5lb%#cBJWQmcr^Ga+S++T3HvA&bbQ!H&~GT&Df>kk z;{4eOhhH>zw}l*H(#_$9m@^0H*O1=>*EDJs{3GPT?lFkd0vL3yq5J47Q0I;|WHgqP zHl>(23O`0`E{`L)rGjJGtsj9CGx9N1l0uR;@Zrom6@LvQI$*5;n-=#ggb)Ojb=6z^i3kVfiGitFw8vrTV}tB9-LQT z>3YDL-WFqp_$|OO-jH~B0JtmVGYo_KhiEX5UR;%&hp7#tl2k~A&~$1w zo<#RP_CKPN6AFr2KnX0t=$h`34GAi0mv>CPUtHgPuLM*g`PrXLY<#}`o+G~Zu$?(j zVj3T{$TAl(h1KGK^#vOrcHdnt<#BQIHi_2#-Ig<7Ty^`)djjr = ({ host }) => { + const intl = useIntl(); + const dispatch = useAppDispatch(); + + const settings = useSettings(); + const remoteInstance: any = useAppSelector(state => getRemoteInstance(state, host)); + const pinned: boolean = (settings.getIn(['remote_timeline', 'pinnedHosts']) as any).includes(host); + + const handlePinHost: React.MouseEventHandler = () => { + if (!pinned) { + dispatch(pinHost(host)); + } else { + dispatch(unpinHost(host)); + } + }; + + const makeMenu = () => { + return [{ + text: intl.formatMessage(pinned ? messages.unpinHost : messages.pinHost, { host }), + action: handlePinHost, + icon: require(pinned ? '@tabler/icons/icons/pinned-off.svg' : '@tabler/icons/icons/pin.svg'), + }]; + }; + + const menu = makeMenu(); + const icon = pinned ? 'thumbtack' : 'globe-w'; + + if (!remoteInstance) return null; + + return ( +
+
+ + + {remoteInstance.get('host')} + +
+ +
+
+
+ ); +}; + +export default InstanceInfoPanel; diff --git a/app/soapbox/pages/remote_instance_page.tsx b/app/soapbox/pages/remote_instance_page.tsx index 548e0f9de4..e3488908ca 100644 --- a/app/soapbox/pages/remote_instance_page.tsx +++ b/app/soapbox/pages/remote_instance_page.tsx @@ -13,13 +13,15 @@ import { federationRestrictionsDisclosed } from 'soapbox/utils/state'; import { Layout } from '../components/ui'; interface IRemoteInstancePage { - params: { - instance: string, + params?: { + instance?: string, }, } /** Page for viewing a remote instance timeline. */ -const RemoteInstancePage: React.FC = ({ children, params: { instance: host } }) => { +const RemoteInstancePage: React.FC = ({ children, params }) => { + const host = params?.instance; + const account = useOwnAccount(); const disclosed = useAppSelector(federationRestrictionsDisclosed);