Add footer extension points for links and avatar

This commit is contained in:
Eduard Heimbuch
2020-02-18 13:10:37 +01:00
parent 1ff0c46b0e
commit 61d7d5e6dd
5 changed files with 69 additions and 22 deletions

View File

@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
### Added
- Added footer extension points for links and avatar
## 2.0.0-rc4 - 2020-02-14 ## 2.0.0-rc4 - 2020-02-14
### Added ### Added
- Support for Java versions > 8 - Support for Java versions > 8

View File

@@ -1,4 +1,4 @@
import React from "react"; import React, {FC} from "react";
import { binder } from "@scm-manager/ui-extensions"; import { binder } from "@scm-manager/ui-extensions";
import { Image } from ".."; import { Image } from "..";
import { Person } from "./Avatar"; import { Person } from "./Avatar";
@@ -6,21 +6,20 @@ import { EXTENSION_POINT } from "./Avatar";
type Props = { type Props = {
person: Person; person: Person;
representation?: "rounded" | "rounded-border";
}; };
class AvatarImage extends React.Component<Props> { const AvatarImage:FC<Props> = ({person, representation = "rounded-border"}) => {
render() {
const { person } = this.props;
const avatarFactory = binder.getExtension(EXTENSION_POINT); const avatarFactory = binder.getExtension(EXTENSION_POINT);
if (avatarFactory) { if (avatarFactory) {
const avatar = avatarFactory(person); const avatar = avatarFactory(person);
return <Image className="has-rounded-border" src={avatar} alt={person.name} />; const className = representation === "rounded" ? "is-rounded" : "has-rounded-border";
return <Image className={className} src={avatar} alt={person.name} />;
} }
return null; return null;
} };
}
export default AvatarImage; export default AvatarImage;

View File

@@ -1,23 +1,66 @@
import React from "react"; import React from "react";
import { Me } from "@scm-manager/ui-types"; import { Me, Links } from "@scm-manager/ui-types";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { binder } from "@scm-manager/ui-extensions";
import { AvatarWrapper, AvatarImage } from "../avatar";
type Props = { type Props = {
me?: Me; me?: Me;
version: string;
links: Links;
}; };
const RestDocLink = () => {
return <a href="">Rest Documentation</a>;
};
binder.bind("footer.links", RestDocLink);
class Footer extends React.Component<Props> { class Footer extends React.Component<Props> {
render() { render() {
const { me } = this.props; const { me, version, links } = this.props;
if (!me) { if (!me) {
return ""; return "";
} }
const extensions = binder.getExtensions("footer.links", { me, links });
return ( return (
<footer className="footer"> <footer className="footer">
<div className="container is-centered"> <div className="container is-centered has-text-centered ">
<p className="has-text-centered"> <p className="is-size-6 columns is-centered">
<AvatarWrapper>
<figure className="media-left">
<p className="image is-24x24 is-rounded">
<AvatarImage person={me} representation="rounded" />
</p>
</figure>
</AvatarWrapper>
<Link to={"/me"}>{me.displayName}</Link> <Link to={"/me"}>{me.displayName}</Link>
</p> </p>
<hr className={"has-background-grey-lighter"} />
<p>
<a href="https://www.scm-manager.org/" target="_blank">
SCM-Manager {version}
</a>
{extensions.map(Ext => (
<>
{" "}
| <Ext />
</>
))}
</p>
<br />
<p>
Powered by{" "}
<a target="_blank" href="https://cloudogu.com/">
Cloudogu GmbH
</a>{" "}
| Learn more at{" "}
<a href="https://www.scm-manager.org/" target="_blank">
SCM-Manager
</a>
</p>
</div> </div>
</footer> </footer>
); );

View File

@@ -67,8 +67,10 @@ hr.header-with-actions {
} }
} }
.footer { footer.footer {
height: 50px; //height: 100px;
background-color: whitesmoke;
padding: 2rem 1.5rem 1rem;
} }
// 6. Import the rest of Bulma // 6. Import the rest of Bulma
@@ -691,11 +693,6 @@ form .field:not(.is-grouped) {
} }
} }
// footer
.footer {
background-color: whitesmoke;
}
// aside // aside
.aside-background { .aside-background {
bottom: 0; bottom: 0;

View File

@@ -8,6 +8,7 @@ import { fetchMe, getFetchMeFailure, getMe, isAuthenticated, isFetchMePending }
import { ErrorPage, Footer, Header, Loading, PrimaryNavigation } from "@scm-manager/ui-components"; import { ErrorPage, Footer, Header, Loading, PrimaryNavigation } from "@scm-manager/ui-components";
import { Links, Me } from "@scm-manager/ui-types"; import { Links, Me } from "@scm-manager/ui-types";
import { import {
getAppVersion,
getFetchIndexResourcesFailure, getFetchIndexResourcesFailure,
getLinks, getLinks,
getMeLink, getMeLink,
@@ -21,6 +22,7 @@ type Props = WithTranslation & {
loading: boolean; loading: boolean;
links: Links; links: Links;
meLink: string; meLink: string;
version: string;
// dispatcher functions // dispatcher functions
fetchMe: (link: string) => void; fetchMe: (link: string) => void;
@@ -34,7 +36,7 @@ class App extends Component<Props> {
} }
render() { render() {
const { me, loading, error, authenticated, links, t } = this.props; const { me, loading, error, authenticated, links, version, t } = this.props;
let content; let content;
const navigation = authenticated ? <PrimaryNavigation links={links} /> : ""; const navigation = authenticated ? <PrimaryNavigation links={links} /> : "";
@@ -50,7 +52,7 @@ class App extends Component<Props> {
<div className="App"> <div className="App">
<Header>{navigation}</Header> <Header>{navigation}</Header>
{content} {content}
{authenticated && <Footer me={me} />} {authenticated && <Footer me={me} version={version} links={links} />}
</div> </div>
); );
} }
@@ -69,13 +71,15 @@ const mapStateToProps = (state: any) => {
const error = getFetchMeFailure(state) || getFetchIndexResourcesFailure(state); const error = getFetchMeFailure(state) || getFetchIndexResourcesFailure(state);
const links = getLinks(state); const links = getLinks(state);
const meLink = getMeLink(state); const meLink = getMeLink(state);
const version = getAppVersion(state);
return { return {
authenticated, authenticated,
me, me,
loading, loading,
error, error,
links, links,
meLink meLink,
version
}; };
}; };