mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 16:35:45 +01:00
use binder from context to make extensions it testable
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import React, { FC } from "react";
|
||||
import { binder } from "@scm-manager/ui-extensions";
|
||||
import { Image } from "..";
|
||||
import { Person } from "./Avatar";
|
||||
import { EXTENSION_POINT } from "./Avatar";
|
||||
import { useBinder } from "@scm-manager/ui-extensions";
|
||||
|
||||
type Props = {
|
||||
person: Person;
|
||||
@@ -10,6 +10,7 @@ type Props = {
|
||||
};
|
||||
|
||||
const AvatarImage: FC<Props> = ({ person, representation = "rounded-border" }) => {
|
||||
const binder = useBinder();
|
||||
const avatarFactory = binder.getExtension(EXTENSION_POINT);
|
||||
if (avatarFactory) {
|
||||
const avatar = avatarFactory(person);
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
import React, { Component, ReactNode } from "react";
|
||||
import { binder } from "@scm-manager/ui-extensions";
|
||||
import React, { FC } from "react";
|
||||
import { useBinder } from "@scm-manager/ui-extensions";
|
||||
import { EXTENSION_POINT } from "./Avatar";
|
||||
|
||||
type Props = {
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
class AvatarWrapper extends Component<Props> {
|
||||
render() {
|
||||
const AvatarWrapper: FC = ({ children }) => {
|
||||
const binder = useBinder();
|
||||
if (binder.hasExtension(EXTENSION_POINT)) {
|
||||
return <>{this.props.children}</>;
|
||||
return <>{children}</>;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default AvatarWrapper;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from "react";
|
||||
import React, { FC } from "react";
|
||||
import { Me, Links } from "@scm-manager/ui-types";
|
||||
import { Link } from "react-router-dom";
|
||||
import { binder } from "@scm-manager/ui-extensions";
|
||||
import { useBinder } from "@scm-manager/ui-extensions";
|
||||
import { AvatarWrapper, AvatarImage } from "../avatar";
|
||||
|
||||
type Props = {
|
||||
@@ -10,13 +10,11 @@ type Props = {
|
||||
links: Links;
|
||||
};
|
||||
|
||||
class Footer extends React.Component<Props> {
|
||||
render() {
|
||||
const { me, version, links } = this.props;
|
||||
const Footer: FC<Props> = ({ me, version, links }) => {
|
||||
const binder = useBinder();
|
||||
if (!me) {
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
|
||||
const extensionProps = { me, links };
|
||||
const extensions = binder.getExtensions("footer.links", extensionProps);
|
||||
|
||||
@@ -59,7 +57,6 @@ class Footer extends React.Component<Props> {
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default Footer;
|
||||
|
||||
Reference in New Issue
Block a user