hide contributor table behind toggle

This commit is contained in:
Sebastian Sdorra
2020-06-09 16:13:05 +02:00
parent 4890d5528f
commit 27db6c5b4a
2 changed files with 39 additions and 11 deletions

View File

@@ -50,6 +50,9 @@ const AvatarImage = styled(Image)`
width: 1em; width: 1em;
height: 1em; height: 1em;
margin-right: 0.25em; margin-right: 0.25em;
vertical-align: middle !important;
margin-bottom: 0.2em;
border-radius: 0.25em;
`; `;
type PersonAvatarProps = { type PersonAvatarProps = {
@@ -134,7 +137,7 @@ const ChangesetAuthor: FC<Props> = ({ changeset }) => {
return filterTrailersByType("Co-authored-by"); return filterTrailersByType("Co-authored-by");
}; };
const getCommiters = () => { const getCommitters = () => {
return filterTrailersByType("Committed-by"); return filterTrailersByType("Committed-by");
}; };
@@ -153,25 +156,24 @@ const ChangesetAuthor: FC<Props> = ({ changeset }) => {
); );
} }
const commiters = getCommiters(); const commiters = getCommitters();
if (commiters.length > 0) { if (commiters.length > 0) {
authorLine.push(<Persons persons={commiters} label={"changesets.authors.committedBy"} />); authorLine.push(<Persons persons={commiters} label={"changesets.authors.committedBy"} />);
} }
const coAuthors = getCoAuthors(); const coAuthors = getCoAuthors();
if (coAuthors.length > 0) { if (coAuthors.length > 0) {
authorLine.push(<Persons persons={coAuthors} label={"changesets.authors.coAuthoredBy"} />); authorLine.push(<Persons persons={coAuthors} label={"changesets.authors.coAuthoredBy"} />);
} }
// extensions // extensions
const extensions = binder.getExtensions("changesets.author.suffix", { changeset }); const extensions = binder.getExtensions("changesets.author.suffix", { changeset });
if (extensions) { if (extensions) {
coAuthors.push(...extensions); coAuthors.push(...extensions);
} }
return ( return (
<span style={{ verticalAlign: "middle" }}> <>
{authorLine.map((p, i) => { {authorLine.map((p, i) => {
if (i === 0) { if (i === 0) {
return <>{p}</>; return <>{p}</>;
@@ -186,7 +188,7 @@ const ChangesetAuthor: FC<Props> = ({ changeset }) => {
return <>, {p}</>; return <>, {p}</>;
} }
})} })}
</span> </>
); );
}; };

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*/ */
import React from "react"; import React, { FC, useState } from "react";
import { Trans, WithTranslation, withTranslation } from "react-i18next"; import { Trans, WithTranslation, withTranslation } from "react-i18next";
import classNames from "classnames"; import classNames from "classnames";
import styled from "styled-components"; import styled from "styled-components";
@@ -31,12 +31,14 @@ import {
AvatarImage, AvatarImage,
AvatarWrapper, AvatarWrapper,
Button, Button,
ChangesetAuthor,
ChangesetDiff, ChangesetDiff,
ChangesetId, ChangesetId,
changesets, changesets,
ChangesetTag, ChangesetTag,
DateFromNow, DateFromNow,
Level Level,
Icon
} from "@scm-manager/ui-components"; } from "@scm-manager/ui-components";
import ContributorTable from "./ContributorTable"; import ContributorTable from "./ContributorTable";
@@ -63,6 +65,31 @@ const BottomMarginLevel = styled(Level)`
margin-bottom: 1rem !important; margin-bottom: 1rem !important;
`; `;
const countContributors = (changeset: Changeset) => {
return changeset.trailers.length + 1;
};
const Contributors: FC<{ changeset: Changeset }> = ({ changeset }) => {
const [open, setOpen] = useState(false);
return (
<>
<div className="level has-cursor-pointer" onClick={e => setOpen(!open)}>
<div className="level-left">
<p>
<Icon name={open ? "angle-down" : "angle-right"} /> <ChangesetAuthor changeset={changeset} />
</p>
</div>
<div className="level-right">
<p>
(<span className="has-text-link">{countContributors(changeset)} Contributors</span>)
</p>
</div>
</div>
{open && <ContributorTable changeset={changeset} />}
</>
);
};
class ChangesetDetails extends React.Component<Props, State> { class ChangesetDetails extends React.Component<Props, State> {
constructor(props: Props) { constructor(props: Props) {
super(props); super(props);
@@ -101,14 +128,13 @@ class ChangesetDetails extends React.Component<Props, State> {
</RightMarginP> </RightMarginP>
</AvatarWrapper> </AvatarWrapper>
<div className="media-content"> <div className="media-content">
<ContributorTable changeset={changeset} /> <Contributors changeset={changeset} />
<p> <p>
<Trans i18nKey="repos:changeset.summary" components={[id, date]} /> <Trans i18nKey="repos:changeset.summary" components={[id, date]} />
</p> </p>
</div> </div>
<div className="media-right">{this.renderTags()}</div> <div className="media-right">{this.renderTags()}</div>
</article> </article>
<p> <p>
{description.message.split("\n").map((item, key) => { {description.message.split("\n").map((item, key) => {
return ( return (