2019-08-20 15:50:11 +02:00
|
|
|
//@flow
|
|
|
|
|
import React from "react";
|
2019-08-20 17:19:57 +02:00
|
|
|
import { compose } from "redux";
|
2019-08-20 15:50:11 +02:00
|
|
|
import { translate } from "react-i18next";
|
2019-08-20 17:19:57 +02:00
|
|
|
import injectSheet from "react-jss";
|
2019-08-20 15:50:11 +02:00
|
|
|
import type { Plugin } from "@scm-manager/ui-types";
|
|
|
|
|
import {
|
|
|
|
|
Button,
|
|
|
|
|
ButtonGroup,
|
|
|
|
|
Checkbox,
|
|
|
|
|
Modal,
|
|
|
|
|
SubmitButton
|
|
|
|
|
} from "@scm-manager/ui-components";
|
2019-08-20 17:19:57 +02:00
|
|
|
import classNames from "classnames";
|
2019-08-20 15:50:11 +02:00
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
plugin: Plugin,
|
|
|
|
|
onSubmit: () => void,
|
|
|
|
|
onClose: () => void,
|
|
|
|
|
|
|
|
|
|
// context props
|
2019-08-20 17:19:57 +02:00
|
|
|
classes: any,
|
2019-08-20 15:50:11 +02:00
|
|
|
t: string => string
|
|
|
|
|
};
|
|
|
|
|
|
2019-08-20 17:19:57 +02:00
|
|
|
const styles = {
|
|
|
|
|
titleVersion: {
|
|
|
|
|
marginLeft: "0.75rem"
|
|
|
|
|
},
|
|
|
|
|
userLabelAlignment: {
|
|
|
|
|
textAlign: "left",
|
|
|
|
|
marginRight: 0,
|
|
|
|
|
minWidth: "5.5em"
|
|
|
|
|
},
|
|
|
|
|
userFieldFlex: {
|
|
|
|
|
flexGrow: 4
|
|
|
|
|
},
|
|
|
|
|
listSpacing: {
|
|
|
|
|
marginTop: "0 !important"
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2019-08-20 15:50:11 +02:00
|
|
|
class PluginModal extends React.Component<Props> {
|
|
|
|
|
renderDependencies() {
|
2019-08-20 17:19:57 +02:00
|
|
|
const { plugin, classes, t } = this.props;
|
2019-08-20 15:50:11 +02:00
|
|
|
|
|
|
|
|
let dependencies = null;
|
|
|
|
|
if (plugin.dependencies && plugin.dependencies.length > 0) {
|
|
|
|
|
dependencies = (
|
|
|
|
|
<>
|
2019-08-20 17:19:57 +02:00
|
|
|
<strong>{t("plugin.modal.dependencyNotification")}</strong>
|
|
|
|
|
<div className="field is-horizontal">
|
|
|
|
|
<div
|
|
|
|
|
className={classNames(
|
|
|
|
|
classes.userLabelAlignment,
|
|
|
|
|
"field-label is-inline-flex"
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
{t("plugins.modal.dependencies")}:
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
|
|
|
|
className={classNames(
|
|
|
|
|
classes.userFieldFlex,
|
|
|
|
|
"field-body is-inline-flex"
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
<ul className={classes.listSpacing}>
|
|
|
|
|
{plugin.dependencies.map((dependency, index) => {
|
|
|
|
|
return <li key={index}>{dependency}</li>;
|
|
|
|
|
})}
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2019-08-20 15:50:11 +02:00
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return dependencies;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
2019-08-20 17:19:57 +02:00
|
|
|
const { plugin, onSubmit, onClose, classes, t } = this.props;
|
2019-08-20 15:50:11 +02:00
|
|
|
|
|
|
|
|
const body = (
|
|
|
|
|
<>
|
2019-08-20 17:19:57 +02:00
|
|
|
<div className="media">
|
|
|
|
|
<div className="media-content">
|
|
|
|
|
<p>{plugin.description && plugin.description}</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="media">
|
|
|
|
|
<div className="media-content">
|
|
|
|
|
<div className="field is-horizontal">
|
|
|
|
|
<div
|
|
|
|
|
className={classNames(
|
|
|
|
|
classes.userLabelAlignment,
|
|
|
|
|
"field-label is-inline-flex"
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
{t("plugins.modal.author")}:
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
|
|
|
|
className={classNames(
|
|
|
|
|
classes.userFieldFlex,
|
|
|
|
|
"field-body is-inline-flex"
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
{plugin.author}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="field is-horizontal">
|
|
|
|
|
<div
|
|
|
|
|
className={classNames(
|
|
|
|
|
classes.userLabelAlignment,
|
|
|
|
|
"field-label is-inline-flex"
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
{t("plugins.modal.version")}:
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
|
|
|
|
className={classNames(
|
|
|
|
|
classes.userFieldFlex,
|
|
|
|
|
"field-body is-inline-flex"
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
{plugin.version}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{this.renderDependencies()}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="media">
|
|
|
|
|
<div className="media-content">
|
|
|
|
|
<Checkbox
|
|
|
|
|
checked={false}
|
|
|
|
|
label={t("plugins.modal.restart")}
|
|
|
|
|
onChange={null}
|
|
|
|
|
disabled={null}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2019-08-20 15:50:11 +02:00
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const footer = (
|
|
|
|
|
<form onSubmit={onSubmit}>
|
|
|
|
|
<ButtonGroup>
|
|
|
|
|
<SubmitButton label={t("plugins.modal.install")} />
|
|
|
|
|
<Button label={t("plugins.modal.abort")} action={onClose} />
|
|
|
|
|
</ButtonGroup>
|
|
|
|
|
</form>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Modal
|
2019-08-20 17:19:57 +02:00
|
|
|
title={t("plugins.modal.title", {
|
|
|
|
|
name: plugin.displayName ? plugin.displayName : ""
|
|
|
|
|
})}
|
2019-08-20 15:50:11 +02:00
|
|
|
closeFunction={() => onClose()}
|
|
|
|
|
body={body}
|
|
|
|
|
footer={footer}
|
|
|
|
|
active={true}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-20 17:19:57 +02:00
|
|
|
export default compose(
|
|
|
|
|
injectSheet(styles),
|
|
|
|
|
translate("admin")
|
|
|
|
|
)(PluginModal);
|