mirror of
https://github.com/flarum/framework.git
synced 2024-12-11 13:05:50 +08:00
eb72307a54
* Introduce user display names It is not uncommon for forums to be intergrated with sites where users don't have a unique "handle" - they might just have their first name, or a full name, which is not guaranteed to be unique. This commit introduces the concept of "display names" for users. By default display names are the same as usernames, but extensions may override this and set them to something different. The important thing is that all code should use `display_name` whenever intending to output a human-readable name - `username` is reserved for cases where you want to output a unique identifier (which may or may not be human-friendly). The new "GetDisplayName" API is probably sub-optimal, but I didn't worry too much because we can come up with something better in `next-back`. ref #557 * Apply fixes from StyleCI [ci skip] [skip ci]
13 lines
412 B
JavaScript
13 lines
412 B
JavaScript
/**
|
|
* The `username` helper displays a user's username in a <span class="username">
|
|
* tag. If the user doesn't exist, the username will be displayed as [deleted].
|
|
*
|
|
* @param {User} user
|
|
* @return {Object}
|
|
*/
|
|
export default function username(user) {
|
|
const name = (user && user.displayName()) || app.translator.trans('core.lib.username.deleted_text');
|
|
|
|
return <span className="username">{name}</span>;
|
|
}
|