mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-07 14:05:44 +01:00
47 lines
947 B
JavaScript
47 lines
947 B
JavaScript
//@flow
|
|
|
|
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,
|
|
changeset: Changeset,
|
|
link: boolean
|
|
};
|
|
|
|
export default class ChangesetId extends React.Component<Props> {
|
|
static defaultProps = {
|
|
link: true
|
|
};
|
|
|
|
shortId = (changeset: Changeset) => {
|
|
return changeset.id.substr(0, 7);
|
|
};
|
|
|
|
renderLink = () => {
|
|
const { repository, changeset } = this.props;
|
|
const link = createChangesetLink(repository, changeset);
|
|
|
|
return (
|
|
<Link to={link}>
|
|
{this.shortId(changeset)}
|
|
</Link>
|
|
);
|
|
};
|
|
|
|
renderText = () => {
|
|
const { changeset } = this.props;
|
|
return this.shortId(changeset);
|
|
};
|
|
|
|
render() {
|
|
const { link } = this.props;
|
|
if (link) {
|
|
return this.renderLink();
|
|
}
|
|
return this.renderText();
|
|
}
|
|
}
|