2018-10-18 14:40:35 +02:00
|
|
|
//@flow
|
|
|
|
|
import React from "react";
|
2018-10-19 08:44:03 +02:00
|
|
|
import {binder} from "@scm-manager/ui-extensions";
|
2018-12-10 08:45:59 +01:00
|
|
|
import {Image} from "..";
|
|
|
|
|
import type { Person } from "./Avatar";
|
|
|
|
|
import { EXTENSION_POINT } from "./Avatar";
|
|
|
|
|
|
2018-10-18 14:40:35 +02:00
|
|
|
|
|
|
|
|
type Props = {
|
2018-12-10 08:45:59 +01:00
|
|
|
person: Person
|
2018-10-18 14:40:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class AvatarImage extends React.Component<Props> {
|
|
|
|
|
render() {
|
2018-12-10 08:45:59 +01:00
|
|
|
const { person } = this.props;
|
2018-10-18 14:40:35 +02:00
|
|
|
|
2018-12-10 08:45:59 +01:00
|
|
|
const avatarFactory = binder.getExtension(EXTENSION_POINT);
|
2018-10-18 14:40:35 +02:00
|
|
|
if (avatarFactory) {
|
2018-12-10 08:45:59 +01:00
|
|
|
const avatar = avatarFactory(person);
|
2018-10-18 14:40:35 +02:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Image
|
|
|
|
|
className="has-rounded-border"
|
|
|
|
|
src={avatar}
|
2018-12-10 08:45:59 +01:00
|
|
|
alt={person.name}
|
2018-10-18 14:40:35 +02:00
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default AvatarImage;
|