diff --git a/scm-ui-components/packages/ui-components/src/buttons/DownloadButton.js b/scm-ui-components/packages/ui-components/src/buttons/DownloadButton.js new file mode 100644 index 0000000000..3a99dc876b --- /dev/null +++ b/scm-ui-components/packages/ui-components/src/buttons/DownloadButton.js @@ -0,0 +1,25 @@ +//@flow +import React from "react"; +import Button, { type ButtonProps } from "./Button"; +import type {File} from "@scm-manager/ui-types"; + +type Props = { + displayName: string, + url: string +}; + +class DownloadButton extends React.Component { + render() { + const {displayName, url} = this.props; + return ( + + + + + {displayName} + + ); + } +} + +export default DownloadButton; diff --git a/scm-ui-components/packages/ui-components/src/buttons/index.js b/scm-ui-components/packages/ui-components/src/buttons/index.js index d7da320fc2..2e166e1d93 100644 --- a/scm-ui-components/packages/ui-components/src/buttons/index.js +++ b/scm-ui-components/packages/ui-components/src/buttons/index.js @@ -7,4 +7,4 @@ export { default as DeleteButton } from "./DeleteButton.js"; export { default as EditButton } from "./EditButton.js"; export { default as RemoveEntryOfTableButton } from "./RemoveEntryOfTableButton.js"; export { default as SubmitButton } from "./SubmitButton.js"; - +export {default as DownloadButton} from "./DownloadButton.js"; diff --git a/scm-ui/public/locales/en/repos.json b/scm-ui/public/locales/en/repos.json index 60ee220318..d4fd950c45 100644 --- a/scm-ui/public/locales/en/repos.json +++ b/scm-ui/public/locales/en/repos.json @@ -51,7 +51,11 @@ "name": "Name", "length": "Length", "lastModified": "Last modified", - "description": "Description" + "description": "Description", + "branch": "Branch" + }, + "content": { + "downloadButton": "Download" } }, "changesets": { diff --git a/scm-ui/src/repos/sources/components/content/DownloadViewer.js b/scm-ui/src/repos/sources/components/content/DownloadViewer.js index 9f5e9cdf75..d9a96fd886 100644 --- a/scm-ui/src/repos/sources/components/content/DownloadViewer.js +++ b/scm-ui/src/repos/sources/components/content/DownloadViewer.js @@ -1,28 +1,52 @@ // @flow 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"; type Props = { - t: string => string + t: string => string, + file: File, + revision: string }; -type State = { - content: string -}; - -class DownloadViewer extends React.Component { - constructor(props: Props) { - super(props); - - this.state = { - content: "" - }; - } - - componentDidMount() {} - +class DownloadViewer extends React.Component { render() { - return "DownloadViewer"; + const { t, file, revision } = 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 d8e536e0e1..9506e637aa 100644 --- a/scm-ui/src/repos/sources/containers/Content.js +++ b/scm-ui/src/repos/sources/containers/Content.js @@ -68,7 +68,7 @@ class Content extends React.Component { } render() { - const { file } = this.props; + const { file, revision } = this.props; const contentType = this.state.contentType; const error = this.state.error; const hasError = this.state.hasError; @@ -87,7 +87,7 @@ class Content extends React.Component { return ; } - return ; + return ; } }