From 1c459e994473cc2381dfccab7899da6aa01264eb Mon Sep 17 00:00:00 2001 From: Florian Scholdei Date: Fri, 1 Feb 2019 16:08:33 +0100 Subject: [PATCH] renamed editusernavlink back + implemented new extension point for repo --- .../src/config/ConfigurationBinder.js | 29 ++++++++++++++++++- ...avLink.test.js => EditUserNavLink.test.js} | 0 2 files changed, 28 insertions(+), 1 deletion(-) rename scm-ui/src/users/components/navLinks/{GeneralUserNavLink.test.js => EditUserNavLink.test.js} (100%) diff --git a/scm-ui-components/packages/ui-components/src/config/ConfigurationBinder.js b/scm-ui-components/packages/ui-components/src/config/ConfigurationBinder.js index 2454ad9cea..da1372c316 100644 --- a/scm-ui-components/packages/ui-components/src/config/ConfigurationBinder.js +++ b/scm-ui-components/packages/ui-components/src/config/ConfigurationBinder.js @@ -59,7 +59,7 @@ class ConfigurationBinder { }); // bind navigation link to extension point - binder.bind("repository.subnavigation", RepoNavLink, repoPredicate); + binder.bind("repository.navigation", RepoNavLink, repoPredicate); // route for global configuration, passes the current repository to component @@ -72,6 +72,33 @@ class ConfigurationBinder { binder.bind("repository.route", RepoRoute, repoPredicate); } + bindRepositorySub(to: string, labelI18nKey: string, linkName: string, RepositoryComponent: any) { + + // 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 repoPredicate = (props: Object) => { + return props.repository && props.repository._links && props.repository._links[linkName]; + }; + + // create NavigationLink with translated label + const RepoNavLink = translate(this.i18nNamespace)(({t, url}) => { + return this.navLink(url + "/settings" + to, labelI18nKey, t); + }); + + // bind navigation link to extension point + binder.bind("repository.subnavigation", RepoNavLink, repoPredicate); + + + // route for global configuration, passes the current repository to component + const RepoRoute = ({url, repository, ...additionalProps}) => { + const link = repository._links[linkName].href; + return this.route(url + "/settings" + to, ); + }; + + // bind config route to extension point + binder.bind("repository.route", RepoRoute, repoPredicate); + } + } export default new ConfigurationBinder(); diff --git a/scm-ui/src/users/components/navLinks/GeneralUserNavLink.test.js b/scm-ui/src/users/components/navLinks/EditUserNavLink.test.js similarity index 100% rename from scm-ui/src/users/components/navLinks/GeneralUserNavLink.test.js rename to scm-ui/src/users/components/navLinks/EditUserNavLink.test.js