2019-07-03 09:35:15 +02:00
|
|
|
//@flow
|
|
|
|
|
import React from "react";
|
2019-07-31 15:40:35 +02:00
|
|
|
import injectSheet from "react-jss";
|
2019-07-04 17:31:15 +02:00
|
|
|
import type { Plugin } from "@scm-manager/ui-types";
|
2019-07-09 13:29:25 +02:00
|
|
|
import { CardColumn } from "@scm-manager/ui-components";
|
2019-07-04 17:31:15 +02:00
|
|
|
import PluginAvatar from "./PluginAvatar";
|
2019-07-03 09:35:15 +02:00
|
|
|
|
|
|
|
|
type Props = {
|
2019-07-31 15:40:35 +02:00
|
|
|
plugin: Plugin,
|
|
|
|
|
|
|
|
|
|
// context props
|
|
|
|
|
classes: any
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const styles = {
|
|
|
|
|
link: {
|
|
|
|
|
pointerEvents: "all"
|
|
|
|
|
}
|
2019-07-03 09:35:15 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class PluginEntry extends React.Component<Props> {
|
2019-07-09 13:29:25 +02:00
|
|
|
createAvatar = (plugin: Plugin) => {
|
|
|
|
|
return <PluginAvatar plugin={plugin} />;
|
|
|
|
|
};
|
|
|
|
|
|
2019-07-31 15:40:35 +02:00
|
|
|
createContentRight = (plugin: Plugin) => {
|
|
|
|
|
const { classes } = this.props;
|
|
|
|
|
if (plugin._links && plugin._links.install && plugin._links.install.href) {
|
|
|
|
|
return (
|
|
|
|
|
<a className={classes.link} href={plugin._links.install.href}>
|
|
|
|
|
<i className="fas fa-cloud-download-alt fa-2x" />
|
|
|
|
|
</a>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2019-07-09 13:29:25 +02:00
|
|
|
createFooterLeft = (plugin: Plugin) => {
|
|
|
|
|
return <small className="level-item">{plugin.author}</small>;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
createFooterRight = (plugin: Plugin) => {
|
|
|
|
|
return <p className="level-item">{plugin.version}</p>;
|
|
|
|
|
};
|
|
|
|
|
|
2019-07-03 09:35:15 +02:00
|
|
|
render() {
|
2019-07-09 13:29:25 +02:00
|
|
|
const { plugin } = this.props;
|
|
|
|
|
const avatar = this.createAvatar(plugin);
|
2019-07-31 15:40:35 +02:00
|
|
|
const contentRight = this.createContentRight(plugin);
|
2019-07-09 13:29:25 +02:00
|
|
|
const footerLeft = this.createFooterLeft(plugin);
|
|
|
|
|
const footerRight = this.createFooterRight(plugin);
|
|
|
|
|
|
2019-07-04 17:31:15 +02:00
|
|
|
// TODO: Add link to plugin page below
|
2019-07-03 09:35:15 +02:00
|
|
|
return (
|
2019-07-09 13:29:25 +02:00
|
|
|
<CardColumn
|
|
|
|
|
link="#"
|
|
|
|
|
avatar={avatar}
|
|
|
|
|
title={plugin.name}
|
|
|
|
|
description={plugin.description}
|
2019-07-31 15:40:35 +02:00
|
|
|
contentRight={contentRight}
|
2019-07-09 13:29:25 +02:00
|
|
|
footerLeft={footerLeft}
|
|
|
|
|
footerRight={footerRight}
|
|
|
|
|
/>
|
2019-07-03 09:35:15 +02:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-31 15:40:35 +02:00
|
|
|
export default injectSheet(styles)(PluginEntry);
|