mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05:44 +01:00
expose sources to extensionPoint
This commit is contained in:
@@ -8,13 +8,12 @@ import { Branch, Repository } from "@scm-manager/ui-types";
|
|||||||
import Icon from "./Icon";
|
import Icon from "./Icon";
|
||||||
|
|
||||||
type Props = WithTranslation & {
|
type Props = WithTranslation & {
|
||||||
repository: Repository;
|
|
||||||
branch: Branch;
|
branch: Branch;
|
||||||
defaultBranch: Branch;
|
defaultBranch: Branch;
|
||||||
branches: Branch[];
|
|
||||||
revision: string;
|
revision: string;
|
||||||
path: string;
|
path: string;
|
||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
|
sources: File;
|
||||||
};
|
};
|
||||||
|
|
||||||
const FlexStartNav = styled.nav`
|
const FlexStartNav = styled.nav`
|
||||||
@@ -59,7 +58,7 @@ class Breadcrumb extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { baseUrl, branch, defaultBranch, branches, revision, path, repository, t } = this.props;
|
const { baseUrl, branch, defaultBranch, sources, revision, path, t } = this.props;
|
||||||
|
|
||||||
let homeUrl = baseUrl + "/";
|
let homeUrl = baseUrl + "/";
|
||||||
if (revision) {
|
if (revision) {
|
||||||
@@ -81,16 +80,14 @@ class Breadcrumb extends React.Component<Props> {
|
|||||||
</FlexStartNav>
|
</FlexStartNav>
|
||||||
{binder.hasExtension("repos.sources.actionbar") && (
|
{binder.hasExtension("repos.sources.actionbar") && (
|
||||||
<ActionWrapper>
|
<ActionWrapper>
|
||||||
|
{console.log(sources)}
|
||||||
<ExtensionPoint
|
<ExtensionPoint
|
||||||
name="repos.sources.actionbar"
|
name="repos.sources.actionbar"
|
||||||
props={{
|
props={{
|
||||||
baseUrl,
|
baseUrl,
|
||||||
branch: branch ? branch : defaultBranch,
|
branch: branch ? branch : defaultBranch,
|
||||||
path,
|
path,
|
||||||
isBranchUrl: branches
|
sources
|
||||||
? branches.filter(b => b.name.replace("/", "%2F") === revision).length > 0
|
|
||||||
: true,
|
|
||||||
repository
|
|
||||||
}}
|
}}
|
||||||
renderAll={true}
|
renderAll={true}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import {
|
|||||||
} from "../../branches/modules/branches";
|
} from "../../branches/modules/branches";
|
||||||
import { compose } from "redux";
|
import { compose } from "redux";
|
||||||
import Content from "./Content";
|
import Content from "./Content";
|
||||||
import { fetchSources, isDirectory } from "../modules/sources";
|
import {fetchSources, getSources, isDirectory} from "../modules/sources";
|
||||||
|
|
||||||
type Props = WithTranslation & {
|
type Props = WithTranslation & {
|
||||||
repository: Repository;
|
repository: Repository;
|
||||||
@@ -24,6 +24,7 @@ type Props = WithTranslation & {
|
|||||||
revision: string;
|
revision: string;
|
||||||
path: string;
|
path: string;
|
||||||
currentFileIsDirectory: boolean;
|
currentFileIsDirectory: boolean;
|
||||||
|
sources: File;
|
||||||
|
|
||||||
// dispatch props
|
// dispatch props
|
||||||
fetchBranches: (p: Repository) => void;
|
fetchBranches: (p: Repository) => void;
|
||||||
@@ -148,7 +149,7 @@ class Sources extends React.Component<Props, State> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
renderBreadcrumb = () => {
|
renderBreadcrumb = () => {
|
||||||
const { revision, path, baseUrl, branches, repository } = this.props;
|
const { revision, path, baseUrl, branches, sources } = this.props;
|
||||||
const { selectedBranch } = this.state;
|
const { selectedBranch } = this.state;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -160,8 +161,7 @@ class Sources extends React.Component<Props, State> {
|
|||||||
defaultBranch={
|
defaultBranch={
|
||||||
branches && branches.filter(b => b.defaultBranch === true)[0]
|
branches && branches.filter(b => b.defaultBranch === true)[0]
|
||||||
}
|
}
|
||||||
branches={branches}
|
sources={sources}
|
||||||
repository={repository}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -177,6 +177,7 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
const currentFileIsDirectory = decodedRevision
|
const currentFileIsDirectory = decodedRevision
|
||||||
? isDirectory(state, repository, decodedRevision, path)
|
? isDirectory(state, repository, decodedRevision, path)
|
||||||
: isDirectory(state, repository, revision, path);
|
: isDirectory(state, repository, revision, path);
|
||||||
|
const sources = getSources(state, repository, revision, path);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
repository,
|
repository,
|
||||||
@@ -185,7 +186,8 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
loading,
|
loading,
|
||||||
error,
|
error,
|
||||||
branches,
|
branches,
|
||||||
currentFileIsDirectory
|
currentFileIsDirectory,
|
||||||
|
sources
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user