mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-05-07 05:16:04 +02:00
Add an extension point for contributor rows in contributor table
Co-authored-by: Rene Pfeuffer<rene.pfeuffer@cloudogu.com>
This commit is contained in:
49
scm-ui/ui-components/src/repos/changesets/Contributor.tsx
Normal file
49
scm-ui/ui-components/src/repos/changesets/Contributor.tsx
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2020 - present Cloudogu GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
import React, { FC } from "react";
|
||||
import { Person } from "@scm-manager/ui-types";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { extensionPoints, useBinder } from "@scm-manager/ui-extensions";
|
||||
import ContributorAvatar from "./ContributorAvatar";
|
||||
|
||||
const Contributor: FC<{ person: Person }> = ({ person }) => {
|
||||
const [t] = useTranslation("repos");
|
||||
const binder = useBinder();
|
||||
const avatarFactory = binder.getExtension<extensionPoints.AvatarFactory>("avatar.factory");
|
||||
let prefix = null;
|
||||
if (avatarFactory) {
|
||||
const avatar = avatarFactory(person);
|
||||
if (avatar) {
|
||||
prefix = (
|
||||
<>
|
||||
<ContributorAvatar src={avatar} alt={person.name} />{" "}
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
if (person.mail) {
|
||||
return (
|
||||
<a href={"mailto:" + person.mail} title={t("changeset.contributors.mailto") + " " + person.mail}>
|
||||
{prefix}
|
||||
{person.name}
|
||||
</a>
|
||||
);
|
||||
}
|
||||
return <>{person.name}</>;
|
||||
};
|
||||
|
||||
export default Contributor;
|
||||
33
scm-ui/ui-components/src/repos/changesets/ContributorRow.tsx
Normal file
33
scm-ui/ui-components/src/repos/changesets/ContributorRow.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2020 - present Cloudogu GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
import React, { FC } from "react";
|
||||
import styled from "styled-components";
|
||||
|
||||
const SizedTd = styled.td`
|
||||
width: 10rem;
|
||||
`;
|
||||
|
||||
const ContributorRow: FC<{ label: string }> = ({ label, children }) => {
|
||||
return (
|
||||
<tr key={label}>
|
||||
<SizedTd>{label}:</SizedTd>
|
||||
<td className="is-ellipsis-overflow m-0">{children}</td>
|
||||
</tr>
|
||||
);
|
||||
};
|
||||
|
||||
export default ContributorRow;
|
||||
@@ -31,3 +31,5 @@ export { default as ChangesetTagsCollapsed } from "./ChangesetTagsCollapsed";
|
||||
export { default as ContributorAvatar } from "./ContributorAvatar";
|
||||
export { default as SignatureIcon } from "./SignatureIcon";
|
||||
export { default as SingleChangeset } from "./SingleChangeset";
|
||||
export { default as Contributor } from "./Contributor";
|
||||
export { default as ContributorRow } from "./ContributorRow";
|
||||
|
||||
Reference in New Issue
Block a user