diff --git a/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetAuthor.js b/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetAuthor.js index bba29a1da2..6ee76e3927 100644 --- a/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetAuthor.js +++ b/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetAuthor.js @@ -2,9 +2,13 @@ import React from "react"; import type { Changeset } from "@scm-manager/ui-types"; import { ExtensionPoint } from "@scm-manager/ui-extensions"; +import {translate} from "react-i18next"; type Props = { - changeset: Changeset + changeset: Changeset, + + // context props + t: (string) => string }; class ChangesetAuthor extends React.Component { @@ -14,39 +18,35 @@ class ChangesetAuthor extends React.Component { return null; } - const { name } = changeset.author; + const { name, mail } = changeset.author; + if (mail) { + return this.withExtensionPoint(this.renderWithMail(name, mail)); + } + return this.withExtensionPoint(<>{name}); + } + + renderWithMail(name: string, mail: string) { + const { t } = this.props; return ( - <> - {name} {this.renderMail()} {this.renderAuthorMetadataExtensionPoint()} - + + {name} + ); } - renderAuthorMetadataExtensionPoint = () => { - const { changeset } = this.props; + withExtensionPoint(child: any) { + const { t } = this.props; return ( - - asas - + <> + {t("changesets.author.prefix")} {child} + + ); - }; - - renderMail() { - const { mail } = this.props.changeset.author; - if (mail) { - return ( - - < - {mail} - > - - ); - } } } -export default ChangesetAuthor; +export default translate("repos")(ChangesetAuthor); diff --git a/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetButtonGroup.js b/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetButtonGroup.js new file mode 100644 index 0000000000..292d61b6cc --- /dev/null +++ b/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetButtonGroup.js @@ -0,0 +1,45 @@ +//@flow +import React from "react"; +import type { Changeset, Repository } from "@scm-manager/ui-types"; +import ButtonGroup from "../../buttons/ButtonGroup"; +import Button from "../../buttons/Button"; +import { createChangesetLink, createSourcesLink } from "./changesets"; + +type Props = { + repository: Repository, + changeset: Changeset +} + +class ChangesetButtonGroup extends React.Component { + + render() { + const { repository, changeset } = this.props; + + const changesetLink = createChangesetLink(repository, changeset); + const sourcesLink = createSourcesLink(repository, changeset); + + return ( + + + + + ); + } + +} + +export default ChangesetButtonGroup; diff --git a/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetId.js b/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetId.js index aec1029427..a3cc3c73b7 100644 --- a/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetId.js +++ b/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetId.js @@ -3,6 +3,7 @@ import {Link} from "react-router-dom"; import React from "react"; import type {Changeset, Repository} from "@scm-manager/ui-types"; +import { createChangesetLink } from "./changesets"; type Props = { repository: Repository, @@ -20,13 +21,11 @@ export default class ChangesetId extends React.Component { }; renderLink = () => { - const { changeset, repository } = this.props; + const { repository, changeset } = this.props; + const link = createChangesetLink(repository, changeset); + return ( - + {this.shortId(changeset)} ); diff --git a/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetRow.js b/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetRow.js index 7609bc2171..10287ec71f 100644 --- a/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetRow.js +++ b/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetRow.js @@ -8,21 +8,39 @@ import ChangesetId from "./ChangesetId"; import injectSheet from "react-jss"; import { DateFromNow } from "../.."; import ChangesetAuthor from "./ChangesetAuthor"; -import ChangesetTag from "./ChangesetTag"; - import { parseDescription } from "./changesets"; import { AvatarWrapper, AvatarImage } from "../../avatar"; import { ExtensionPoint } from "@scm-manager/ui-extensions"; +import ChangesetTags from "./ChangesetTags"; +import ChangesetButtonGroup from "./ChangesetButtonGroup"; const styles = { - pointer: { - cursor: "pointer" + changeset: { + // & references parent rule + // have a look at https://cssinjs.org/jss-plugin-nested?v=v10.0.0-alpha.9 + "& + &": { + borderTop: "1px solid rgba(219, 219, 219, 0.5)", + marginTop: "1rem", + paddingTop: "1rem" + } }, - changesetGroup: { - marginBottom: "1em" + avatarFigure: { + marginTop: ".25rem", + marginRight: ".5rem", }, - withOverflow: { - overflow: "auto" + avatarImage: { + height: "35px", + width: "35px" + }, + isVcentered: { + marginTop: "auto", + marginBottom: "auto" + }, + metadata: { + marginLeft: 0 + }, + tag: { + marginTop: ".5rem" } }; @@ -34,74 +52,70 @@ type Props = { }; class ChangesetRow extends React.Component { - createLink = (changeset: Changeset) => { + createChangesetId = (changeset: Changeset) => { const { repository } = this.props; return ; }; - getTags = () => { - const { changeset } = this.props; - return changeset._embedded.tags || []; - }; - render() { - const { changeset, classes } = this.props; - const changesetLink = this.createLink(changeset); - const dateFromNow = ; - const authorLine = ; + const { repository, changeset, classes } = this.props; const description = parseDescription(changeset.description); + const changesetId = this.createChangesetId(changeset); + const dateFromNow = ; return ( -
- -
-
-

- -

-
+
+
+
+ +

+ + {description.title} + +

+ +
+ +
+
+ +
+
+
+
+

+ +

+

+ +

+

+ +

+
+
+
- -
-
-

- - - {description.title} - - -
- -

{" "} -
{authorLine}
+
+ +
- {this.renderTags()} -
+ ); } - - renderTags = () => { - const tags = this.getTags(); - if (tags.length > 0) { - return ( -
- {tags.map((tag: Tag) => { - return ; - })} -
- ); - } - return null; - }; } export default injectSheet(styles)(translate("repos")(ChangesetRow)); diff --git a/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetTag.js b/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetTag.js index 6a87400d2e..03c73a8e9f 100644 --- a/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetTag.js +++ b/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetTag.js @@ -1,32 +1,17 @@ //@flow import React from "react"; import type { Tag } from "@scm-manager/ui-types"; -import injectSheet from "react-jss"; -import classNames from "classnames"; - -const styles = { - spacing: { - marginRight: "4px" - } -}; +import ChangesetTagBase from "./ChangesetTagBase"; type Props = { - tag: Tag, - - // context props - classes: Object + tag: Tag }; class ChangesetTag extends React.Component { render() { - const { tag, classes } = this.props; - return ( - - {" "} - {tag.name} - - ); + const { tag } = this.props; + return ; } } -export default injectSheet(styles)(ChangesetTag); +export default ChangesetTag; diff --git a/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetTagBase.js b/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetTagBase.js new file mode 100644 index 0000000000..7fc8dabcd2 --- /dev/null +++ b/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetTagBase.js @@ -0,0 +1,34 @@ +//@flow +import React from "react"; +import injectSheet from "react-jss"; +import classNames from "classnames"; + +const styles = { + tag: { + marginTop: ".5rem" + }, + spacing: { + marginRight: ".25rem" + } +}; + +type Props = { + icon: string, + label: string, + + // context props + classes: Object +}; + +class ChangesetTagBase extends React.Component { + render() { + const { icon, label, classes } = this.props; + return ( + + {label} + + ); + } +} + +export default injectSheet(styles)(ChangesetTagBase); diff --git a/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetTags.js b/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetTags.js new file mode 100644 index 0000000000..b8bff8ddd2 --- /dev/null +++ b/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetTags.js @@ -0,0 +1,31 @@ +//@flow +import React from "react"; +import type { Changeset} from "@scm-manager/ui-types"; +import ChangesetTag from "./ChangesetTag"; +import ChangesetTagsCollapsed from "./ChangesetTagsCollapsed"; + +type Props = { + changeset: Changeset +}; + +class ChangesetTags extends React.Component { + + getTags = () => { + const { changeset } = this.props; + return changeset._embedded.tags || []; + }; + + render() { + const tags = this.getTags(); + + if (tags.length === 1) { + return ; + } else if (tags.length > 1) { + return ; + } else { + return null; + } + } +} + +export default ChangesetTags; diff --git a/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetTagsCollapsed.js b/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetTagsCollapsed.js new file mode 100644 index 0000000000..50fb36644d --- /dev/null +++ b/scm-ui-components/packages/ui-components/src/repos/changesets/ChangesetTagsCollapsed.js @@ -0,0 +1,27 @@ +//@flow +import React from "react"; +import type { Tag } from "@scm-manager/ui-types"; +import ChangesetTagBase from "./ChangesetTagBase"; +import { translate } from "react-i18next"; +import Tooltip from "../../Tooltip"; + +type Props = { + tags: Tag[], + + // context props + t: (string) => string +}; + +class ChangesetTagsCollapsed extends React.Component { + render() { + const { tags, t } = this.props; + const message = tags.map((tag) => tag.name).join(", "); + return ( + + + + ); + } +} + +export default translate("repos")(ChangesetTagsCollapsed); diff --git a/scm-ui-components/packages/ui-components/src/repos/changesets/changesets.js b/scm-ui-components/packages/ui-components/src/repos/changesets/changesets.js index f61a89c74b..69227ad75d 100644 --- a/scm-ui-components/packages/ui-components/src/repos/changesets/changesets.js +++ b/scm-ui-components/packages/ui-components/src/repos/changesets/changesets.js @@ -1,9 +1,19 @@ // @flow +import type { Changeset, Repository } from "@scm-manager/ui-types"; + export type Description = { title: string, message: string }; +export function createChangesetLink(repository: Repository, changeset: Changeset) { + return `/repo/${repository.namespace}/${repository.name}/changeset/${changeset.id}`; +} + +export function createSourcesLink(repository: Repository, changeset: Changeset) { + return `/repo/${repository.namespace}/${repository.name}/sources/${changeset.id}`; +} + export function parseDescription(description?: string): Description { const desc = description ? description : ""; const lineBreak = desc.indexOf("\n"); diff --git a/scm-ui-components/packages/ui-components/src/repos/changesets/index.js b/scm-ui-components/packages/ui-components/src/repos/changesets/index.js index 0e7a5e533d..cede55ceca 100644 --- a/scm-ui-components/packages/ui-components/src/repos/changesets/index.js +++ b/scm-ui-components/packages/ui-components/src/repos/changesets/index.js @@ -3,8 +3,12 @@ import * as changesets from "./changesets"; export { changesets }; export { default as ChangesetAuthor } from "./ChangesetAuthor"; +export { default as ChangesetButtonGroup } from "./ChangesetButtonGroup"; +export { default as ChangesetDiff } from "./ChangesetDiff"; export { default as ChangesetId } from "./ChangesetId"; export { default as ChangesetList } from "./ChangesetList"; export { default as ChangesetRow } from "./ChangesetRow"; export { default as ChangesetTag } from "./ChangesetTag"; +export { default as ChangesetTags } from "./ChangesetTags"; +export { default as ChangesetTagsCollapsed } from "./ChangesetTagsCollapsed"; export { default as ChangesetDiff } from "./ChangesetDiff"; diff --git a/scm-ui/public/locales/de/repos.json b/scm-ui/public/locales/de/repos.json index e82edf7512..2b6fe66bb5 100644 --- a/scm-ui/public/locales/de/repos.json +++ b/scm-ui/public/locales/de/repos.json @@ -76,11 +76,15 @@ "description": "Beschreibung", "contact": "Kontakt", "date": "Datum", - "summary": "Changeset {{id}} wurde committet {{time}}" + "summary": "Changeset {{id}} wurde committet {{time}}", + "short-summary": "Committet {{id}} {{time}}" }, + "tags": "Tags", "author": { "name": "Autor", - "mail": "Mail" + "mail": "Mail", + "prefix": "Verfasst von", + "mailto": "E-Mail senden an" } }, "branch-selector": { diff --git a/scm-ui/public/locales/en/repos.json b/scm-ui/public/locales/en/repos.json index 727fe4f664..c829db54ad 100644 --- a/scm-ui/public/locales/en/repos.json +++ b/scm-ui/public/locales/en/repos.json @@ -76,11 +76,15 @@ "description": "Description", "contact": "Contact", "date": "Date", - "summary": "Changeset {{id}} was committed {{time}}" + "summary": "Changeset {{id}} was committed {{time}}", + "short-summary": "Committed {{id}} {{time}}" }, + "tags": "Tags", "author": { "name": "Author", - "mail": "Mail" + "mail": "Mail", + "prefix": "Authored by", + "mailto": "Send mail to" } }, "branch-selector": {