use reflow to migrate from flow to typescript

This commit is contained in:
Sebastian Sdorra
2019-10-19 16:38:07 +02:00
parent f7b8050dfa
commit 6e7a08a3bb
495 changed files with 14239 additions and 13766 deletions

View File

@@ -1,45 +1,44 @@
// @flow
import React, { Component } from "react";
import Main from "./Main";
import { connect } from "react-redux";
import { translate } from "react-i18next";
import { withRouter } from "react-router-dom";
import React, { Component } from 'react';
import Main from './Main';
import { connect } from 'react-redux';
import { translate } from 'react-i18next';
import { withRouter } from 'react-router-dom';
import {
fetchMe,
getFetchMeFailure,
getMe,
isAuthenticated,
isFetchMePending
} from "../modules/auth";
isFetchMePending,
} from '../modules/auth';
import {
ErrorPage,
Footer,
Header,
Loading,
PrimaryNavigation
} from "@scm-manager/ui-components";
import type { Links, Me } from "@scm-manager/ui-types";
PrimaryNavigation,
} from '@scm-manager/ui-components';
import { Links, Me } from '@scm-manager/ui-types';
import {
getFetchIndexResourcesFailure,
getLinks,
getMeLink,
isFetchIndexResourcesPending
} from "../modules/indexResource";
isFetchIndexResourcesPending,
} from '../modules/indexResource';
type Props = {
me: Me,
authenticated: boolean,
error: Error,
loading: boolean,
links: Links,
meLink: string,
me: Me;
authenticated: boolean;
error: Error;
loading: boolean;
links: Links;
meLink: string;
// dispatcher functions
fetchMe: (link: string) => void,
fetchMe: (link: string) => void;
// context props
t: string => string
t: (p: string) => string;
};
class App extends Component<Props> {
@@ -53,15 +52,15 @@ class App extends Component<Props> {
const { me, loading, error, authenticated, links, t } = this.props;
let content;
const navigation = authenticated ? <PrimaryNavigation links={links} /> : "";
const navigation = authenticated ? <PrimaryNavigation links={links} /> : '';
if (loading) {
content = <Loading />;
} else if (error) {
content = (
<ErrorPage
title={t("app.error.title")}
subtitle={t("app.error.subtitle")}
title={t('app.error.title')}
subtitle={t('app.error.subtitle')}
error={error}
/>
);
@@ -80,7 +79,7 @@ class App extends Component<Props> {
const mapDispatchToProps = (dispatch: any) => {
return {
fetchMe: (link: string) => dispatch(fetchMe(link))
fetchMe: (link: string) => dispatch(fetchMe(link)),
};
};
@@ -99,13 +98,13 @@ const mapStateToProps = state => {
loading,
error,
links,
meLink
meLink,
};
};
export default withRouter(
connect(
mapStateToProps,
mapDispatchToProps
)(translate("commons")(App))
mapDispatchToProps,
)(translate('commons')(App)),
);

View File

@@ -1,28 +1,27 @@
// @flow
import React from "react";
import React from 'react';
import {
ErrorNotification,
InputField,
Notification,
PasswordConfirmation,
SubmitButton
} from "@scm-manager/ui-components";
import { translate } from "react-i18next";
import type { Me } from "@scm-manager/ui-types";
import { changePassword } from "../modules/changePassword";
SubmitButton,
} from '@scm-manager/ui-components';
import { translate } from 'react-i18next';
import { Me } from '@scm-manager/ui-types';
import { changePassword } from '../modules/changePassword';
type Props = {
me: Me,
t: string => string
me: Me;
t: (p: string) => string;
};
type State = {
oldPassword: string,
password: string,
loading: boolean,
error?: Error,
passwordChanged: boolean,
passwordValid: boolean
oldPassword: string;
password: string;
loading: boolean;
error?: Error;
passwordChanged: boolean;
passwordValid: boolean;
};
class ChangeUserPassword extends React.Component<Props, State> {
@@ -30,21 +29,21 @@ class ChangeUserPassword extends React.Component<Props, State> {
super(props);
this.state = {
oldPassword: "",
password: "",
oldPassword: '',
password: '',
loading: false,
passwordConfirmationError: false,
validatePasswordError: false,
validatePassword: "",
validatePassword: '',
passwordChanged: false,
passwordValid: false
passwordValid: false,
};
}
setLoadingState = () => {
this.setState({
...this.state,
loading: true
loading: true,
});
};
@@ -52,7 +51,7 @@ class ChangeUserPassword extends React.Component<Props, State> {
this.setState({
...this.state,
error: error,
loading: false
loading: false,
});
};
@@ -61,8 +60,8 @@ class ChangeUserPassword extends React.Component<Props, State> {
...this.state,
loading: false,
passwordChanged: true,
oldPassword: "",
password: ""
oldPassword: '',
password: '',
});
};
@@ -98,8 +97,8 @@ class ChangeUserPassword extends React.Component<Props, State> {
if (passwordChanged) {
message = (
<Notification
type={"success"}
children={t("password.changedSuccessfully")}
type={'success'}
children={t('password.changedSuccessfully')}
onClose={() => this.onClose()}
/>
);
@@ -113,26 +112,29 @@ class ChangeUserPassword extends React.Component<Props, State> {
<div className="columns">
<div className="column">
<InputField
label={t("password.currentPassword")}
label={t('password.currentPassword')}
type="password"
onChange={oldPassword =>
this.setState({ ...this.state, oldPassword })
this.setState({
...this.state,
oldPassword,
})
}
value={this.state.oldPassword ? this.state.oldPassword : ""}
helpText={t("password.currentPasswordHelpText")}
value={this.state.oldPassword ? this.state.oldPassword : ''}
helpText={t('password.currentPasswordHelpText')}
/>
</div>
</div>
<PasswordConfirmation
passwordChanged={this.passwordChanged}
key={this.state.passwordChanged ? "changed" : "unchanged"}
key={this.state.passwordChanged ? 'changed' : 'unchanged'}
/>
<div className="columns">
<div className="column">
<SubmitButton
disabled={!this.isValid()}
loading={loading}
label={t("password.submit")}
label={t('password.submit')}
/>
</div>
</div>
@@ -144,16 +146,16 @@ class ChangeUserPassword extends React.Component<Props, State> {
this.setState({
...this.state,
password,
passwordValid: !!password && passwordValid
passwordValid: !!password && passwordValid,
});
};
onClose = () => {
this.setState({
...this.state,
passwordChanged: false
passwordChanged: false,
});
};
}
export default translate("commons")(ChangeUserPassword);
export default translate('commons')(ChangeUserPassword);

View File

@@ -1,43 +1,42 @@
// @flow
import React, { Component } from "react";
import App from "./App";
import { connect } from "react-redux";
import { translate } from "react-i18next";
import { withRouter } from "react-router-dom";
import React, { Component } from 'react';
import App from './App';
import { connect } from 'react-redux';
import { translate } from 'react-i18next';
import { withRouter } from 'react-router-dom';
import { Loading, ErrorBoundary } from "@scm-manager/ui-components";
import { Loading, ErrorBoundary } from '@scm-manager/ui-components';
import {
fetchIndexResources,
getFetchIndexResourcesFailure,
getLinks,
isFetchIndexResourcesPending
} from "../modules/indexResource";
import PluginLoader from "./PluginLoader";
import type { IndexResources } from "@scm-manager/ui-types";
import ScrollToTop from "./ScrollToTop";
import IndexErrorPage from "./IndexErrorPage";
isFetchIndexResourcesPending,
} from '../modules/indexResource';
import PluginLoader from './PluginLoader';
import { IndexResources } from '@scm-manager/ui-types';
import ScrollToTop from './ScrollToTop';
import IndexErrorPage from './IndexErrorPage';
type Props = {
error: Error,
loading: boolean,
indexResources: IndexResources,
error: Error;
loading: boolean;
indexResources: IndexResources;
// dispatcher functions
fetchIndexResources: () => void,
fetchIndexResources: () => void;
// context props
t: string => string
t: (p: string) => string;
};
type State = {
pluginsLoaded: boolean
pluginsLoaded: boolean;
};
class Index extends Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = {
pluginsLoaded: false
pluginsLoaded: false,
};
}
@@ -47,7 +46,7 @@ class Index extends Component<Props, State> {
pluginLoaderCallback = () => {
this.setState({
pluginsLoaded: true
pluginsLoaded: true,
});
};
@@ -56,7 +55,7 @@ class Index extends Component<Props, State> {
const { pluginsLoaded } = this.state;
if (error) {
return <IndexErrorPage error={error}/>;
return <IndexErrorPage error={error} />;
} else if (loading || !indexResources) {
return <Loading />;
} else {
@@ -78,7 +77,7 @@ class Index extends Component<Props, State> {
const mapDispatchToProps = (dispatch: any) => {
return {
fetchIndexResources: () => dispatch(fetchIndexResources())
fetchIndexResources: () => dispatch(fetchIndexResources()),
};
};
@@ -89,13 +88,13 @@ const mapStateToProps = state => {
return {
loading,
error,
indexResources
indexResources,
};
};
export default withRouter(
connect(
mapStateToProps,
mapDispatchToProps
)(translate("commons")(Index))
mapDispatchToProps,
)(translate('commons')(Index)),
);

View File

@@ -1,26 +0,0 @@
//@flow
import React from "react";
import { translate, type TFunction } from "react-i18next";
import { ErrorPage } from "@scm-manager/ui-components";
type Props = {
error: Error,
t: TFunction
}
class IndexErrorPage extends React.Component<Props> {
render() {
const { error, t } = this.props;
return (
<ErrorPage
title={t("app.error.title")}
subtitle={t("app.error.subtitle")}
error={error}
/>
);
}
}
export default translate("commons")(IndexErrorPage);

View File

@@ -0,0 +1,23 @@
import React from 'react';
import { translate, TFunction } from 'react-i18next';
import { ErrorPage } from '@scm-manager/ui-components';
type Props = {
error: Error;
t: TFunction;
};
class IndexErrorPage extends React.Component<Props> {
render() {
const { error, t } = this.props;
return (
<ErrorPage
title={t('app.error.title')}
subtitle={t('app.error.subtitle')}
error={error}
/>
);
}
}
export default translate('commons')(IndexErrorPage);

View File

@@ -1,33 +1,32 @@
//@flow
import React from "react";
import { connect } from "react-redux";
import { Redirect, withRouter } from "react-router-dom";
import { compose } from "redux";
import { translate } from "react-i18next";
import styled from "styled-components";
import React from 'react';
import { connect } from 'react-redux';
import { Redirect, withRouter } from 'react-router-dom';
import { compose } from 'redux';
import { translate } from 'react-i18next';
import styled from 'styled-components';
import {
getLoginFailure,
isAuthenticated,
isLoginPending,
login
} from "../modules/auth";
import { getLoginInfoLink, getLoginLink } from "../modules/indexResource";
import LoginInfo from "../components/LoginInfo";
login,
} from '../modules/auth';
import { getLoginInfoLink, getLoginLink } from '../modules/indexResource';
import LoginInfo from '../components/LoginInfo';
type Props = {
authenticated: boolean,
loading: boolean,
error?: Error,
link: string,
loginInfoLink?: string,
authenticated: boolean;
loading: boolean;
error?: Error;
link: string;
loginInfoLink?: string;
// dispatcher props
login: (link: string, username: string, password: string) => void,
login: (link: string, username: string, password: string) => void;
// context props
t: string => string,
from: any,
location: any
t: (p: string) => string;
from: any;
location: any;
};
const HeroSection = styled.section`
@@ -41,7 +40,11 @@ class Login extends React.Component<Props> {
};
renderRedirect = () => {
const { from } = this.props.location.state || { from: { pathname: "/" } };
const { from } = this.props.location.state || {
from: {
pathname: '/',
},
};
return <Redirect to={from} />;
};
@@ -77,14 +80,14 @@ const mapStateToProps = state => {
loading,
error,
link,
loginInfoLink
loginInfoLink,
};
};
const mapDispatchToProps = dispatch => {
return {
login: (loginLink: string, username: string, password: string) =>
dispatch(login(loginLink, username, password))
dispatch(login(loginLink, username, password)),
};
};
@@ -92,6 +95,6 @@ export default compose(
withRouter,
connect(
mapStateToProps,
mapDispatchToProps
)
mapDispatchToProps,
),
)(Login);

View File

@@ -1,30 +1,30 @@
//@flow
import React from "react";
import { connect } from "react-redux";
import { translate } from "react-i18next";
import { Redirect } from "react-router-dom";
import React from 'react';
import { connect } from 'react-redux';
import { translate } from 'react-i18next';
import { Redirect } from 'react-router-dom';
import {
logout,
isAuthenticated,
isLogoutPending,
getLogoutFailure, isRedirecting
} from "../modules/auth";
import { Loading, ErrorPage } from "@scm-manager/ui-components";
import { getLogoutLink } from "../modules/indexResource";
getLogoutFailure,
isRedirecting,
} from '../modules/auth';
import { Loading, ErrorPage } from '@scm-manager/ui-components';
import { getLogoutLink } from '../modules/indexResource';
type Props = {
authenticated: boolean,
loading: boolean,
redirecting: boolean,
error: Error,
logoutLink: string,
authenticated: boolean;
loading: boolean;
redirecting: boolean;
error: Error;
logoutLink: string;
// dispatcher functions
logout: (link: string) => void,
logout: (link: string) => void;
// context props
t: string => string
t: (p: string) => string;
};
class Logout extends React.Component<Props> {
@@ -37,8 +37,8 @@ class Logout extends React.Component<Props> {
if (error) {
return (
<ErrorPage
title={t("logout.error.title")}
subtitle={t("logout.error.subtitle")}
title={t('logout.error.title')}
subtitle={t('logout.error.subtitle')}
error={error}
/>
);
@@ -61,17 +61,17 @@ const mapStateToProps = state => {
loading,
redirecting,
error,
logoutLink
logoutLink,
};
};
const mapDispatchToProps = dispatch => {
return {
logout: (link: string) => dispatch(logout(link))
logout: (link: string) => dispatch(logout(link)),
};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(translate("commons")(Logout));
mapDispatchToProps,
)(translate('commons')(Logout));

View File

@@ -1,40 +1,39 @@
//@flow
import React from "react";
import React from 'react';
import { Redirect, Route, Switch, withRouter } from "react-router-dom";
import type { Links } from "@scm-manager/ui-types";
import { Redirect, Route, Switch, withRouter } from 'react-router-dom';
import { Links } from '@scm-manager/ui-types';
import Overview from "../repos/containers/Overview";
import Users from "../users/containers/Users";
import Login from "../containers/Login";
import Logout from "../containers/Logout";
import Overview from '../repos/containers/Overview';
import Users from '../users/containers/Users';
import Login from '../containers/Login';
import Logout from '../containers/Logout';
import { ProtectedRoute } from "@scm-manager/ui-components";
import { binder, ExtensionPoint } from "@scm-manager/ui-extensions";
import { ProtectedRoute } from '@scm-manager/ui-components';
import { binder, ExtensionPoint } from '@scm-manager/ui-extensions';
import CreateUser from "../users/containers/CreateUser";
import SingleUser from "../users/containers/SingleUser";
import RepositoryRoot from "../repos/containers/RepositoryRoot";
import Create from "../repos/containers/Create";
import CreateUser from '../users/containers/CreateUser';
import SingleUser from '../users/containers/SingleUser';
import RepositoryRoot from '../repos/containers/RepositoryRoot';
import Create from '../repos/containers/Create';
import Groups from "../groups/containers/Groups";
import SingleGroup from "../groups/containers/SingleGroup";
import CreateGroup from "../groups/containers/CreateGroup";
import Groups from '../groups/containers/Groups';
import SingleGroup from '../groups/containers/SingleGroup';
import CreateGroup from '../groups/containers/CreateGroup';
import Admin from "../admin/containers/Admin";
import Admin from '../admin/containers/Admin';
import Profile from "./Profile";
import Profile from './Profile';
type Props = {
authenticated?: boolean,
links: Links
authenticated?: boolean;
links: Links;
};
class Main extends React.Component<Props> {
render() {
const { authenticated, links } = this.props;
const redirectUrlFactory = binder.getExtension("main.redirect", this.props);
let url = "/repos/";
const redirectUrlFactory = binder.getExtension('main.redirect', this.props);
let url = '/repos/';
if (redirectUrlFactory) {
url = redirectUrlFactory(this.props);
}
@@ -127,7 +126,10 @@ class Main extends React.Component<Props> {
<ExtensionPoint
name="main.route"
renderAll={true}
props={{ authenticated, links }}
props={{
authenticated,
links,
}}
/>
</Switch>
</div>

View File

@@ -1,31 +1,30 @@
// @flow
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";
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,
children: React.Node,
link: string,
callback: () => void
loaded: boolean;
children: React.Node;
link: string;
callback: () => void;
};
type State = {
message: string
message: string;
};
type Plugin = {
name: string,
bundles: string[]
name: string;
bundles: string[];
};
class PluginLoader extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = {
message: "booting"
message: 'booting',
};
}
@@ -33,7 +32,7 @@ class PluginLoader extends React.Component<Props, State> {
const { loaded } = this.props;
if (!loaded) {
this.setState({
message: "loading plugin information"
message: 'loading plugin information',
});
this.getPlugins(this.props.link);
@@ -52,7 +51,7 @@ class PluginLoader extends React.Component<Props, State> {
loadPlugins = (plugins: Plugin[]) => {
this.setState({
message: "loading plugins"
message: 'loading plugins',
});
const promises = [];
@@ -69,7 +68,7 @@ class PluginLoader extends React.Component<Props, State> {
loadPlugin = (plugin: Plugin) => {
this.setState({
message: `loading ${plugin.name}`
message: `loading ${plugin.name}`,
});
const promises = [];
@@ -100,7 +99,7 @@ const comparePluginsByName = (a: Plugin, b: Plugin) => {
const mapStateToProps = state => {
const link = getUiPluginsLink(state);
return {
link
link,
};
};

View File

@@ -1,37 +1,35 @@
// @flow
import React from 'react';
import React from "react";
import { Route, withRouter } from "react-router-dom";
import { getMe } from "../modules/auth";
import { compose } from "redux";
import { connect } from "react-redux";
import { translate } from "react-i18next";
import type { Me } from "@scm-manager/ui-types";
import { Route, withRouter } from 'react-router-dom';
import { getMe } from '../modules/auth';
import { compose } from 'redux';
import { connect } from 'react-redux';
import { translate } from 'react-i18next';
import { Me } from '@scm-manager/ui-types';
import {
ErrorPage,
Page,
Navigation,
SubNavigation,
Section,
NavLink
} from "@scm-manager/ui-components";
import ChangeUserPassword from "./ChangeUserPassword";
import ProfileInfo from "./ProfileInfo";
import { ExtensionPoint } from "@scm-manager/ui-extensions";
NavLink,
} from '@scm-manager/ui-components';
import ChangeUserPassword from './ChangeUserPassword';
import ProfileInfo from './ProfileInfo';
import { ExtensionPoint } from '@scm-manager/ui-extensions';
type Props = {
me: Me,
me: Me;
// Context props
t: string => string,
match: any
t: (p: string) => string;
match: any;
};
type State = {};
class Profile extends React.Component<Props, State> {
stripEndingSlash = (url: string) => {
if (url.endsWith("/")) {
if (url.endsWith('/')) {
return url.substring(0, url.length - 2);
}
return url;
@@ -49,11 +47,11 @@ class Profile extends React.Component<Props, State> {
if (!me) {
return (
<ErrorPage
title={t("profile.error-title")}
subtitle={t("profile.error-subtitle")}
title={t('profile.error-title')}
subtitle={t('profile.error-subtitle')}
error={{
name: t("profile.error"),
message: t("profile.error-message")
name: t('profile.error'),
message: t('profile.error-message'),
}}
/>
);
@@ -61,7 +59,7 @@ class Profile extends React.Component<Props, State> {
const extensionProps = {
me,
url
url,
};
return (
@@ -81,19 +79,19 @@ class Profile extends React.Component<Props, State> {
</div>
<div className="column">
<Navigation>
<Section label={t("profile.navigationLabel")}>
<Section label={t('profile.navigationLabel')}>
<NavLink
to={`${url}`}
icon="fas fa-info-circle"
label={t("profile.informationNavLink")}
label={t('profile.informationNavLink')}
/>
<SubNavigation
to={`${url}/settings/password`}
label={t("profile.settingsNavLink")}
label={t('profile.settingsNavLink')}
>
<NavLink
to={`${url}/settings/password`}
label={t("profile.changePasswordNavLink")}
label={t('profile.changePasswordNavLink')}
/>
<ExtensionPoint
name="profile.setting"
@@ -112,12 +110,12 @@ class Profile extends React.Component<Props, State> {
const mapStateToProps = state => {
return {
me: getMe(state)
me: getMe(state),
};
};
export default compose(
translate("commons"),
translate('commons'),
connect(mapStateToProps),
withRouter
withRouter,
)(Profile);

View File

@@ -1,18 +1,17 @@
// @flow
import React from "react";
import { translate } from "react-i18next";
import type { Me } from "@scm-manager/ui-types";
import React from 'react';
import { translate } from 'react-i18next';
import { Me } from '@scm-manager/ui-types';
import {
MailLink,
AvatarWrapper,
AvatarImage
} from "@scm-manager/ui-components";
AvatarImage,
} from '@scm-manager/ui-components';
type Props = {
me: Me,
me: Me;
// Context props
t: string => string
t: (p: string) => string;
};
class ProfileInfo extends React.Component<Props> {
@@ -31,15 +30,15 @@ class ProfileInfo extends React.Component<Props> {
<table className="table content">
<tbody>
<tr>
<th>{t("profile.username")}</th>
<th>{t('profile.username')}</th>
<td>{me.name}</td>
</tr>
<tr>
<th>{t("profile.displayName")}</th>
<th>{t('profile.displayName')}</th>
<td>{me.displayName}</td>
</tr>
<tr>
<th>{t("profile.mail")}</th>
<th>{t('profile.mail')}</th>
<td>
<MailLink address={me.mail} />
</td>
@@ -59,7 +58,7 @@ class ProfileInfo extends React.Component<Props> {
if (me.groups.length > 0) {
groups = (
<tr>
<th>{t("profile.groups")}</th>
<th>{t('profile.groups')}</th>
<td className="is-paddingless">
<ul>
{me.groups.map(group => {
@@ -74,4 +73,4 @@ class ProfileInfo extends React.Component<Props> {
}
}
export default translate("commons")(ProfileInfo);
export default translate('commons')(ProfileInfo);

View File

@@ -1,12 +1,10 @@
// @flow
import React from "react";
import { withRouter } from "react-router-dom";
import React from 'react';
import { withRouter } from 'react-router-dom';
type Props = {
location: any,
children: any
}
location: any;
children: any;
};
class ScrollToTop extends React.Component<Props> {
componentDidUpdate(prevProps) {

View File

@@ -1,58 +0,0 @@
/* global SystemJS */
// eslint-disable-next-line import/no-webpack-loader-syntax
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 Redux from "redux";
import * as ReactRedux from "react-redux";
import SytleComponentsDefault from "styled-components";
import * as SytleComponents from "styled-components";
import * as ReactI18Next from "react-i18next";
import ClassNamesDefault from "classnames";
import * as ClassNames from "classnames";
import QueryStringDefault from "query-string";
import * as QueryString from "query-string";
import * as UIExtensions from "@scm-manager/ui-extensions";
import * as UIComponents from "@scm-manager/ui-components";
import { urls } from "@scm-manager/ui-components";
// TODO add headers "Cache": "no-cache", "X-Requested-With": "XMLHttpRequest"
SystemJS.config({
baseURL: urls.withContextPath("/assets"),
meta: {
"/*": {
esModule: true,
authorization: true
}
}
});
const expose = (name, cmp, defaultCmp) => {
let mod = cmp;
if (defaultCmp) {
// SystemJS default export:
// https://github.com/systemjs/systemjs/issues/1749
mod = {
...cmp,
__useDefault: defaultCmp
};
}
SystemJS.set(name, SystemJS.newModule(mod));
};
expose("react", React);
expose("react-dom", ReactDOM);
expose("react-router-dom", ReactRouterDom);
expose("styled-components", SytleComponents, SytleComponentsDefault);
expose("redux", Redux);
expose("react-redux", ReactRedux);
expose("react-i18next", ReactI18Next);
expose("classnames", ClassNames, ClassNamesDefault);
expose("query-string", QueryString, QueryStringDefault);
expose("@scm-manager/ui-extensions", UIExtensions);
expose("@scm-manager/ui-components", UIComponents);
export default (plugin) => SystemJS.import(plugin);

View File

@@ -0,0 +1,58 @@
/* global SystemJS */
// eslint-disable-next-line import/no-webpack-loader-syntax
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 Redux from 'redux';
import * as ReactRedux from 'react-redux';
import SytleComponentsDefault from 'styled-components';
import * as SytleComponents from 'styled-components';
import * as ReactI18Next from 'react-i18next';
import ClassNamesDefault from 'classnames';
import * as ClassNames from 'classnames';
import QueryStringDefault from 'query-string';
import * as QueryString from 'query-string';
import * as UIExtensions from '@scm-manager/ui-extensions';
import * as UIComponents from '@scm-manager/ui-components';
import { urls } from '@scm-manager/ui-components';
// TODO add headers "Cache": "no-cache", "X-Requested-With": "XMLHttpRequest"
SystemJS.config({
baseURL: urls.withContextPath('/assets'),
meta: {
'/*': {
esModule: true,
authorization: true,
},
},
});
const expose = (name, cmp, defaultCmp) => {
let mod = cmp;
if (defaultCmp) {
// SystemJS default export:
// https://github.com/systemjs/systemjs/issues/1749
mod = {
...cmp,
__useDefault: defaultCmp,
};
}
SystemJS.set(name, SystemJS.newModule(mod));
};
expose('react', React);
expose('react-dom', ReactDOM);
expose('react-router-dom', ReactRouterDom);
expose('styled-components', SytleComponents, SytleComponentsDefault);
expose('redux', Redux);
expose('react-redux', ReactRedux);
expose('react-i18next', ReactI18Next);
expose('classnames', ClassNames, ClassNamesDefault);
expose('query-string', QueryString, QueryStringDefault);
expose('@scm-manager/ui-extensions', UIExtensions);
expose('@scm-manager/ui-components', UIComponents);
export default plugin => SystemJS.import(plugin);