mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 00:45:44 +01:00
use new plugin bundle format
This commit is contained in:
@@ -3,6 +3,7 @@ import * as React from "react";
|
||||
import { apiClient, Loading } from "@scm-manager/ui-components";
|
||||
import { getUiPluginsLink } from "../modules/indexResource";
|
||||
import { connect } from "react-redux";
|
||||
import loadBundle from "./loadBundle";
|
||||
|
||||
type Props = {
|
||||
loaded: boolean,
|
||||
@@ -73,30 +74,11 @@ class PluginLoader extends React.Component<Props, State> {
|
||||
|
||||
const promises = [];
|
||||
for (let bundle of plugin.bundles) {
|
||||
promises.push(this.loadBundle(bundle));
|
||||
promises.push(loadBundle(bundle));
|
||||
}
|
||||
return Promise.all(promises);
|
||||
};
|
||||
|
||||
loadBundle = (bundle: string) => {
|
||||
return fetch(bundle, {
|
||||
credentials: "same-origin",
|
||||
headers: {
|
||||
Cache: "no-cache",
|
||||
// identify the request as ajax request
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
return response.text();
|
||||
})
|
||||
.then(script => {
|
||||
// TODO is this safe???
|
||||
// eslint-disable-next-line no-eval
|
||||
eval(script); // NOSONAR
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
const { loaded } = this.props;
|
||||
const { message } = this.state;
|
||||
|
||||
47
scm-ui/ui-webapp/src/containers/loadBundle.js
Normal file
47
scm-ui/ui-webapp/src/containers/loadBundle.js
Normal file
@@ -0,0 +1,47 @@
|
||||
import "script-loader!../../../../node_modules/systemjs/dist/system.js";
|
||||
|
||||
import * as React from "react";
|
||||
import * as ReactDOM from "react-dom";
|
||||
import * as ReactRouterDom from "react-router-dom";
|
||||
import * as ReactRedux from "react-redux";
|
||||
import {default as injectSheets } from "react-jss";
|
||||
import * as ReactJSS from "react-jss";
|
||||
import * as ReactI18Next from "react-i18next";
|
||||
import * as ClassNames from "classnames";
|
||||
import * as UIExtensions from "@scm-manager/ui-extensions";
|
||||
import * as UIComponents from "@scm-manager/ui-components";
|
||||
|
||||
/**
|
||||
credentials: "same-origin",
|
||||
headers: {
|
||||
Cache: "no-cache",
|
||||
// identify the request as ajax request
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
}
|
||||
*/
|
||||
|
||||
SystemJS.config({
|
||||
baseURL: "/plugins",
|
||||
meta: {
|
||||
"/*": {
|
||||
esModule: true,
|
||||
authorization: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const expose = (name, cmp) => {
|
||||
SystemJS.set(name, SystemJS.newModule(cmp));
|
||||
};
|
||||
|
||||
expose("react", React);
|
||||
expose("react-dom", ReactDOM);
|
||||
expose("react-router-dom", ReactRouterDom);
|
||||
expose("react-jss", {...ReactJSS, default: injectSheets});
|
||||
expose("react-redux", ReactRedux);
|
||||
expose("react-i18next", ReactI18Next);
|
||||
expose("classnames", ClassNames);
|
||||
expose("@scm-manager/ui-extensions", UIExtensions);
|
||||
expose("@scm-manager/ui-components", UIComponents);
|
||||
|
||||
export default (plugin: string) => SystemJS.import(plugin);
|
||||
Reference in New Issue
Block a user