mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-07 05:55:44 +01:00
38 lines
894 B
JavaScript
38 lines
894 B
JavaScript
//@flow
|
|
import React from "react";
|
|
import type { Changeset } from "@scm-manager/ui-types";
|
|
import LoadingDiff from "../LoadingDiff";
|
|
import Notification from "../../Notification";
|
|
import {translate} from "react-i18next";
|
|
|
|
type Props = {
|
|
changeset: Changeset,
|
|
|
|
// context props
|
|
t: string => string
|
|
};
|
|
|
|
class ChangesetDiff extends React.Component<Props> {
|
|
|
|
isDiffSupported(changeset: Changeset) {
|
|
return !!changeset._links.diff;
|
|
}
|
|
|
|
createUrl(changeset: Changeset) {
|
|
return changeset._links.diff.href + "?format=GIT";
|
|
}
|
|
|
|
render() {
|
|
const { changeset, t } = this.props;
|
|
if (!this.isDiffSupported(changeset)) {
|
|
return <Notification type="danger">{t("changesets.diff.not-supported")}</Notification>;
|
|
} else {
|
|
const url = this.createUrl(changeset);
|
|
return <LoadingDiff url={url} />;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
export default translate("repos")(ChangesetDiff);
|