added no sources found notification

This commit is contained in:
Florian Scholdei
2019-04-09 15:31:12 +02:00
parent 818076ac6f
commit 4a6fd9721f
4 changed files with 49 additions and 47 deletions

View File

@@ -108,7 +108,8 @@
"lastModified": "Zuletzt bearbeitet", "lastModified": "Zuletzt bearbeitet",
"description": "Beschreibung", "description": "Beschreibung",
"size": "Größe" "size": "Größe"
} },
"noSources": "Keine Sources gefunden."
}, },
"permission": { "permission": {
"title": "Berechtigungen bearbeiten", "title": "Berechtigungen bearbeiten",

View File

@@ -108,7 +108,8 @@
"lastModified": "Last modified", "lastModified": "Last modified",
"description": "Description", "description": "Description",
"size": "Size" "size": "Size"
} },
"noSources": "No sources found."
}, },
"permission": { "permission": {
"title": "Edit Permissions", "title": "Edit Permissions",

View File

@@ -5,7 +5,11 @@ import { connect } from "react-redux";
import injectSheet from "react-jss"; import injectSheet from "react-jss";
import FileTreeLeaf from "./FileTreeLeaf"; import FileTreeLeaf from "./FileTreeLeaf";
import type { Repository, File } from "@scm-manager/ui-types"; 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 { import {
getFetchSourcesFailure, getFetchSourcesFailure,
isFetchSourcesPending, isFetchSourcesPending,
@@ -48,16 +52,34 @@ export function findParent(path: string) {
class FileTree extends React.Component<Props> { class FileTree extends React.Component<Props> {
render() { render() {
const { const { error, loading, tree } = this.props;
error,
loading, if (error) {
tree, return <ErrorNotification error={error} />;
revision, }
path,
baseUrl, if (loading) {
classes, return <Loading />;
t }
} = this.props; 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 { const compareFiles = function(f1: File, f2: File): number {
if (f1.directory) { 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) { if (tree._embedded && tree._embedded.children) {
files.push(...tree._embedded.children.sort(compareFiles)); files.push(...tree._embedded.children.sort(compareFiles));
} }
if (files && files.length > 0) {
let baseUrlWithRevision = baseUrl; let baseUrlWithRevision = baseUrl;
if (revision) { if (revision) {
baseUrlWithRevision += "/" + encodeURIComponent(revision); baseUrlWithRevision += "/" + encodeURIComponent(revision);
@@ -108,7 +110,6 @@ class FileTree extends React.Component<Props> {
} }
return ( return (
<div className="panel-block">
<table className="table table-hover table-sm is-fullwidth"> <table className="table table-hover table-sm is-fullwidth">
<thead> <thead>
<tr> <tr>
@@ -135,9 +136,10 @@ class FileTree extends React.Component<Props> {
))} ))}
</tbody> </tbody>
</table> </table>
</div>
); );
} }
return <Notification type="info">{t("sources.noSources")}</Notification>;
}
} }
const mapStateToProps = (state: any, ownProps: Props) => { const mapStateToProps = (state: any, ownProps: Props) => {

View File

@@ -94,9 +94,7 @@ class Sources extends React.Component<Props> {
if (currentFileIsDirectory) { if (currentFileIsDirectory) {
return ( return (
<div className="panel"> <div className="panel">
<div className="panel-heading"> <div className="panel-heading">{this.renderBranchSelector()}</div>
{this.renderBranchSelector()}
</div>
<FileTree <FileTree
repository={repository} repository={repository}
revision={revision} revision={revision}