show notification if diff is empty

This commit is contained in:
Eduard Heimbuch
2019-11-20 13:40:40 +01:00
parent 5797b89a8a
commit 5de7d5df94
5 changed files with 24 additions and 15 deletions

View File

@@ -1,11 +1,14 @@
import React from "react";
import DiffFile from "./DiffFile";
import { DiffObjectProps, File } from "./DiffTypes";
import Notification from "../Notification";
import { WithTranslation, withTranslation } from "react-i18next";
type Props = DiffObjectProps & {
diff: File[];
defaultCollapse?: boolean;
};
type Props = WithTranslation &
DiffObjectProps & {
diff: File[];
defaultCollapse?: boolean;
};
class Diff extends React.Component<Props> {
static defaultProps: Partial<Props> = {
@@ -13,15 +16,17 @@ class Diff extends React.Component<Props> {
};
render() {
const { diff, ...fileProps } = this.props;
const { diff, t, ...fileProps } = this.props;
return (
<>
{diff.map((file, index) => (
<DiffFile key={index} file={file} {...fileProps} {...this.props} />
))}
{diff.length === 0 ? (
<Notification type="info">{t("noDiffFound")}</Notification>
) : (
diff.map((file, index) => <DiffFile key={index} file={file} {...fileProps} {...this.props} />)
)}
</>
);
}
}
export default Diff;
export default withTranslation("plugins")(Diff);