From 4a6fd9721fc136b5cd193e8882d6534f786a9f02 Mon Sep 17 00:00:00 2001 From: Florian Scholdei Date: Tue, 9 Apr 2019 15:31:12 +0200 Subject: [PATCH] added no sources found notification --- scm-ui/public/locales/de/repos.json | 3 +- scm-ui/public/locales/en/repos.json | 3 +- .../src/repos/sources/components/FileTree.js | 86 ++++++++++--------- .../src/repos/sources/containers/Sources.js | 4 +- 4 files changed, 49 insertions(+), 47 deletions(-) diff --git a/scm-ui/public/locales/de/repos.json b/scm-ui/public/locales/de/repos.json index 0a42e49b6f..4093d1c2e0 100644 --- a/scm-ui/public/locales/de/repos.json +++ b/scm-ui/public/locales/de/repos.json @@ -108,7 +108,8 @@ "lastModified": "Zuletzt bearbeitet", "description": "Beschreibung", "size": "Größe" - } + }, + "noSources": "Keine Sources gefunden." }, "permission": { "title": "Berechtigungen bearbeiten", diff --git a/scm-ui/public/locales/en/repos.json b/scm-ui/public/locales/en/repos.json index 8b245cb2a6..44d2e09468 100644 --- a/scm-ui/public/locales/en/repos.json +++ b/scm-ui/public/locales/en/repos.json @@ -108,7 +108,8 @@ "lastModified": "Last modified", "description": "Description", "size": "Size" - } + }, + "noSources": "No sources found." }, "permission": { "title": "Edit Permissions", diff --git a/scm-ui/src/repos/sources/components/FileTree.js b/scm-ui/src/repos/sources/components/FileTree.js index 18ef1b01c5..960f6b42d6 100644 --- a/scm-ui/src/repos/sources/components/FileTree.js +++ b/scm-ui/src/repos/sources/components/FileTree.js @@ -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 { render() { - const { - error, - loading, - tree, - revision, - path, - baseUrl, - classes, - t - } = this.props; + const { error, loading, tree } = this.props; + + if (error) { + return ; + } + + if (loading) { + return ; + } + if (!tree) { + return null; + } + + return
{this.renderSourcesTable()}
; + } + + 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,40 +97,19 @@ class FileTree extends React.Component { } }; - if (error) { - return ; - } - - if (loading) { - return ; - } - 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)); } - let baseUrlWithRevision = baseUrl; - if (revision) { - baseUrlWithRevision += "/" + encodeURIComponent(revision); - } else { - baseUrlWithRevision += "/" + encodeURIComponent(tree.revision); - } + if (files && files.length > 0) { + let baseUrlWithRevision = baseUrl; + if (revision) { + baseUrlWithRevision += "/" + encodeURIComponent(revision); + } else { + baseUrlWithRevision += "/" + encodeURIComponent(tree.revision); + } - return ( -
+ return ( @@ -135,8 +136,9 @@ class FileTree extends React.Component { ))}
-
- ); + ); + } + return {t("sources.noSources")}; } } diff --git a/scm-ui/src/repos/sources/containers/Sources.js b/scm-ui/src/repos/sources/containers/Sources.js index 7b87776e73..2d7e1ca468 100644 --- a/scm-ui/src/repos/sources/containers/Sources.js +++ b/scm-ui/src/repos/sources/containers/Sources.js @@ -94,9 +94,7 @@ class Sources extends React.Component { if (currentFileIsDirectory) { return (
-
- {this.renderBranchSelector()} -
+
{this.renderBranchSelector()}