show changeset parents on changeset details view

This commit is contained in:
Eduard Heimbuch
2020-06-15 12:44:43 +02:00
parent 4f79f14b3d
commit b75b438d7b
4 changed files with 49 additions and 4 deletions

View File

@@ -87,6 +87,10 @@
"shortSummary": "Committet <0/> <1/>", "shortSummary": "Committet <0/> <1/>",
"tags": "Tags", "tags": "Tags",
"diffNotSupported": "Diff des Changesets wird von diesem Repositorytyp nicht unterstützt", "diffNotSupported": "Diff des Changesets wird von diesem Repositorytyp nicht unterstützt",
"parents": {
"label" : "Parent",
"label_plural": "Parents"
},
"contributors": { "contributors": {
"mailto": "Mail senden an", "mailto": "Mail senden an",
"list": "Liste der Mitwirkenden", "list": "Liste der Mitwirkenden",

View File

@@ -91,6 +91,10 @@
"details": "Details", "details": "Details",
"sources": "Sources" "sources": "Sources"
}, },
"parents": {
"label" : "Parent",
"label_plural": "Parents"
},
"contributors": { "contributors": {
"mailto": "Send mail to", "mailto": "Send mail to",
"list": "List of contributors", "list": "List of contributors",

View File

@@ -26,7 +26,7 @@ import { Trans, useTranslation, WithTranslation, withTranslation } from "react-i
import classNames from "classnames"; import classNames from "classnames";
import styled from "styled-components"; import styled from "styled-components";
import { ExtensionPoint } from "@scm-manager/ui-extensions"; import { ExtensionPoint } from "@scm-manager/ui-extensions";
import { Changeset, Repository, Tag } from "@scm-manager/ui-types"; import { Changeset, Repository, Tag, Link } from "@scm-manager/ui-types";
import { import {
AvatarImage, AvatarImage,
AvatarWrapper, AvatarWrapper,
@@ -41,6 +41,7 @@ import {
Icon Icon
} from "@scm-manager/ui-components"; } from "@scm-manager/ui-components";
import ContributorTable from "./ContributorTable"; import ContributorTable from "./ContributorTable";
import { Link as ReactLink } from "react-router-dom";
type Props = WithTranslation & { type Props = WithTranslation & {
changeset: Changeset; changeset: Changeset;
@@ -51,6 +52,11 @@ type State = {
collapsed: boolean; collapsed: boolean;
}; };
type Parent = {
id: string;
_links: Link[];
};
const RightMarginP = styled.p` const RightMarginP = styled.p`
margin-right: 1em; margin-right: 1em;
`; `;
@@ -102,6 +108,18 @@ const ContributorToggleLine = styled.p`
margin-bottom: 0.5rem !important; margin-bottom: 0.5rem !important;
`; `;
const ChangesetSummary = styled.div`
display: flex;
justify-content: space-between;
`
const SeparatedParents = styled.div`
a + a:before {
content: ",\\00A0";
color: #4a4a4a;
}
`;
const Contributors: FC<{ changeset: Changeset }> = ({ changeset }) => { const Contributors: FC<{ changeset: Changeset }> = ({ changeset }) => {
const [t] = useTranslation("repos"); const [t] = useTranslation("repos");
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
@@ -148,6 +166,11 @@ class ChangesetDetails extends React.Component<Props, State> {
const description = changesets.parseDescription(changeset.description); const description = changesets.parseDescription(changeset.description);
const id = <ChangesetId repository={repository} changeset={changeset} link={false} />; const id = <ChangesetId repository={repository} changeset={changeset} link={false} />;
const date = <DateFromNow date={changeset.date} />; const date = <DateFromNow date={changeset.date} />;
const parents = changeset._embedded.parents.map((parent: Parent) => (
<ReactLink title={parent.id} to={parent.id}>
{parent.id.substring(0, 7)}
</ReactLink>
));
return ( return (
<> <>
@@ -172,9 +195,17 @@ class ChangesetDetails extends React.Component<Props, State> {
</AvatarWrapper> </AvatarWrapper>
<div className="media-content is-ellipsis-overflow"> <div className="media-content is-ellipsis-overflow">
<Contributors changeset={changeset} /> <Contributors changeset={changeset} />
<p> <ChangesetSummary>
<Trans i18nKey="repos:changeset.summary" components={[id, date]} /> <p>
</p> <Trans i18nKey="repos:changeset.summary" components={[id, date]} />
</p>
{parents?.length > 0 && (
<SeparatedParents>
{t("changeset.parents.label", { count: parents?.length }) + ": "}
{parents}
</SeparatedParents>
)}
</ChangesetSummary>
</div> </div>
<div className="media-right">{this.renderTags()}</div> <div className="media-right">{this.renderTags()}</div>
</article> </article>

View File

@@ -53,6 +53,12 @@ class ChangesetView extends React.Component<Props> {
fetchChangesetIfNeeded(repository, id); fetchChangesetIfNeeded(repository, id);
} }
componentDidUpdate() {
const { fetchChangesetIfNeeded, repository } = this.props;
const id = this.props.match.params.id;
fetchChangesetIfNeeded(repository, id);
}
render() { render() {
const { changeset, loading, error, t, repository } = this.props; const { changeset, loading, error, t, repository } = this.props;