Merged in bugfix/new_pr_undefined_on_diff (pull request #359)

show notification if diff is empty
This commit is contained in:
Rene Pfeuffer
2019-11-20 15:37:42 +00:00
5 changed files with 24 additions and 15 deletions

View File

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

View File

@@ -43,6 +43,7 @@ class LoadingDiff extends React.Component<Props, State> {
fetchDiff = () => { fetchDiff = () => {
const { url } = this.props; const { url } = this.props;
this.setState({loading: true});
apiClient apiClient
.get(url) .get(url)
.then(response => response.text()) .then(response => response.text())

View File

@@ -202,5 +202,6 @@
"CustomNamespaceStrategy": "Benutzerdefiniert", "CustomNamespaceStrategy": "Benutzerdefiniert",
"CurrentYearNamespaceStrategy": "Aktuelles Jahr", "CurrentYearNamespaceStrategy": "Aktuelles Jahr",
"RepositoryTypeNamespaceStrategy": "Repository Typ" "RepositoryTypeNamespaceStrategy": "Repository Typ"
} },
"noDiffFound": "Kein Diff zwischen den ausgewählten Branches gefunden."
} }

View File

@@ -202,5 +202,6 @@
"CustomNamespaceStrategy": "Custom", "CustomNamespaceStrategy": "Custom",
"CurrentYearNamespaceStrategy": "Current year", "CurrentYearNamespaceStrategy": "Current year",
"RepositoryTypeNamespaceStrategy": "Repository type" "RepositoryTypeNamespaceStrategy": "Repository type"
} },
"noDiffFound": "No Diff between the selected branches found."
} }

View File

@@ -182,5 +182,6 @@
"CustomNamespaceStrategy": "Personalizar", "CustomNamespaceStrategy": "Personalizar",
"CurrentYearNamespaceStrategy": "Año actual", "CurrentYearNamespaceStrategy": "Año actual",
"RepositoryTypeNamespaceStrategy": "Tipo de repositorio" "RepositoryTypeNamespaceStrategy": "Tipo de repositorio"
} },
"noDiffFound": "No se encontraron diferencias entre las ramas seleccionadas."
} }