mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-07 05:55:44 +01:00
renaming
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// @flow
|
||||
import * as React from "react";
|
||||
import { binder } from "@scm-manager/ui-extensions";
|
||||
import { NavLink } from "../navigation";
|
||||
import { RepositoryNavLink } from "../navigation";
|
||||
import { Route } from "react-router-dom";
|
||||
import { translate } from "react-i18next";
|
||||
|
||||
@@ -10,34 +10,35 @@ class RepositoryConfigurationBinder {
|
||||
|
||||
i18nNamespace: string = "plugins";
|
||||
|
||||
bindGlobal(to: string, labelI18nKey: string, linkName: string, ConfigurationComponent: any) {
|
||||
bindRepository(to: string, labelI18nKey: string, linkName: string, RepositoryComponent: any) {
|
||||
|
||||
// create predicate based on the link name of the index resource
|
||||
// create predicate based on the link name of the current repository route
|
||||
// if the linkname is not available, the navigation link and the route are not bound to the extension points
|
||||
const configPredicate = (props: Object) => {
|
||||
const repoPredicate = (props: Object) => {
|
||||
return props.repository && props.repository._links && props.repository._links[linkName];
|
||||
};
|
||||
|
||||
// create NavigationLink with translated label
|
||||
const ConfigNavLink = translate(this.i18nNamespace)(({t, url}) => {
|
||||
return <NavLink to={url + to} label={t(labelI18nKey)} />;
|
||||
const RepoNavLink = translate(this.i18nNamespace)(({t, url}) => {
|
||||
return <RepositoryNavLink to={url + to} label={t(labelI18nKey)} />;
|
||||
});
|
||||
|
||||
// bind navigation link to extension point
|
||||
binder.bind("repository.navigation", ConfigNavLink, configPredicate);
|
||||
binder.bind("repository.navigation", RepoNavLink, repoPredicate);
|
||||
|
||||
|
||||
// route for global configuration, passes the current repository to component
|
||||
const ConfigRoute = ({ url, repository }) => {
|
||||
const RepoRoute = ({ url, repository }) => {
|
||||
return <Route path={url + to}
|
||||
render={() => <ConfigurationComponent repository={repository}/>}
|
||||
render={() => <RepositoryComponent repository={repository}/>}
|
||||
exact/>;
|
||||
};
|
||||
|
||||
// bind config route to extension point
|
||||
binder.bind("repository.route", ConfigRoute, configPredicate);
|
||||
binder.bind("repository.route", RepoRoute, repoPredicate);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
export default new RepositoryConfigurationBinder();
|
||||
|
||||
Reference in New Issue
Block a user