mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 01:51:40 -05:00
withList -> withMulti; add fallback prop for Avatar component
This commit is contained in:
parent
493380889b
commit
bafe350407
2 changed files with 8 additions and 3 deletions
|
@ -5,8 +5,13 @@ import Users from 'meteor/vulcan:users';
|
||||||
import { Link } from 'react-router';
|
import { Link } from 'react-router';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
const Avatar = ({className, user, link}) => {
|
const Avatar = ({className, user, link, fallback}) => {
|
||||||
|
|
||||||
|
const avatarClassNames = classNames('avatar', className);
|
||||||
|
|
||||||
|
if (!user) {
|
||||||
|
return <div className={avatarClassNames}>{fallback}</div>
|
||||||
|
}
|
||||||
const avatarUrl = user.avatarUrl || Users.avatar.getUrl(user);
|
const avatarUrl = user.avatarUrl || Users.avatar.getUrl(user);
|
||||||
|
|
||||||
const img = <img alt={Users.getDisplayName(user)} className="avatar-image" src={avatarUrl} title={user.username}/>;
|
const img = <img alt={Users.getDisplayName(user)} className="avatar-image" src={avatarUrl} title={user.username}/>;
|
||||||
|
@ -15,7 +20,7 @@ const Avatar = ({className, user, link}) => {
|
||||||
const avatar = avatarUrl ? img : initials;
|
const avatar = avatarUrl ? img : initials;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames('avatar', className)}>
|
<div className={avatarClassNames}>
|
||||||
{link ?
|
{link ?
|
||||||
<Link to={Users.getProfileUrl(user)}>
|
<Link to={Users.getProfileUrl(user)}>
|
||||||
<span>{avatar}</span>
|
<span>{avatar}</span>
|
||||||
|
|
|
@ -72,7 +72,7 @@ class Datatable extends PureComponent {
|
||||||
...this.props.options
|
...this.props.options
|
||||||
}
|
}
|
||||||
|
|
||||||
const DatatableWithList = withList(options)(Components.DatatableContents);
|
const DatatableWithList = withMulti(options)(Components.DatatableContents);
|
||||||
|
|
||||||
const canInsert = collection.options && collection.options.mutations && collection.options.mutations.new && collection.options.mutations.new.check(this.props.currentUser);
|
const canInsert = collection.options && collection.options.mutations && collection.options.mutations.new && collection.options.mutations.new.check(this.props.currentUser);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue