Files
SCM-Manager/scm-ui/src/repos/components/changesets/ChangesetDetails.js

124 lines
3.1 KiB
JavaScript
Raw Normal View History

2018-10-18 14:40:35 +02:00
//@flow
import React from "react";
2018-11-01 11:43:49 +01:00
import type { Changeset, Repository } from "@scm-manager/ui-types";
import { Interpolate, translate } from "react-i18next";
2018-10-18 14:40:35 +02:00
import injectSheet from "react-jss";
import {
DateFromNow,
ChangesetId,
ChangesetTag,
ChangesetAuthor,
ChangesetDiff,
AvatarWrapper,
AvatarImage,
changesets
} from "@scm-manager/ui-components";
2018-10-18 14:40:35 +02:00
import classNames from "classnames";
2018-11-01 11:43:49 +01:00
import type { Tag } from "@scm-manager/ui-types";
import { ExtensionPoint } from "@scm-manager/ui-extensions";
2018-10-18 14:40:35 +02:00
const styles = {
spacing: {
marginRight: "1em"
}
};
type Props = {
changeset: Changeset,
repository: Repository,
t: string => string,
classes: any
};
class ChangesetDetails extends React.Component<Props> {
render() {
2018-11-01 11:43:49 +01:00
const { changeset, repository, classes } = this.props;
2018-10-18 14:40:35 +02:00
const description = changesets.parseDescription(changeset.description);
2018-10-18 14:40:35 +02:00
const id = (
<ChangesetId repository={repository} changeset={changeset} link={false} />
2018-10-18 14:40:35 +02:00
);
const date = <DateFromNow date={changeset.date} />;
2018-10-18 14:40:35 +02:00
return (
<div>
<div className="content">
<h4>
<ExtensionPoint
name="changesets.changeset.description"
props={{ changeset, value: description.title }}
renderAll={true}
>
{description.title}
</ExtensionPoint>
</h4>
<article className="media">
<AvatarWrapper>
<p className={classNames("image", "is-64x64", classes.spacing)}>
<AvatarImage person={changeset.author} />
</p>
</AvatarWrapper>
<div className="media-content">
<p>
<ChangesetAuthor changeset={changeset} />
</p>
<p>
<Interpolate
i18nKey="changesets.changeset.summary"
id={id}
time={date}
/>
</p>
</div>
<div className="media-right">{this.renderTags()}</div>
</article>
<p>
{description.message.split("\n").map((item, key) => {
return (
<span key={key}>
<ExtensionPoint
name="changesets.changeset.description"
props={{ changeset, value: item }}
renderAll={true}
>
{item}
</ExtensionPoint>
<br />
</span>
);
})}
</p>
</div>
<div>
<ChangesetDiff changeset={changeset} />
</div>
2018-10-18 14:40:35 +02:00
</div>
);
}
getTags = () => {
2018-11-01 11:43:49 +01:00
const { changeset } = this.props;
2018-10-18 14:40:35 +02:00
return changeset._embedded.tags || [];
};
renderTags = () => {
const tags = this.getTags();
if (tags.length > 0) {
return (
<div className="level-item">
{tags.map((tag: Tag) => {
return <ChangesetTag key={tag.name} tag={tag} />;
2018-10-18 14:40:35 +02:00
})}
</div>
);
}
return null;
};
}
export default injectSheet(styles)(translate("repos")(ChangesetDetails));