From 463a93553deedb6463e358551c83fe8b0cd137f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maren=20S=C3=BCwer?= Date: Mon, 29 Oct 2018 09:32:30 +0100 Subject: [PATCH] refactoring content view --- .../components/content/DownloadViewer.js | 38 ++------- .../src/repos/sources/containers/Content.js | 77 +++++++++++++++---- 2 files changed, 69 insertions(+), 46 deletions(-) diff --git a/scm-ui/src/repos/sources/components/content/DownloadViewer.js b/scm-ui/src/repos/sources/components/content/DownloadViewer.js index d9a96fd886..b902c1f0b3 100644 --- a/scm-ui/src/repos/sources/components/content/DownloadViewer.js +++ b/scm-ui/src/repos/sources/components/content/DownloadViewer.js @@ -2,7 +2,7 @@ import React from "react"; import { translate } from "react-i18next"; import type { File } from "@scm-manager/ui-types"; -import { DownloadButton, DateFromNow } from "@scm-manager/ui-components"; +import { DownloadButton } from "@scm-manager/ui-components"; type Props = { t: string => string, @@ -12,39 +12,13 @@ type Props = { class DownloadViewer extends React.Component { render() { - const { t, file, revision } = this.props; + const { t, file } = this.props; return (
-
-
-

{file.name}

-
-
-
- -
-
- - - - - - - - - - - - - - - -
{t("sources.description")}{file.description}
{t("sources.lastModified")} - -
{t("sources.branch")}{revision}
+
); } diff --git a/scm-ui/src/repos/sources/containers/Content.js b/scm-ui/src/repos/sources/containers/Content.js index 9506e637aa..68e02aece2 100644 --- a/scm-ui/src/repos/sources/containers/Content.js +++ b/scm-ui/src/repos/sources/containers/Content.js @@ -1,20 +1,23 @@ // @flow import React from "react"; -import { translate } from "react-i18next"; +import { Interpolate, translate } from "react-i18next"; import { apiClient } from "@scm-manager/ui-components"; import { getSources } from "../modules/sources"; -import type { - Repository, - File -} from "@scm-manager/ui-types"; +import type { Repository, File } from "@scm-manager/ui-types"; import { ErrorNotification, - Loading + Loading, + DateFromNow } from "@scm-manager/ui-components"; import { connect } from "react-redux"; import ImageViewer from "../components/content/ImageViewer"; import SourcecodeViewer from "../components/content/SourcecodeViewer"; import DownloadViewer from "../components/content/DownloadViewer"; +import FileSize from "../components/FileSize"; +import AvatarWrapper from "../../components/changesets/AvatarWrapper"; +import classNames from "classnames"; +import AvatarImage from "../../components/changesets/AvatarImage"; +import ChangesetAuthor from "../../components/changesets/ChangesetAuthor"; type Props = { t: string => string, @@ -67,9 +70,47 @@ class Content extends React.Component { .catch(err => {}); } - render() { + showHeader() { + const { file, revision, t } = this.props; + const date = ; + const fileSize = file.directory ? "" : ; + + return ( +
+

{file.name}

+
+
+

+ {file.description.split("\n").map((item, key) => { + return ( + + {item} +
+
+ ); + })} +

+
+
{date}
+
+
+ ); + } + + showContent() { const { file, revision } = this.props; const contentType = this.state.contentType; + if (contentType.startsWith("image")) { + return ; + } else if (contentType.startsWith("text")) { + return ; + } else { + return ; + } + } + + render() { + const { file } = this.props; const error = this.state.error; const hasError = this.state.hasError; @@ -79,15 +120,23 @@ class Content extends React.Component { if (hasError) { return ; } - if (contentType.startsWith("image")) { - return ; - } - if (contentType.startsWith("text")) { - return ; - } + const header = this.showHeader(); + const content = this.showContent(); + const fileSize = file.directory ? "" : ; - return ; + return ( +
+ {header} + +
+ ); } }