mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
Merged in bugfix/new_pr_undefined_on_diff (pull request #359)
show notification if diff is empty
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -43,6 +43,7 @@ class LoadingDiff extends React.Component<Props, State> {
|
||||
|
||||
fetchDiff = () => {
|
||||
const { url } = this.props;
|
||||
this.setState({loading: true});
|
||||
apiClient
|
||||
.get(url)
|
||||
.then(response => response.text())
|
||||
|
||||
Reference in New Issue
Block a user