gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

username.jsx (1571B)


      1 /*
      2 	GoToSocial
      3 	Copyright (C) GoToSocial Authors admin@gotosocial.org
      4 	SPDX-License-Identifier: AGPL-3.0-or-later
      5 
      6 	This program is free software: you can redistribute it and/or modify
      7 	it under the terms of the GNU Affero General Public License as published by
      8 	the Free Software Foundation, either version 3 of the License, or
      9 	(at your option) any later version.
     10 
     11 	This program is distributed in the hope that it will be useful,
     12 	but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14 	GNU Affero General Public License for more details.
     15 
     16 	You should have received a copy of the GNU Affero General Public License
     17 	along with this program.  If not, see <http://www.gnu.org/licenses/>.
     18 */
     19 
     20 "use strict";
     21 
     22 const React = require("react");
     23 const { Link } = require("wouter");
     24 
     25 module.exports = function Username({ user, link = true }) {
     26 	let className = "user";
     27 	let isLocal = user.domain == null;
     28 
     29 	if (user.suspended) {
     30 		className += " suspended";
     31 	}
     32 
     33 	if (isLocal) {
     34 		className += " local";
     35 	}
     36 
     37 	let icon = isLocal
     38 		? { fa: "fa-home", info: "Local user" }
     39 		: { fa: "fa-external-link-square", info: "Remote user" };
     40 
     41 	let Element = "div";
     42 	let href = null;
     43 
     44 	if (link) {
     45 		Element = Link;
     46 		href = `/settings/admin/accounts/${user.id}`;
     47 	}
     48 
     49 	return (
     50 		<Element className={className} to={href}>
     51 			<span className="acct">@{user.account.acct}</span>
     52 			<i className={`fa fa-fw ${icon.fa}`} aria-hidden="true" title={icon.info} />
     53 			<span className="sr-only">{icon.info}</span>
     54 		</Element>
     55 	);
     56 };