diff --git a/scm-ui/ui-webapp/src/repos/sources/components/content/MarkdownViewer.tsx b/scm-ui/ui-webapp/src/repos/sources/components/content/MarkdownViewer.tsx index ce0eba4198..0ee70d5684 100644 --- a/scm-ui/ui-webapp/src/repos/sources/components/content/MarkdownViewer.tsx +++ b/scm-ui/ui-webapp/src/repos/sources/components/content/MarkdownViewer.tsx @@ -29,13 +29,14 @@ import styled from "styled-components"; type Props = { file: File; + basePath: string; }; const MarkdownContent = styled.div` padding: 0.5rem; `; -const MarkdownViewer: FC = ({ file }) => { +const MarkdownViewer: FC = ({ file, basePath }) => { const [loading, setLoading] = useState(true); const [error, setError] = useState(undefined); const [content, setContent] = useState(""); @@ -62,7 +63,7 @@ const MarkdownViewer: FC = ({ file }) => { return ( - + ); }; diff --git a/scm-ui/ui-webapp/src/repos/sources/components/content/SwitchableMarkdownViewer.tsx b/scm-ui/ui-webapp/src/repos/sources/components/content/SwitchableMarkdownViewer.tsx index 7a14bb75b4..e194667894 100644 --- a/scm-ui/ui-webapp/src/repos/sources/components/content/SwitchableMarkdownViewer.tsx +++ b/scm-ui/ui-webapp/src/repos/sources/components/content/SwitchableMarkdownViewer.tsx @@ -21,13 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -import React, { FC, useState } from "react"; +import React, {FC, useState} from "react"; import styled from "styled-components"; import MarkdownViewer from "./MarkdownViewer"; import SourcecodeViewer from "./SourcecodeViewer"; -import { File } from "@scm-manager/ui-types"; -import { Button } from "@scm-manager/ui-components"; -import { useTranslation } from "react-i18next"; +import {File} from "@scm-manager/ui-types"; +import {Button} from "@scm-manager/ui-components"; +import {useTranslation} from "react-i18next"; const ToggleButton = styled(Button)` max-width: 1rem; @@ -43,10 +43,11 @@ const Container = styled.div` type Props = { file: File; + basePath: string; }; -const SwitchableMarkdownViewer: FC = ({ file }) => { - const { t } = useTranslation("repos"); +const SwitchableMarkdownViewer: FC = ({file, basePath}) => { + const {t} = useTranslation("repos"); const [renderMarkdown, setRenderMarkdown] = useState(true); const toggleMarkdown = () => { @@ -64,9 +65,10 @@ const SwitchableMarkdownViewer: FC = ({ file }) => { : t("sources.content.toggleButton.showMarkdown") } > - + - {renderMarkdown ? : } + {renderMarkdown ? : + } ); }; diff --git a/scm-ui/ui-webapp/src/repos/sources/containers/SourcesView.tsx b/scm-ui/ui-webapp/src/repos/sources/containers/SourcesView.tsx index 1b7b26479b..417525c5f6 100644 --- a/scm-ui/ui-webapp/src/repos/sources/containers/SourcesView.tsx +++ b/scm-ui/ui-webapp/src/repos/sources/containers/SourcesView.tsx @@ -76,13 +76,19 @@ class SourcesView extends React.Component { }); } + createBasePath() { + const { repository, revision } = this.props; + return `/repo/${repository.namespace}/${repository.name}/code/sources/${revision}/`; + } + showSources() { const { file, revision } = this.props; const { contentType, language } = this.state; + const basePath = this.createBasePath(); if (contentType.startsWith("image/")) { return ; } else if (contentType.includes("markdown")) { - return ; + return ; } else if (language) { return ; } else if (contentType.startsWith("text/")) { @@ -94,7 +100,8 @@ class SourcesView extends React.Component { props={{ file, contentType, - revision + revision, + basePath }} >