merge with branch feature/changes-for-script-plugin

This commit is contained in:
Sebastian Sdorra
2019-01-11 13:49:02 +01:00
4 changed files with 44 additions and 30 deletions

View File

@@ -57,6 +57,14 @@ class PrimaryNavigation extends React.Component<Props> {
append("/groups", "/(group|groups)", "primary-navigation.groups", "groups"); append("/groups", "/(group|groups)", "primary-navigation.groups", "groups");
append("/config", "/config", "primary-navigation.config", "config"); append("/config", "/config", "primary-navigation.config", "config");
navigationItems.push(
<ExtensionPoint
name="primary-navigation"
renderAll={true}
props={{links: this.props.links}}
/>
);
this.appendLogout(navigationItems, append); this.appendLogout(navigationItems, append);
return navigationItems; return navigationItems;

View File

@@ -79,7 +79,7 @@ class App extends Component<Props> {
/> />
); );
} else { } else {
content = <Main authenticated={authenticated} />; content = <Main authenticated={authenticated} links={links} />;
} }
return ( return (
<div className="App"> <div className="App">

View File

@@ -2,6 +2,7 @@
import React from "react"; import React from "react";
import { Redirect, Route, Switch, withRouter } from "react-router-dom"; import { Redirect, Route, Switch, withRouter } from "react-router-dom";
import type {Links} from "@scm-manager/ui-types";
import Overview from "../repos/containers/Overview"; import Overview from "../repos/containers/Overview";
import Users from "../users/containers/Users"; import Users from "../users/containers/Users";
@@ -9,6 +10,8 @@ import Login from "../containers/Login";
import Logout from "../containers/Logout"; import Logout from "../containers/Logout";
import { ProtectedRoute } from "@scm-manager/ui-components"; import { ProtectedRoute } from "@scm-manager/ui-components";
import { ExtensionPoint } from "@scm-manager/ui-extensions";
import AddUser from "../users/containers/AddUser"; import AddUser from "../users/containers/AddUser";
import SingleUser from "../users/containers/SingleUser"; import SingleUser from "../users/containers/SingleUser";
import RepositoryRoot from "../repos/containers/RepositoryRoot"; import RepositoryRoot from "../repos/containers/RepositoryRoot";
@@ -22,12 +25,13 @@ import Config from "../config/containers/Config";
import Profile from "./Profile"; import Profile from "./Profile";
type Props = { type Props = {
authenticated?: boolean authenticated?: boolean,
links: Links
}; };
class Main extends React.Component<Props> { class Main extends React.Component<Props> {
render() { render() {
const { authenticated } = this.props; const { authenticated, links } = this.props;
return ( return (
<div className="main"> <div className="main">
<Switch> <Switch>
@@ -112,6 +116,12 @@ class Main extends React.Component<Props> {
component={Profile} component={Profile}
authenticated={authenticated} authenticated={authenticated}
/> />
<ExtensionPoint
name="main.route"
renderAll={true}
props={{authenticated, links}}
/>
</Switch> </Switch>
</div> </div>
); );

View File

@@ -73,43 +73,39 @@ public final class UberClassLoader extends ClassLoader
//~--- methods -------------------------------------------------------------- //~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param name
*
* @return
*
* @throws ClassNotFoundException
*/
@Override @Override
protected Class<?> findClass(String name) throws ClassNotFoundException protected Class<?> findClass(String name) throws ClassNotFoundException
{ {
Class<?> clazz = getFromCache(name); Class<?> clazz = getFromCache(name);
if (clazz == null) if (clazz == null) {
{ clazz = findClassInPlugins(name);
for (PluginWrapper plugin : plugins) cache.put(name, new WeakReference<>(clazz));
{
ClassLoader cl = plugin.getClassLoader();
// load class could be slow, perhaps we should call
// find class via reflection ???
clazz = cl.loadClass(name);
if (clazz != null)
{
cache.put(name, new WeakReference<Class<?>>(clazz));
break;
}
}
} }
return clazz; return clazz;
} }
private Class<?> findClassInPlugins(String name) throws ClassNotFoundException {
for (PluginWrapper plugin : plugins) {
Class<?> clazz = findClass(plugin.getClassLoader(), name);
if (clazz != null) {
return clazz;
}
}
throw new ClassNotFoundException("could not find class " + name + " in any of the installed plugins");
}
private Class<?> findClass(ClassLoader classLoader, String name) {
try {
// load class could be slow, perhaps we should call
// find class via reflection ???
return classLoader.loadClass(name);
} catch (ClassNotFoundException ex) {
return null;
}
}
/** /**
* Method description * Method description
* *