mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 16:05:44 +01:00
add extension point
This commit is contained in:
@@ -16,6 +16,7 @@ import DownloadViewer from "../components/content/DownloadViewer";
|
|||||||
import FileSize from "../components/FileSize";
|
import FileSize from "../components/FileSize";
|
||||||
import injectSheet from "react-jss";
|
import injectSheet from "react-jss";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
|
import { ExtensionPoint, binder } from "@scm-manager/ui-extensions";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
t: string => string,
|
t: string => string,
|
||||||
@@ -67,6 +68,7 @@ class Content extends React.Component<Props, State> {
|
|||||||
const { file } = this.props;
|
const { file } = this.props;
|
||||||
getContentType(file._links.self.href)
|
getContentType(file._links.self.href)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
|
console.log(result);
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
this.setState({
|
this.setState({
|
||||||
...this.state,
|
...this.state,
|
||||||
@@ -95,8 +97,6 @@ class Content extends React.Component<Props, State> {
|
|||||||
showHeader() {
|
showHeader() {
|
||||||
const { file, classes } = this.props;
|
const { file, classes } = this.props;
|
||||||
const collapsed = this.state.collapsed;
|
const collapsed = this.state.collapsed;
|
||||||
const date = <DateFromNow date={file.lastModified} />;
|
|
||||||
|
|
||||||
const icon = collapsed ? "fa-angle-right" : "fa-angle-down";
|
const icon = collapsed ? "fa-angle-right" : "fa-angle-down";
|
||||||
const fileSize = file.directory ? "" : <FileSize bytes={file.length} />;
|
const fileSize = file.directory ? "" : <FileSize bytes={file.length} />;
|
||||||
|
|
||||||
@@ -161,7 +161,7 @@ class Content extends React.Component<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
showContent() {
|
showContent() {
|
||||||
const { file } = this.props;
|
const { file, revision } = this.props;
|
||||||
const contentType = this.state.contentType;
|
const contentType = this.state.contentType;
|
||||||
const language = this.state.language;
|
const language = this.state.language;
|
||||||
if (contentType.startsWith("image/")) {
|
if (contentType.startsWith("image/")) {
|
||||||
@@ -169,7 +169,14 @@ class Content extends React.Component<Props, State> {
|
|||||||
} else if (language) {
|
} else if (language) {
|
||||||
return <SourcecodeViewer file={file} language={language} />;
|
return <SourcecodeViewer file={file} language={language} />;
|
||||||
} else {
|
} else {
|
||||||
return <DownloadViewer file={file} />;
|
return (
|
||||||
|
<ExtensionPoint
|
||||||
|
name="repos.sources.view"
|
||||||
|
props={{ file, contentType, revision }}
|
||||||
|
>
|
||||||
|
<DownloadViewer file={file} />
|
||||||
|
</ExtensionPoint>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user