open correct viewer for each type and reorder the structure

This commit is contained in:
Maren Süwer
2018-10-25 14:03:45 +02:00
parent bfdb58797b
commit 36f289a153
7 changed files with 26 additions and 10 deletions

View File

@@ -22,7 +22,7 @@ class DownloadViewer extends React.Component<Props, State> {
componentDidMount() {} componentDidMount() {}
render() { render() {
return null; return "DownloadViewer";
} }
} }

View File

@@ -22,7 +22,7 @@ class ImageViewer extends React.Component<Props, State> {
componentDidMount() {} componentDidMount() {}
render() { render() {
return null; return "ImageViewer";
} }
} }

View File

@@ -1,7 +1,7 @@
// @flow // @flow
import React from "react"; import React from "react";
import { translate } from "react-i18next"; import { translate } from "react-i18next";
import { apiClient } from "@scm-manager/ui-components"; import { apiClient } from "../../../../../../scm-ui-components/packages/ui-components/src/index";
type Props = { type Props = {
t: string => string t: string => string
@@ -23,7 +23,7 @@ class SourcecodeViewer extends React.Component<Props, State> {
componentDidMount() {} componentDidMount() {}
render() { render() {
return null; return "sourceCodeViewer";
} }
} }

View File

@@ -1,11 +1,20 @@
// @flow // @flow
import React from "react"; import React from "react";
import { translate } from "react-i18next"; import { translate } from "react-i18next";
import { apiClient } from "@scm-manager/ui-components"; import { apiClient } from "../../../../../scm-ui-components/packages/ui-components/src/index";
import { getSources } from "../../sources/modules/sources"; import { getSources } from "../modules/sources";
import type { Repository, File } from "@scm-manager/ui-types"; import type {
import { ErrorNotification, Loading } from "@scm-manager/ui-components"; Repository,
File
} from "../../../../../scm-ui-components/packages/ui-types/src/index";
import {
ErrorNotification,
Loading
} from "../../../../../scm-ui-components/packages/ui-components/src/index";
import { connect } from "react-redux"; import { connect } from "react-redux";
import ImageViewer from "../components/content/ImageViewer";
import SourcecodeViewer from "../components/content/SourcecodeViewer";
import DownloadViewer from "../components/content/DownloadViewer";
type Props = { type Props = {
t: string => string, t: string => string,
@@ -49,8 +58,15 @@ class Content extends React.Component<Props, State> {
if (!file) { if (!file) {
return <Loading />; return <Loading />;
} }
if (contentType.startsWith("image")) {
return <ImageViewer />;
}
return this.state.contentType; if (contentType.startsWith("text")) {
return <SourcecodeViewer />;
}
return <DownloadViewer />;
} }
} }

View File

@@ -13,7 +13,7 @@ import {
isFetchBranchesPending isFetchBranchesPending
} from "../../modules/branches"; } from "../../modules/branches";
import { compose } from "redux"; import { compose } from "redux";
import Content from "../../content/components/Content"; import Content from "./Content";
import { fetchSources, isDirectory } from "../modules/sources"; import { fetchSources, isDirectory } from "../modules/sources";
type Props = { type Props = {