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";
|
2018-12-10 08:45:59 +01:00
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
DateFromNow,
|
|
|
|
|
ChangesetId,
|
|
|
|
|
ChangesetTag,
|
|
|
|
|
ChangesetAuthor,
|
|
|
|
|
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";
|
2018-10-26 16:26:55 +02:00
|
|
|
import ScmDiff from "../../containers/ScmDiff";
|
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
|
|
|
|
2018-12-10 08:45:59 +01:00
|
|
|
const description = changesets.parseDescription(changeset.description);
|
2018-10-18 14:40:35 +02:00
|
|
|
|
|
|
|
|
const id = (
|
2018-12-10 08:45:59 +01:00
|
|
|
<ChangesetId repository={repository} changeset={changeset} link={false}/>
|
2018-10-18 14:40:35 +02:00
|
|
|
);
|
2018-12-10 08:45:59 +01:00
|
|
|
const date = <DateFromNow date={changeset.date}/>;
|
2018-10-18 14:40:35 +02:00
|
|
|
|
|
|
|
|
return (
|
2018-10-26 16:26:55 +02:00
|
|
|
<div>
|
|
|
|
|
<div className="content">
|
|
|
|
|
<h4>{description.title}</h4>
|
|
|
|
|
<article className="media">
|
|
|
|
|
<AvatarWrapper>
|
|
|
|
|
<p className={classNames("image", "is-64x64", classes.spacing)}>
|
2018-12-10 14:55:42 +01:00
|
|
|
<AvatarImage person={changeset.author} />
|
2018-10-26 16:26:55 +02:00
|
|
|
</p>
|
|
|
|
|
</AvatarWrapper>
|
|
|
|
|
<div className="media-content">
|
|
|
|
|
<p>
|
2018-12-10 08:45:59 +01:00
|
|
|
<ChangesetAuthor changeset={changeset}/>
|
2018-10-26 16:26:55 +02:00
|
|
|
</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}>
|
2018-11-01 11:43:49 +01:00
|
|
|
{item}
|
2018-12-10 08:45:59 +01:00
|
|
|
<br/>
|
2018-11-01 11:43:49 +01:00
|
|
|
</span>
|
2018-10-26 16:26:55 +02:00
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
2018-12-10 08:45:59 +01:00
|
|
|
<ScmDiff changeset={changeset} sideBySide={false}/>
|
2018-10-26 16:26:55 +02:00
|
|
|
</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) => {
|
2018-12-10 08:45:59 +01:00
|
|
|
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));
|