mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05:44 +01:00
added no sources found notification
This commit is contained in:
@@ -108,7 +108,8 @@
|
||||
"lastModified": "Zuletzt bearbeitet",
|
||||
"description": "Beschreibung",
|
||||
"size": "Größe"
|
||||
}
|
||||
},
|
||||
"noSources": "Keine Sources gefunden."
|
||||
},
|
||||
"permission": {
|
||||
"title": "Berechtigungen bearbeiten",
|
||||
|
||||
@@ -108,7 +108,8 @@
|
||||
"lastModified": "Last modified",
|
||||
"description": "Description",
|
||||
"size": "Size"
|
||||
}
|
||||
},
|
||||
"noSources": "No sources found."
|
||||
},
|
||||
"permission": {
|
||||
"title": "Edit Permissions",
|
||||
|
||||
@@ -5,7 +5,11 @@ import { connect } from "react-redux";
|
||||
import injectSheet from "react-jss";
|
||||
import FileTreeLeaf from "./FileTreeLeaf";
|
||||
import type { Repository, File } from "@scm-manager/ui-types";
|
||||
import { ErrorNotification, Loading } from "@scm-manager/ui-components";
|
||||
import {
|
||||
ErrorNotification,
|
||||
Loading,
|
||||
Notification
|
||||
} from "@scm-manager/ui-components";
|
||||
import {
|
||||
getFetchSourcesFailure,
|
||||
isFetchSourcesPending,
|
||||
@@ -48,16 +52,34 @@ export function findParent(path: string) {
|
||||
|
||||
class FileTree extends React.Component<Props> {
|
||||
render() {
|
||||
const {
|
||||
error,
|
||||
loading,
|
||||
tree,
|
||||
revision,
|
||||
path,
|
||||
baseUrl,
|
||||
classes,
|
||||
t
|
||||
} = this.props;
|
||||
const { error, loading, tree } = this.props;
|
||||
|
||||
if (error) {
|
||||
return <ErrorNotification error={error} />;
|
||||
}
|
||||
|
||||
if (loading) {
|
||||
return <Loading />;
|
||||
}
|
||||
if (!tree) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <div className="panel-block">{this.renderSourcesTable()}</div>;
|
||||
}
|
||||
|
||||
renderSourcesTable() {
|
||||
const { tree, revision, path, baseUrl, classes, t } = this.props;
|
||||
|
||||
const files = [];
|
||||
|
||||
if (path) {
|
||||
files.push({
|
||||
name: "..",
|
||||
path: findParent(path),
|
||||
directory: true
|
||||
});
|
||||
}
|
||||
|
||||
const compareFiles = function(f1: File, f2: File): number {
|
||||
if (f1.directory) {
|
||||
@@ -75,31 +97,11 @@ class FileTree extends React.Component<Props> {
|
||||
}
|
||||
};
|
||||
|
||||
if (error) {
|
||||
return <ErrorNotification error={error} />;
|
||||
}
|
||||
|
||||
if (loading) {
|
||||
return <Loading />;
|
||||
}
|
||||
if (!tree) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const files = [];
|
||||
|
||||
if (path) {
|
||||
files.push({
|
||||
name: "..",
|
||||
path: findParent(path),
|
||||
directory: true
|
||||
});
|
||||
}
|
||||
|
||||
if (tree._embedded && tree._embedded.children) {
|
||||
files.push(...tree._embedded.children.sort(compareFiles));
|
||||
}
|
||||
|
||||
if (files && files.length > 0) {
|
||||
let baseUrlWithRevision = baseUrl;
|
||||
if (revision) {
|
||||
baseUrlWithRevision += "/" + encodeURIComponent(revision);
|
||||
@@ -108,7 +110,6 @@ class FileTree extends React.Component<Props> {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="panel-block">
|
||||
<table className="table table-hover table-sm is-fullwidth">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -135,9 +136,10 @@ class FileTree extends React.Component<Props> {
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return <Notification type="info">{t("sources.noSources")}</Notification>;
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state: any, ownProps: Props) => {
|
||||
|
||||
@@ -94,9 +94,7 @@ class Sources extends React.Component<Props> {
|
||||
if (currentFileIsDirectory) {
|
||||
return (
|
||||
<div className="panel">
|
||||
<div className="panel-heading">
|
||||
{this.renderBranchSelector()}
|
||||
</div>
|
||||
<div className="panel-heading">{this.renderBranchSelector()}</div>
|
||||
<FileTree
|
||||
repository={repository}
|
||||
revision={revision}
|
||||
|
||||
Reference in New Issue
Block a user