2019-10-20 16:59:02 +02:00
|
|
|
import React from "react";
|
|
|
|
|
import DiffFile from "./DiffFile";
|
|
|
|
|
import { DiffObjectProps, File } from "./DiffTypes";
|
2019-11-20 13:40:40 +01:00
|
|
|
import Notification from "../Notification";
|
|
|
|
|
import { WithTranslation, withTranslation } from "react-i18next";
|
2018-12-11 13:25:35 +01:00
|
|
|
|
2019-11-20 13:40:40 +01:00
|
|
|
type Props = WithTranslation &
|
|
|
|
|
DiffObjectProps & {
|
|
|
|
|
diff: File[];
|
|
|
|
|
defaultCollapse?: boolean;
|
|
|
|
|
};
|
2018-12-11 13:25:35 +01:00
|
|
|
|
|
|
|
|
class Diff extends React.Component<Props> {
|
2019-10-20 16:59:02 +02:00
|
|
|
static defaultProps: Partial<Props> = {
|
|
|
|
|
sideBySide: false
|
2018-12-11 13:25:35 +01:00
|
|
|
};
|
|
|
|
|
|
2019-02-26 15:00:05 +01:00
|
|
|
render() {
|
2019-11-20 13:40:40 +01:00
|
|
|
const { diff, t, ...fileProps } = this.props;
|
2018-12-11 13:25:35 +01:00
|
|
|
return (
|
2019-02-26 15:00:05 +01:00
|
|
|
<>
|
2019-11-20 13:40:40 +01:00
|
|
|
{diff.length === 0 ? (
|
|
|
|
|
<Notification type="info">{t("noDiffFound")}</Notification>
|
|
|
|
|
) : (
|
|
|
|
|
diff.map((file, index) => <DiffFile key={index} file={file} {...fileProps} {...this.props} />)
|
|
|
|
|
)}
|
2019-02-26 15:00:05 +01:00
|
|
|
</>
|
2018-12-11 13:25:35 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-20 13:40:40 +01:00
|
|
|
export default withTranslation("plugins")(Diff);
|