fix a ton of typescript errors

This commit is contained in:
Eduard Heimbuch
2020-01-08 13:40:07 +01:00
parent 15a9a5b09b
commit a43ffacf03
41 changed files with 229 additions and 311 deletions

View File

@@ -15,7 +15,7 @@ class DropDown extends React.Component<Props> {
const { options, optionValues, preselectedOption, className, disabled } = this.props; const { options, optionValues, preselectedOption, className, disabled } = this.props;
if (preselectedOption && !options.includes(preselectedOption)) { if (preselectedOption && !options.includes(preselectedOption)) {
options.unshift(preselectedOption) options.unshift(preselectedOption);
} }
return ( return (

View File

@@ -13,10 +13,10 @@ type Props = {
class ArrayConfigTable extends React.Component<Props> { class ArrayConfigTable extends React.Component<Props> {
render() { render() {
const { label, disabled, removeLabel, items, helpText } = this.props; const { label, disabled, removeLabel, items, helpText } = this.props;
if(items.length > 0) { if (items.length > 0) {
return ( return (
<> <>
<LabelWithHelpIcon label={label} helpText={helpText}/> <LabelWithHelpIcon label={label} helpText={helpText} />
<table className="table is-hoverable is-fullwidth"> <table className="table is-hoverable is-fullwidth">
<tbody> <tbody>
{items.map(item => { {items.map(item => {

View File

@@ -147,7 +147,4 @@ const mapStateToProps = (state: any) => {
}; };
}; };
export default compose( export default compose(connect(mapStateToProps), withTranslation("admin"))(Admin);
connect(mapStateToProps),
withTranslation("admin")
)(Admin);

View File

@@ -22,6 +22,7 @@ import {
getNamespaceStrategies, getNamespaceStrategies,
isFetchNamespaceStrategiesPending isFetchNamespaceStrategiesPending
} from "../modules/namespaceStrategies"; } from "../modules/namespaceStrategies";
import { compose } from "redux";
type Props = WithTranslation & { type Props = WithTranslation & {
loading: boolean; loading: boolean;
@@ -137,7 +138,7 @@ class GlobalConfig extends React.Component<Props, State> {
}; };
} }
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
fetchConfig: (link: string) => { fetchConfig: (link: string) => {
dispatch(fetchConfig(link)); dispatch(fetchConfig(link));
@@ -154,7 +155,7 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
const mapStateToProps = state => { const mapStateToProps = (state: any) => {
const loading = const loading =
isFetchConfigPending(state) || isModifyConfigPending(state) || isFetchNamespaceStrategiesPending(state); isFetchConfigPending(state) || isModifyConfigPending(state) || isFetchNamespaceStrategiesPending(state);
const error = const error =
@@ -175,7 +176,4 @@ const mapStateToProps = state => {
}; };
}; };
export default connect( export default compose(connect(mapStateToProps, mapDispatchToProps), withTranslation("config"))(GlobalConfig);
mapStateToProps,
mapDispatchToProps
)(withTranslation("config")(GlobalConfig));

View File

@@ -31,6 +31,7 @@ import PluginBottomActions from "../components/PluginBottomActions";
import ExecutePendingActionModal from "../components/ExecutePendingActionModal"; import ExecutePendingActionModal from "../components/ExecutePendingActionModal";
import CancelPendingActionModal from "../components/CancelPendingActionModal"; import CancelPendingActionModal from "../components/CancelPendingActionModal";
import UpdateAllActionModal from "../components/UpdateAllActionModal"; import UpdateAllActionModal from "../components/UpdateAllActionModal";
import {Plugin} from "@scm-manager/ui-types/src";
type Props = WithTranslation & { type Props = WithTranslation & {
loading: boolean; loading: boolean;
@@ -68,7 +69,7 @@ class PluginsOverview extends React.Component<Props, State> {
this.fetchPlugins(); this.fetchPlugins();
} }
componentDidUpdate(prevProps) { componentDidUpdate(prevProps: Props) {
const { installed } = this.props; const { installed } = this.props;
if (prevProps.installed !== installed) { if (prevProps.installed !== installed) {
this.fetchPlugins(); this.fetchPlugins();
@@ -90,7 +91,7 @@ class PluginsOverview extends React.Component<Props, State> {
} }
}; };
renderHeader = (actions: React.Node) => { renderHeader = (actions: React.ReactNode) => {
const { installed, t } = this.props; const { installed, t } = this.props;
return ( return (
<div className="columns"> <div className="columns">
@@ -103,7 +104,7 @@ class PluginsOverview extends React.Component<Props, State> {
); );
}; };
renderFooter = (actions: React.Node) => { renderFooter = (actions: React.ReactNode) => {
if (actions) { if (actions) {
return <PluginBottomActions>{actions}</PluginBottomActions>; return <PluginBottomActions>{actions}</PluginBottomActions>;
} }
@@ -173,7 +174,7 @@ class PluginsOverview extends React.Component<Props, State> {
computeUpdateAllSize = () => { computeUpdateAllSize = () => {
const { collection, t } = this.props; const { collection, t } = this.props;
const outdatedPlugins = collection._embedded.plugins.filter(p => p._links.update).length; const outdatedPlugins = collection._embedded.plugins.filter((p: Plugin) => p._links.update).length;
return t("plugins.outdatedPlugins", { return t("plugins.outdatedPlugins", {
count: outdatedPlugins count: outdatedPlugins
}); });
@@ -256,7 +257,7 @@ class PluginsOverview extends React.Component<Props, State> {
} }
} }
const mapStateToProps = state => { const mapStateToProps = (state: any) => {
const collection = getPluginCollection(state); const collection = getPluginCollection(state);
const loading = isFetchPluginsPending(state); const loading = isFetchPluginsPending(state);
const error = getFetchPluginsFailure(state); const error = getFetchPluginsFailure(state);
@@ -276,7 +277,7 @@ const mapStateToProps = state => {
}; };
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
fetchPluginsByLink: (link: string) => { fetchPluginsByLink: (link: string) => {
dispatch(fetchPluginsByLink(link)); dispatch(fetchPluginsByLink(link));
@@ -287,10 +288,4 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
export default compose( export default compose(withTranslation("admin"), connect(mapStateToProps, mapDispatchToProps))(PluginsOverview);
withTranslation("admin"),
connect(
mapStateToProps,
mapDispatchToProps
)
)(PluginsOverview);

View File

@@ -1,5 +1,6 @@
import React from "react"; import React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { compose } from "redux";
import { WithTranslation, withTranslation } from "react-i18next"; import { WithTranslation, withTranslation } from "react-i18next";
import { History } from "history"; import { History } from "history";
import { RepositoryRole } from "@scm-manager/ui-types"; import { RepositoryRole } from "@scm-manager/ui-types";
@@ -38,13 +39,13 @@ class CreateRepositoryRole extends React.Component<Props> {
<> <>
<Title title={t("repositoryRole.title")} /> <Title title={t("repositoryRole.title")} />
<Subtitle subtitle={t("repositoryRole.createSubtitle")} /> <Subtitle subtitle={t("repositoryRole.createSubtitle")} />
<RepositoryRoleForm submitForm={role => this.createRepositoryRole(role)} /> <RepositoryRoleForm submitForm={(role: RepositoryRole) => this.createRepositoryRole(role)} />
</> </>
); );
} }
} }
const mapStateToProps = (state) => { const mapStateToProps = (state: any) => {
const loading = isFetchVerbsPending(state); const loading = isFetchVerbsPending(state);
const error = getFetchVerbsFailure(state) || getCreateRoleFailure(state); const error = getFetchVerbsFailure(state) || getCreateRoleFailure(state);
const verbsLink = getRepositoryVerbsLink(state); const verbsLink = getRepositoryVerbsLink(state);
@@ -58,7 +59,7 @@ const mapStateToProps = (state) => {
}; };
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
addRole: (link: string, role: RepositoryRole, callback?: () => void) => { addRole: (link: string, role: RepositoryRole, callback?: () => void) => {
dispatch(createRole(link, role, callback)); dispatch(createRole(link, role, callback));
@@ -66,7 +67,4 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
export default connect( export default compose(connect(mapStateToProps, mapDispatchToProps), withTranslation("admin"))(CreateRepositoryRole);
mapStateToProps,
mapDispatchToProps
)(withTranslation("admin")(CreateRepositoryRole));

View File

@@ -1,5 +1,6 @@
import React from "react"; import React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { compose } from "redux";
import { withRouter } from "react-router-dom"; import { withRouter } from "react-router-dom";
import { WithTranslation, withTranslation } from "react-i18next"; import { WithTranslation, withTranslation } from "react-i18next";
import { History } from "history"; import { History } from "history";
@@ -72,7 +73,7 @@ class DeleteRepositoryRole extends React.Component<Props> {
} }
} }
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state: any, ownProps: Props) => {
const loading = isDeleteRolePending(state, ownProps.role.name); const loading = isDeleteRolePending(state, ownProps.role.name);
const error = getDeleteRoleFailure(state, ownProps.role.name); const error = getDeleteRoleFailure(state, ownProps.role.name);
return { return {
@@ -81,7 +82,7 @@ const mapStateToProps = (state, ownProps) => {
}; };
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
deleteRole: (role: RepositoryRole, callback?: () => void) => { deleteRole: (role: RepositoryRole, callback?: () => void) => {
dispatch(deleteRole(role, callback)); dispatch(deleteRole(role, callback));
@@ -89,7 +90,8 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
export default connect( export default compose(
mapStateToProps, connect(mapStateToProps, mapDispatchToProps),
mapDispatchToProps withRouter,
)(withRouter(withTranslation("admin")(DeleteRepositoryRole))); withTranslation("admin")
)(DeleteRepositoryRole);

View File

@@ -7,6 +7,7 @@ import { ErrorNotification, Subtitle, Loading } from "@scm-manager/ui-components
import { RepositoryRole } from "@scm-manager/ui-types"; import { RepositoryRole } from "@scm-manager/ui-types";
import { History } from "history"; import { History } from "history";
import DeleteRepositoryRole from "./DeleteRepositoryRole"; import DeleteRepositoryRole from "./DeleteRepositoryRole";
import { compose } from "redux";
type Props = WithTranslation & { type Props = WithTranslation & {
disabled: boolean; disabled: boolean;
@@ -43,14 +44,17 @@ class EditRepositoryRole extends React.Component<Props> {
return ( return (
<> <>
<Subtitle subtitle={t("repositoryRole.editSubtitle")} /> <Subtitle subtitle={t("repositoryRole.editSubtitle")} />
<RepositoryRoleForm role={this.props.role} submitForm={role => this.updateRepositoryRole(role)} /> <RepositoryRoleForm
role={this.props.role}
submitForm={(role: RepositoryRole) => this.updateRepositoryRole(role)}
/>
<DeleteRepositoryRole role={this.props.role} /> <DeleteRepositoryRole role={this.props.role} />
</> </>
); );
} }
} }
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state: any, ownProps: Props) => {
const loading = isModifyRolePending(state, ownProps.role.name); const loading = isModifyRolePending(state, ownProps.role.name);
const error = getModifyRoleFailure(state, ownProps.role.name); const error = getModifyRoleFailure(state, ownProps.role.name);
@@ -60,7 +64,7 @@ const mapStateToProps = (state, ownProps) => {
}; };
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
updateRole: (role: RepositoryRole, callback?: () => void) => { updateRole: (role: RepositoryRole, callback?: () => void) => {
dispatch(modifyRole(role, callback)); dispatch(modifyRole(role, callback));
@@ -68,7 +72,4 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
export default connect( export default compose(connect(mapStateToProps, mapDispatchToProps), withTranslation("admin"))(EditRepositoryRole);
mapStateToProps,
mapDispatchToProps
)(withTranslation("admin")(EditRepositoryRole));

View File

@@ -6,6 +6,7 @@ import { InputField, Level, SubmitButton } from "@scm-manager/ui-components";
import { getRepositoryRolesLink, getRepositoryVerbsLink } from "../../../modules/indexResource"; import { getRepositoryRolesLink, getRepositoryVerbsLink } from "../../../modules/indexResource";
import { fetchAvailableVerbs, getFetchVerbsFailure, getVerbsFromState, isFetchVerbsPending } from "../modules/roles"; import { fetchAvailableVerbs, getFetchVerbsFailure, getVerbsFromState, isFetchVerbsPending } from "../modules/roles";
import PermissionsWrapper from "../../../permissions/components/PermissionsWrapper"; import PermissionsWrapper from "../../../permissions/components/PermissionsWrapper";
import { compose } from "redux";
type Props = WithTranslation & { type Props = WithTranslation & {
role?: RepositoryRole; role?: RepositoryRole;
@@ -120,7 +121,7 @@ class RepositoryRoleForm extends React.Component<Props, State> {
} }
} }
const mapStateToProps = state => { const mapStateToProps = (state: any) => {
const loading = isFetchVerbsPending(state); const loading = isFetchVerbsPending(state);
const error = getFetchVerbsFailure(state); const error = getFetchVerbsFailure(state);
const verbsLink = getRepositoryVerbsLink(state); const verbsLink = getRepositoryVerbsLink(state);
@@ -136,7 +137,7 @@ const mapStateToProps = state => {
}; };
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
fetchAvailableVerbs: (link: string) => { fetchAvailableVerbs: (link: string) => {
dispatch(fetchAvailableVerbs(link)); dispatch(fetchAvailableVerbs(link));
@@ -144,7 +145,4 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
export default connect( export default compose(connect(mapStateToProps, mapDispatchToProps), withTranslation("admin"))(RepositoryRoleForm);
mapStateToProps,
mapDispatchToProps
)(withTranslation("admin")(RepositoryRoleForm));

View File

@@ -1,6 +1,6 @@
import React from "react"; import React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { withRouter } from "react-router-dom"; import { withRouter, RouteComponentProps } from "react-router-dom";
import { WithTranslation, withTranslation } from "react-i18next"; import { WithTranslation, withTranslation } from "react-i18next";
import { History } from "history"; import { History } from "history";
import { RepositoryRole, PagedCollection } from "@scm-manager/ui-types"; import { RepositoryRole, PagedCollection } from "@scm-manager/ui-types";
@@ -16,7 +16,8 @@ import {
import PermissionRoleTable from "../components/PermissionRoleTable"; import PermissionRoleTable from "../components/PermissionRoleTable";
import { getRepositoryRolesLink } from "../../../modules/indexResource"; import { getRepositoryRolesLink } from "../../../modules/indexResource";
type Props = WithTranslation & { type Props = RouteComponentProps &
WithTranslation & {
baseUrl: string; baseUrl: string;
roles: RepositoryRole[]; roles: RepositoryRole[];
loading: boolean; loading: boolean;
@@ -32,7 +33,7 @@ type Props = WithTranslation & {
// dispatch functions // dispatch functions
fetchRolesByPage: (link: string, page: number) => void; fetchRolesByPage: (link: string, page: number) => void;
}; };
class RepositoryRoles extends React.Component<Props> { class RepositoryRoles extends React.Component<Props> {
componentDidMount() { componentDidMount() {
@@ -89,7 +90,7 @@ class RepositoryRoles extends React.Component<Props> {
} }
} }
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state: any, ownProps: Props) => {
const { match } = ownProps; const { match } = ownProps;
const roles = getRolesFromState(state); const roles = getRolesFromState(state);
const loading = isFetchRolesPending(state); const loading = isFetchRolesPending(state);
@@ -110,7 +111,7 @@ const mapStateToProps = (state, ownProps) => {
}; };
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
fetchRolesByPage: (link: string, page: number) => { fetchRolesByPage: (link: string, page: number) => {
dispatch(fetchRolesByPage(link, page)); dispatch(fetchRolesByPage(link, page));
@@ -118,9 +119,4 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
export default withRouter( export default withRouter(connect(mapStateToProps, mapDispatchToProps)(withTranslation("admin")(RepositoryRoles)));
connect(
mapStateToProps,
mapDispatchToProps
)(withTranslation("admin")(RepositoryRoles))
);

View File

@@ -10,6 +10,7 @@ import { getRepositoryRolesLink } from "../../../modules/indexResource";
import { fetchRoleByName, getFetchRoleFailure, getRoleByName, isFetchRolePending } from "../modules/roles"; import { fetchRoleByName, getFetchRoleFailure, getRoleByName, isFetchRolePending } from "../modules/roles";
import PermissionRoleDetail from "../components/PermissionRoleDetails"; import PermissionRoleDetail from "../components/PermissionRoleDetails";
import EditRepositoryRole from "./EditRepositoryRole"; import EditRepositoryRole from "./EditRepositoryRole";
import { compose } from "redux";
type Props = WithTranslation & { type Props = WithTranslation & {
roleName: string; roleName: string;
@@ -78,7 +79,7 @@ class SingleRepositoryRole extends React.Component<Props> {
} }
} }
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state: any, ownProps: Props) => {
const roleName = ownProps.match.params.role; const roleName = ownProps.match.params.role;
const role = getRoleByName(state, roleName); const role = getRoleByName(state, roleName);
const loading = isFetchRolePending(state, roleName); const loading = isFetchRolePending(state, roleName);
@@ -93,7 +94,7 @@ const mapStateToProps = (state, ownProps) => {
}; };
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
fetchRoleByName: (link: string, name: string) => { fetchRoleByName: (link: string, name: string) => {
dispatch(fetchRoleByName(link, name)); dispatch(fetchRoleByName(link, name));
@@ -101,9 +102,8 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
export default withRouter( export default compose(
connect( withRouter,
mapStateToProps, connect(mapStateToProps, mapDispatchToProps),
mapDispatchToProps withTranslation("admin")
)(withTranslation("admin")(SingleRepositoryRole)) )(SingleRepositoryRole);
);

View File

@@ -1,6 +1,7 @@
import React, { Component } from "react"; import React, { Component } from "react";
import Main from "./Main"; import Main from "./Main";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { compose } from "redux";
import { WithTranslation, withTranslation } from "react-i18next"; import { WithTranslation, withTranslation } from "react-i18next";
import { withRouter } from "react-router-dom"; import { withRouter } from "react-router-dom";
import { fetchMe, getFetchMeFailure, getMe, isAuthenticated, isFetchMePending } from "../modules/auth"; import { fetchMe, getFetchMeFailure, getMe, isAuthenticated, isFetchMePending } from "../modules/auth";
@@ -61,7 +62,7 @@ const mapDispatchToProps = (dispatch: any) => {
}; };
}; };
const mapStateToProps = state => { const mapStateToProps = (state: any) => {
const authenticated = isAuthenticated(state); const authenticated = isAuthenticated(state);
const me = getMe(state); const me = getMe(state);
const loading = isFetchMePending(state) || isFetchIndexResourcesPending(state); const loading = isFetchMePending(state) || isFetchIndexResourcesPending(state);
@@ -78,9 +79,4 @@ const mapStateToProps = state => {
}; };
}; };
export default withRouter( export default compose(withRouter, connect(mapStateToProps, mapDispatchToProps), withTranslation("commons"))(App);
connect(
mapStateToProps,
mapDispatchToProps
)(withTranslation("commons")(App))
);

View File

@@ -1,6 +1,7 @@
import React, { Component } from "react"; import React, { Component } from "react";
import App from "./App"; import App from "./App";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { compose } from "redux";
import { WithTranslation, withTranslation } from "react-i18next"; import { WithTranslation, withTranslation } from "react-i18next";
import { withRouter } from "react-router-dom"; import { withRouter } from "react-router-dom";
import { Loading, ErrorBoundary } from "@scm-manager/ui-components"; import { Loading, ErrorBoundary } from "@scm-manager/ui-components";
@@ -74,7 +75,7 @@ const mapDispatchToProps = (dispatch: any) => {
}; };
}; };
const mapStateToProps = state => { const mapStateToProps = (state: any) => {
const loading = isFetchIndexResourcesPending(state); const loading = isFetchIndexResourcesPending(state);
const error = getFetchIndexResourcesFailure(state); const error = getFetchIndexResourcesFailure(state);
const indexResources = getLinks(state); const indexResources = getLinks(state);
@@ -85,9 +86,4 @@ const mapStateToProps = state => {
}; };
}; };
export default withRouter( export default compose(withRouter, connect(mapStateToProps, mapDispatchToProps), withTranslation("commons"))(Index);
connect(
mapStateToProps,
mapDispatchToProps
)(withTranslation("commons")(Index))
);

View File

@@ -62,7 +62,7 @@ class Login extends React.Component<Props> {
} }
} }
const mapStateToProps = state => { const mapStateToProps = (state: any) => {
const authenticated = isAuthenticated(state); const authenticated = isAuthenticated(state);
const loading = isLoginPending(state); const loading = isLoginPending(state);
const error = getLoginFailure(state); const error = getLoginFailure(state);
@@ -77,16 +77,10 @@ const mapStateToProps = state => {
}; };
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
login: (loginLink: string, username: string, password: string) => dispatch(login(loginLink, username, password)) login: (loginLink: string, username: string, password: string) => dispatch(login(loginLink, username, password))
}; };
}; };
export default compose( export default compose(withRouter, connect(mapStateToProps, mapDispatchToProps))(Login);
withRouter,
connect(
mapStateToProps,
mapDispatchToProps
)
)(Login);

View File

@@ -35,7 +35,7 @@ class Logout extends React.Component<Props> {
} }
} }
const mapStateToProps = state => { const mapStateToProps = (state: any) => {
const authenticated = isAuthenticated(state); const authenticated = isAuthenticated(state);
const loading = isLogoutPending(state); const loading = isLogoutPending(state);
const redirecting = isRedirecting(state); const redirecting = isRedirecting(state);
@@ -50,13 +50,10 @@ const mapStateToProps = state => {
}; };
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
logout: (link: string) => dispatch(logout(link)) logout: (link: string) => dispatch(logout(link))
}; };
}; };
export default connect( export default connect(mapStateToProps, mapDispatchToProps)(withTranslation("commons")(Logout));
mapStateToProps,
mapDispatchToProps
)(withTranslation("commons")(Logout));

View File

@@ -78,14 +78,10 @@ class Profile extends React.Component<Props, State> {
} }
} }
const mapStateToProps = state => { const mapStateToProps = (state: any) => {
return { return {
me: getMe(state) me: getMe(state)
}; };
}; };
export default compose( export default compose(withTranslation("commons"), connect(mapStateToProps), withRouter)(Profile);
withTranslation("commons"),
connect(mapStateToProps),
withRouter
)(Profile);

View File

@@ -1,8 +1,9 @@
import React from "react"; import React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { compose } from "redux";
import { WithTranslation, withTranslation } from "react-i18next"; import { WithTranslation, withTranslation } from "react-i18next";
import { History } from "history"; import { History } from "history";
import { Group } from "@scm-manager/ui-types"; import { Group, DisplayedUser } from "@scm-manager/ui-types";
import { Page } from "@scm-manager/ui-components"; import { Page } from "@scm-manager/ui-components";
import { getGroupsLink, getUserAutoCompleteLink } from "../../modules/indexResource"; import { getGroupsLink, getUserAutoCompleteLink } from "../../modules/indexResource";
import { createGroup, isCreateGroupPending, getCreateGroupFailure, createGroupReset } from "../modules/groups"; import { createGroup, isCreateGroupPending, getCreateGroupFailure, createGroupReset } from "../modules/groups";
@@ -45,7 +46,7 @@ class CreateGroup extends React.Component<Props> {
.get(url + inputValue) .get(url + inputValue)
.then(response => response.json()) .then(response => response.json())
.then(json => { .then(json => {
return json.map(element => { return json.map((element: DisplayedUser) => {
return { return {
value: element, value: element,
label: `${element.displayName} (${element.id})` label: `${element.displayName} (${element.id})`
@@ -61,7 +62,7 @@ class CreateGroup extends React.Component<Props> {
}; };
} }
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
createGroup: (link: string, group: Group, callback?: () => void) => dispatch(createGroup(link, group, callback)), createGroup: (link: string, group: Group, callback?: () => void) => dispatch(createGroup(link, group, callback)),
resetForm: () => { resetForm: () => {
@@ -70,7 +71,7 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
const mapStateToProps = state => { const mapStateToProps = (state: any) => {
const loading = isCreateGroupPending(state); const loading = isCreateGroupPending(state);
const error = getCreateGroupFailure(state); const error = getCreateGroupFailure(state);
const createLink = getGroupsLink(state); const createLink = getGroupsLink(state);
@@ -83,7 +84,4 @@ const mapStateToProps = state => {
}; };
}; };
export default connect( export default compose(connect(mapStateToProps, mapDispatchToProps), withTranslation("groups"))(CreateGroup);
mapStateToProps,
mapDispatchToProps
)(withTranslation("groups")(CreateGroup));

View File

@@ -1,5 +1,6 @@
import React from "react"; import React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { compose } from "redux";
import { withRouter } from "react-router-dom"; import { withRouter } from "react-router-dom";
import { WithTranslation, withTranslation } from "react-i18next"; import { WithTranslation, withTranslation } from "react-i18next";
import { History } from "history"; import { History } from "history";
@@ -72,7 +73,7 @@ export class DeleteGroup extends React.Component<Props> {
} }
} }
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state: any, ownProps: Props) => {
const loading = isDeleteGroupPending(state, ownProps.group.name); const loading = isDeleteGroupPending(state, ownProps.group.name);
const error = getDeleteGroupFailure(state, ownProps.group.name); const error = getDeleteGroupFailure(state, ownProps.group.name);
return { return {
@@ -81,7 +82,7 @@ const mapStateToProps = (state, ownProps) => {
}; };
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
deleteGroup: (group: Group, callback?: () => void) => { deleteGroup: (group: Group, callback?: () => void) => {
dispatch(deleteGroup(group, callback)); dispatch(deleteGroup(group, callback));
@@ -89,7 +90,8 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
export default connect( export default compose(
mapStateToProps, connect(mapStateToProps, mapDispatchToProps),
mapDispatchToProps withRouter,
)(withRouter(withTranslation("groups")(DeleteGroup))); withTranslation("groups")
)(DeleteGroup);

View File

@@ -4,11 +4,12 @@ import GroupForm from "../components/GroupForm";
import { modifyGroup, getModifyGroupFailure, isModifyGroupPending, modifyGroupReset } from "../modules/groups"; import { modifyGroup, getModifyGroupFailure, isModifyGroupPending, modifyGroupReset } from "../modules/groups";
import { History } from "history"; import { History } from "history";
import { withRouter } from "react-router-dom"; import { withRouter } from "react-router-dom";
import { Group } from "@scm-manager/ui-types"; import { Group, DisplayedUser } from "@scm-manager/ui-types";
import { ErrorNotification } from "@scm-manager/ui-components"; import { ErrorNotification } from "@scm-manager/ui-components";
import { getUserAutoCompleteLink } from "../../modules/indexResource"; import { getUserAutoCompleteLink } from "../../modules/indexResource";
import DeleteGroup from "./DeleteGroup"; import DeleteGroup from "./DeleteGroup";
import { apiClient } from "@scm-manager/ui-components/src"; import { apiClient } from "@scm-manager/ui-components/src";
import { compose } from "redux";
type Props = { type Props = {
group: Group; group: Group;
@@ -41,7 +42,7 @@ class EditGroup extends React.Component<Props> {
.get(url + inputValue) .get(url + inputValue)
.then(response => response.json()) .then(response => response.json())
.then(json => { .then(json => {
return json.map(element => { return json.map((element: DisplayedUser) => {
return { return {
value: element, value: element,
label: `${element.displayName} (${element.id})` label: `${element.displayName} (${element.id})`
@@ -69,7 +70,7 @@ class EditGroup extends React.Component<Props> {
} }
} }
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state: any, ownProps: Props) => {
const loading = isModifyGroupPending(state, ownProps.group.name); const loading = isModifyGroupPending(state, ownProps.group.name);
const error = getModifyGroupFailure(state, ownProps.group.name); const error = getModifyGroupFailure(state, ownProps.group.name);
const autocompleteLink = getUserAutoCompleteLink(state); const autocompleteLink = getUserAutoCompleteLink(state);
@@ -80,7 +81,7 @@ const mapStateToProps = (state, ownProps) => {
}; };
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
modifyGroup: (group: Group, callback?: () => void) => { modifyGroup: (group: Group, callback?: () => void) => {
dispatch(modifyGroup(group, callback)); dispatch(modifyGroup(group, callback));
@@ -91,7 +92,4 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
export default connect( export default compose(connect(mapStateToProps, mapDispatchToProps), withRouter)(EditGroup);
mapStateToProps,
mapDispatchToProps
)(withRouter(EditGroup));

View File

@@ -1,6 +1,7 @@
import React from "react"; import React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { WithTranslation, withTranslation } from "react-i18next"; import { WithTranslation, withTranslation } from "react-i18next";
import { RouteComponentProps } from "react-router-dom";
import { History } from "history"; import { History } from "history";
import { Group, PagedCollection } from "@scm-manager/ui-types"; import { Group, PagedCollection } from "@scm-manager/ui-types";
import { import {
@@ -23,7 +24,8 @@ import {
} from "../modules/groups"; } from "../modules/groups";
import { GroupTable } from "./../components/table"; import { GroupTable } from "./../components/table";
type Props = WithTranslation & { type Props = RouteComponentProps &
WithTranslation & {
groups: Group[]; groups: Group[];
loading: boolean; loading: boolean;
error: Error; error: Error;
@@ -38,7 +40,7 @@ type Props = WithTranslation & {
// dispatch functions // dispatch functions
fetchGroupsByPage: (link: string, page: number, filter?: string) => void; fetchGroupsByPage: (link: string, page: number, filter?: string) => void;
}; };
class Groups extends React.Component<Props> { class Groups extends React.Component<Props> {
componentDidMount() { componentDidMount() {
@@ -100,7 +102,7 @@ class Groups extends React.Component<Props> {
} }
} }
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state: any, ownProps: Props) => {
const { match } = ownProps; const { match } = ownProps;
const groups = getGroupsFromState(state); const groups = getGroupsFromState(state);
const loading = isFetchGroupsPending(state); const loading = isFetchGroupsPending(state);
@@ -121,7 +123,7 @@ const mapStateToProps = (state, ownProps) => {
}; };
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
fetchGroupsByPage: (link: string, page: number, filter?: string) => { fetchGroupsByPage: (link: string, page: number, filter?: string) => {
dispatch(fetchGroupsByPage(link, page, filter)); dispatch(fetchGroupsByPage(link, page, filter));
@@ -129,7 +131,4 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
export default connect( export default connect(mapStateToProps, mapDispatchToProps)(withTranslation("groups")(Groups));
mapStateToProps,
mapDispatchToProps
)(withTranslation("groups")(Groups));

View File

@@ -94,7 +94,7 @@ class SingleGroup extends React.Component<Props> {
} }
} }
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state: any, ownProps: Props) => {
const name = ownProps.match.params.name; const name = ownProps.match.params.name;
const group = getGroupByName(state, name); const group = getGroupByName(state, name);
const loading = isFetchGroupPending(state, name); const loading = isFetchGroupPending(state, name);
@@ -110,7 +110,7 @@ const mapStateToProps = (state, ownProps) => {
}; };
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
fetchGroupByName: (link: string, name: string) => { fetchGroupByName: (link: string, name: string) => {
dispatch(fetchGroupByName(link, name)); dispatch(fetchGroupByName(link, name));
@@ -118,7 +118,4 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
export default connect( export default connect(mapStateToProps, mapDispatchToProps)(withTranslation("groups")(SingleGroup));
mapStateToProps,
mapDispatchToProps
)(withTranslation("groups")(SingleGroup));

View File

@@ -151,7 +151,7 @@ class SetPermissions extends React.Component<Props, State> {
}; };
} }
const mapStateToProps = state => { const mapStateToProps = (state: any) => {
const availablePermissionLink = getLink(state, "permissions"); const availablePermissionLink = getLink(state, "permissions");
return { return {
availablePermissionLink availablePermissionLink

View File

@@ -1,6 +1,7 @@
import React from "react"; import React from "react";
import BranchView from "../components/BranchView"; import BranchView from "../components/BranchView";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { compose } from "redux";
import { Redirect, Route, Switch, withRouter } from "react-router-dom"; import { Redirect, Route, Switch, withRouter } from "react-router-dom";
import { Repository, Branch } from "@scm-manager/ui-types"; import { Repository, Branch } from "@scm-manager/ui-types";
import { fetchBranch, getBranch, getFetchBranchFailure, isFetchBranchPending } from "../modules/branches"; import { fetchBranch, getBranch, getFetchBranchFailure, isFetchBranchPending } from "../modules/branches";
@@ -28,7 +29,6 @@ type Props = {
class BranchRoot extends React.Component<Props> { class BranchRoot extends React.Component<Props> {
componentDidMount() { componentDidMount() {
const { fetchBranch, repository, branchName } = this.props; const { fetchBranch, repository, branchName } = this.props;
fetchBranch(repository, branchName); fetchBranch(repository, branchName);
} }
@@ -96,9 +96,4 @@ const mapDispatchToProps = (dispatch: any) => {
}; };
}; };
export default withRouter( export default compose(withRouter, connect(mapStateToProps, mapDispatchToProps))(BranchRoot);
connect(
mapStateToProps,
mapDispatchToProps
)(BranchRoot)
);

View File

@@ -75,7 +75,7 @@ class BranchesOverview extends React.Component<Props> {
} }
} }
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state: any, ownProps: Props) => {
const { repository } = ownProps; const { repository } = ownProps;
const loading = isFetchBranchesPending(state, repository); const loading = isFetchBranchesPending(state, repository);
const error = getFetchBranchesFailure(state, repository); const error = getFetchBranchesFailure(state, repository);
@@ -91,7 +91,7 @@ const mapStateToProps = (state, ownProps) => {
}; };
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
fetchBranches: (repository: Repository) => { fetchBranches: (repository: Repository) => {
dispatch(fetchBranches(repository)); dispatch(fetchBranches(repository));
@@ -102,8 +102,5 @@ const mapDispatchToProps = dispatch => {
export default compose( export default compose(
withTranslation("repos"), withTranslation("repos"),
withRouter, withRouter,
connect( connect(mapStateToProps, mapDispatchToProps)
mapStateToProps,
mapDispatchToProps
)
)(BranchesOverview); )(BranchesOverview);

View File

@@ -20,7 +20,7 @@ const CodeViewSwitcher: FC<Props> = ({ url }) => {
const createDestinationUrl = (destination: string) => { const createDestinationUrl = (destination: string) => {
let splittedUrl = url.split("/"); let splittedUrl = url.split("/");
splittedUrl[5] = destination; splittedUrl[5] = destination;
return splittedUrl.join("/") return splittedUrl.join("/");
}; };
return ( return (

View File

@@ -8,8 +8,8 @@ import * as validator from "./repositoryValidation";
type Props = WithTranslation & { type Props = WithTranslation & {
submitForm: (p: Repository) => void; submitForm: (p: Repository) => void;
repository?: Repository; repository?: Repository;
repositoryTypes: RepositoryType[]; repositoryTypes?: RepositoryType[];
namespaceStrategy: string; namespaceStrategy?: string;
loading?: boolean; loading?: boolean;
}; };
@@ -127,7 +127,8 @@ class RepositoryForm extends React.Component<Props, State> {
); );
} }
createSelectOptions(repositoryTypes: RepositoryType[]) { createSelectOptions(repositoryTypes?: RepositoryType[]) {
if (repositoryTypes) {
return repositoryTypes.map(repositoryType => { return repositoryTypes.map(repositoryType => {
return { return {
label: repositoryType.displayName, label: repositoryType.displayName,
@@ -135,6 +136,8 @@ class RepositoryForm extends React.Component<Props, State> {
}; };
}); });
} }
return [];
}
renderNamespaceField = () => { renderNamespaceField = () => {
const { namespaceStrategy, t } = this.props; const { namespaceStrategy, t } = this.props;

View File

@@ -1,5 +1,6 @@
import React from "react"; import React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { compose } from "redux";
import { withRouter } from "react-router-dom"; import { withRouter } from "react-router-dom";
import { WithTranslation, withTranslation } from "react-i18next"; import { WithTranslation, withTranslation } from "react-i18next";
import { Changeset, Repository } from "@scm-manager/ui-types"; import { Changeset, Repository } from "@scm-manager/ui-types";
@@ -42,7 +43,7 @@ class ChangesetView extends React.Component<Props> {
} }
} }
const mapStateToProps = (state, ownProps: Props) => { const mapStateToProps = (state: any, ownProps: Props) => {
const repository = ownProps.repository; const repository = ownProps.repository;
const id = ownProps.match.params.id; const id = ownProps.match.params.id;
const changeset = getChangeset(state, repository, id); const changeset = getChangeset(state, repository, id);
@@ -55,7 +56,7 @@ const mapStateToProps = (state, ownProps: Props) => {
}; };
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
fetchChangesetIfNeeded: (repository: Repository, id: string) => { fetchChangesetIfNeeded: (repository: Repository, id: string) => {
dispatch(fetchChangesetIfNeeded(repository, id)); dispatch(fetchChangesetIfNeeded(repository, id));
@@ -63,9 +64,8 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
export default withRouter( export default compose(
connect( withRouter,
mapStateToProps, connect(mapStateToProps, mapDispatchToProps),
mapDispatchToProps withTranslation("repos")
)(withTranslation("repos")(ChangesetView)) )(ChangesetView);
);

View File

@@ -76,7 +76,7 @@ class Create extends React.Component<Props> {
} }
} }
const mapStateToProps = state => { const mapStateToProps = (state: any) => {
const repositoryTypes = getRepositoryTypes(state); const repositoryTypes = getRepositoryTypes(state);
const namespaceStrategies = getNamespaceStrategies(state); const namespaceStrategies = getNamespaceStrategies(state);
const pageLoading = isFetchRepositoryTypesPending(state) || isFetchNamespaceStrategiesPending(state); const pageLoading = isFetchRepositoryTypesPending(state) || isFetchNamespaceStrategiesPending(state);
@@ -94,7 +94,7 @@ const mapStateToProps = state => {
}; };
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
fetchRepositoryTypesIfNeeded: () => { fetchRepositoryTypesIfNeeded: () => {
dispatch(fetchRepositoryTypesIfNeeded()); dispatch(fetchRepositoryTypesIfNeeded());
@@ -111,7 +111,4 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
export default connect( export default connect(mapStateToProps, mapDispatchToProps)(withTranslation("repos")(Create));
mapStateToProps,
mapDispatchToProps
)(withTranslation("repos")(Create));

View File

@@ -1,5 +1,6 @@
import React from "react"; import React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { compose } from "redux";
import { withRouter } from "react-router-dom"; import { withRouter } from "react-router-dom";
import { WithTranslation, withTranslation } from "react-i18next"; import { WithTranslation, withTranslation } from "react-i18next";
import { History } from "history"; import { History } from "history";
@@ -72,7 +73,7 @@ class DeleteRepo extends React.Component<Props> {
} }
} }
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state: any, ownProps: Props) => {
const { namespace, name } = ownProps.repository; const { namespace, name } = ownProps.repository;
const loading = isDeleteRepoPending(state, namespace, name); const loading = isDeleteRepoPending(state, namespace, name);
const error = getDeleteRepoFailure(state, namespace, name); const error = getDeleteRepoFailure(state, namespace, name);
@@ -82,7 +83,7 @@ const mapStateToProps = (state, ownProps) => {
}; };
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
deleteRepo: (repo: Repository, callback: () => void) => { deleteRepo: (repo: Repository, callback: () => void) => {
dispatch(deleteRepo(repo, callback)); dispatch(deleteRepo(repo, callback));
@@ -90,7 +91,4 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
export default connect( export default compose(connect(mapStateToProps, mapDispatchToProps), withRouter, withTranslation("repos"))(DeleteRepo);
mapStateToProps,
mapDispatchToProps
)(withRouter(withTranslation("repos")(DeleteRepo)));

View File

@@ -8,6 +8,7 @@ import { modifyRepo, isModifyRepoPending, getModifyRepoFailure, modifyRepoReset
import { History } from "history"; import { History } from "history";
import { ErrorNotification } from "@scm-manager/ui-components"; import { ErrorNotification } from "@scm-manager/ui-components";
import { ExtensionPoint } from "@scm-manager/ui-extensions"; import { ExtensionPoint } from "@scm-manager/ui-extensions";
import { compose } from "redux";
type Props = { type Props = {
loading: boolean; loading: boolean;
@@ -71,7 +72,7 @@ class EditRepo extends React.Component<Props> {
} }
} }
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state: any, ownProps: Props) => {
const { namespace, name } = ownProps.repository; const { namespace, name } = ownProps.repository;
const loading = isModifyRepoPending(state, namespace, name); const loading = isModifyRepoPending(state, namespace, name);
const error = getModifyRepoFailure(state, namespace, name); const error = getModifyRepoFailure(state, namespace, name);
@@ -81,7 +82,7 @@ const mapStateToProps = (state, ownProps) => {
}; };
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
modifyRepo: (repo: Repository, callback: () => void) => { modifyRepo: (repo: Repository, callback: () => void) => {
dispatch(modifyRepo(repo, callback)); dispatch(modifyRepo(repo, callback));
@@ -92,7 +93,4 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
export default connect( export default compose(connect(mapStateToProps, mapDispatchToProps), withRouter)(EditRepo);
mapStateToProps,
mapDispatchToProps
)(withRouter(EditRepo));

View File

@@ -1,6 +1,6 @@
import React from "react"; import React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { withRouter } from "react-router-dom"; import { withRouter, RouteComponentProps } from "react-router-dom";
import { WithTranslation, withTranslation } from "react-i18next"; import { WithTranslation, withTranslation } from "react-i18next";
import { History } from "history"; import { History } from "history";
import { RepositoryCollection } from "@scm-manager/ui-types"; import { RepositoryCollection } from "@scm-manager/ui-types";
@@ -23,7 +23,7 @@ import {
} from "../modules/repos"; } from "../modules/repos";
import RepositoryList from "../components/list"; import RepositoryList from "../components/list";
type Props = WithTranslation & { type Props = WithTranslation & RouteComponentProps & {
loading: boolean; loading: boolean;
error: Error; error: Error;
showCreateButton: boolean; showCreateButton: boolean;
@@ -103,7 +103,7 @@ class Overview extends React.Component<Props> {
} }
} }
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state: any, ownProps: Props) => {
const { match } = ownProps; const { match } = ownProps;
const collection = getRepositoryCollection(state); const collection = getRepositoryCollection(state);
const loading = isFetchReposPending(state); const loading = isFetchReposPending(state);
@@ -121,14 +121,11 @@ const mapStateToProps = (state, ownProps) => {
}; };
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
fetchReposByPage: (link: string, page: number, filter?: string) => { fetchReposByPage: (link: string, page: number, filter?: string) => {
dispatch(fetchReposByPage(link, page, filter)); dispatch(fetchReposByPage(link, page, filter));
} }
}; };
}; };
export default connect( export default connect(mapStateToProps, mapDispatchToProps)(withTranslation("repos")(withRouter(Overview)));
mapStateToProps,
mapDispatchToProps
)(withTranslation("repos")(withRouter(Overview)));

View File

@@ -175,7 +175,7 @@ class Permissions extends React.Component<Props> {
} }
} }
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state: any, ownProps: Props) => {
const namespace = ownProps.namespace; const namespace = ownProps.namespace;
const repoName = ownProps.repoName; const repoName = ownProps.repoName;
const error = const error =
@@ -216,7 +216,7 @@ const mapStateToProps = (state, ownProps) => {
}; };
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
fetchPermissions: (link: string, namespace: string, repoName: string) => { fetchPermissions: (link: string, namespace: string, repoName: string) => {
dispatch(fetchPermissions(link, namespace, repoName)); dispatch(fetchPermissions(link, namespace, repoName));
@@ -245,7 +245,4 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
export default connect( export default connect(mapStateToProps, mapDispatchToProps)(withTranslation("repos")(Permissions));
mapStateToProps,
mapDispatchToProps
)(withTranslation("repos")(Permissions));

View File

@@ -208,7 +208,7 @@ class SinglePermission extends React.Component<Props, State> {
}; };
} }
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state: any, ownProps: Props) => {
const permission = ownProps.permission; const permission = ownProps.permission;
const loading = isModifyPermissionPending(state, ownProps.namespace, ownProps.repoName, permission); const loading = isModifyPermissionPending(state, ownProps.namespace, ownProps.repoName, permission);
const deleteLoading = isDeletePermissionPending(state, ownProps.namespace, ownProps.repoName, permission); const deleteLoading = isDeletePermissionPending(state, ownProps.namespace, ownProps.repoName, permission);
@@ -219,7 +219,7 @@ const mapStateToProps = (state, ownProps) => {
}; };
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
modifyPermission: (permission: Permission, namespace: string, repoName: string) => { modifyPermission: (permission: Permission, namespace: string, repoName: string) => {
dispatch(modifyPermission(permission, namespace, repoName)); dispatch(modifyPermission(permission, namespace, repoName));
@@ -229,7 +229,4 @@ const mapDispatchToProps = dispatch => {
} }
}; };
}; };
export default connect( export default connect(mapStateToProps, mapDispatchToProps)(withTranslation("repos")(SinglePermission));
mapStateToProps,
mapDispatchToProps
)(withTranslation("repos")(SinglePermission));

View File

@@ -174,10 +174,4 @@ const mapStateToProps = (state: any, ownProps: Props) => {
}; };
}; };
export default compose( export default compose(withRouter, connect(mapStateToProps, mapDispatchToProps))(withTranslation("repos")(FileTree));
withRouter,
connect(
mapStateToProps,
mapDispatchToProps
)
)(withTranslation("repos")(FileTree));

View File

@@ -88,14 +88,16 @@ class FileTreeLeaf extends React.Component<Props> {
render() { render() {
const { file } = this.props; const { file } = this.props;
const renderFileSize = (file: File) => <FileSize bytes={file.length} />; const renderFileSize = (file: File) => <FileSize bytes={file?.length ? file.length : 0} />;
const renderCommitDate = (file: File) => <DateFromNow date={file.commitDate} />; const renderCommitDate = (file: File) => <DateFromNow date={file.commitDate} />;
return ( return (
<tr> <tr>
<td>{this.createFileIcon(file)}</td> <td>{this.createFileIcon(file)}</td>
<MinWidthTd className="is-word-break">{this.createFileName(file)}</MinWidthTd> <MinWidthTd className="is-word-break">{this.createFileName(file)}</MinWidthTd>
<NoWrapTd className="is-hidden-mobile">{file.directory ? "" : this.contentIfPresent(file, "length", renderFileSize)}</NoWrapTd> <NoWrapTd className="is-hidden-mobile">
{file.directory ? "" : this.contentIfPresent(file, "length", renderFileSize)}
</NoWrapTd>
<td className="is-hidden-mobile">{this.contentIfPresent(file, "commitDate", renderCommitDate)}</td> <td className="is-hidden-mobile">{this.contentIfPresent(file, "commitDate", renderCommitDate)}</td>
<MinWidthTd className={classNames("is-word-break", "is-hidden-touch")}> <MinWidthTd className={classNames("is-word-break", "is-hidden-touch")}>
{this.contentIfPresent(file, "description", file => file.description)} {this.contentIfPresent(file, "description", file => file.description)}

View File

@@ -85,9 +85,4 @@ const mapDispatchToProps = (dispatch: any) => {
}; };
}; };
export default withRouter( export default withRouter(connect(mapStateToProps, mapDispatchToProps)(withTranslation("repos")(SourceExtensions)));
connect(
mapStateToProps,
mapDispatchToProps
)(withTranslation("repos")(SourceExtensions))
);

View File

@@ -1,5 +1,6 @@
import React from "react"; import React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { compose } from "redux";
import { WithTranslation, withTranslation } from "react-i18next"; import { WithTranslation, withTranslation } from "react-i18next";
import { History } from "history"; import { History } from "history";
import { User } from "@scm-manager/ui-types"; import { User } from "@scm-manager/ui-types";
@@ -46,7 +47,7 @@ class CreateUser extends React.Component<Props> {
} }
} }
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
addUser: (link: string, user: User, callback?: () => void) => { addUser: (link: string, user: User, callback?: () => void) => {
dispatch(createUser(link, user, callback)); dispatch(createUser(link, user, callback));
@@ -57,7 +58,7 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state: any) => {
const loading = isCreateUserPending(state); const loading = isCreateUserPending(state);
const error = getCreateUserFailure(state); const error = getCreateUserFailure(state);
const usersLink = getUsersLink(state); const usersLink = getUsersLink(state);
@@ -68,7 +69,4 @@ const mapStateToProps = (state, ownProps) => {
}; };
}; };
export default connect( export default compose(connect(mapStateToProps, mapDispatchToProps), withTranslation("users"))(CreateUser);
mapStateToProps,
mapDispatchToProps
)(withTranslation("users")(CreateUser));

View File

@@ -1,5 +1,6 @@
import React from "react"; import React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { compose } from "redux";
import { withRouter } from "react-router-dom"; import { withRouter } from "react-router-dom";
import { WithTranslation, withTranslation } from "react-i18next"; import { WithTranslation, withTranslation } from "react-i18next";
import { History } from "history"; import { History } from "history";
@@ -72,7 +73,7 @@ class DeleteUser extends React.Component<Props> {
} }
} }
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state: any, ownProps: Props) => {
const loading = isDeleteUserPending(state, ownProps.user.name); const loading = isDeleteUserPending(state, ownProps.user.name);
const error = getDeleteUserFailure(state, ownProps.user.name); const error = getDeleteUserFailure(state, ownProps.user.name);
return { return {
@@ -81,7 +82,7 @@ const mapStateToProps = (state, ownProps) => {
}; };
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
deleteUser: (user: User, callback?: () => void) => { deleteUser: (user: User, callback?: () => void) => {
dispatch(deleteUser(user, callback)); dispatch(deleteUser(user, callback));
@@ -89,7 +90,4 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
export default connect( export default compose(connect(mapStateToProps, mapDispatchToProps), withRouter, withTranslation("users"))(DeleteUser);
mapStateToProps,
mapDispatchToProps
)(withRouter(withTranslation("users")(DeleteUser)));

View File

@@ -7,6 +7,7 @@ import { User } from "@scm-manager/ui-types";
import { modifyUser, isModifyUserPending, getModifyUserFailure, modifyUserReset } from "../modules/users"; import { modifyUser, isModifyUserPending, getModifyUserFailure, modifyUserReset } from "../modules/users";
import { History } from "history"; import { History } from "history";
import { ErrorNotification } from "@scm-manager/ui-components"; import { ErrorNotification } from "@scm-manager/ui-components";
import { compose } from "redux";
type Props = { type Props = {
loading: boolean; loading: boolean;
@@ -47,7 +48,7 @@ class EditUser extends React.Component<Props> {
} }
} }
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state: any, ownProps: Props) => {
const loading = isModifyUserPending(state, ownProps.user.name); const loading = isModifyUserPending(state, ownProps.user.name);
const error = getModifyUserFailure(state, ownProps.user.name); const error = getModifyUserFailure(state, ownProps.user.name);
return { return {
@@ -56,7 +57,7 @@ const mapStateToProps = (state, ownProps) => {
}; };
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
modifyUser: (user: User, callback?: () => void) => { modifyUser: (user: User, callback?: () => void) => {
dispatch(modifyUser(user, callback)); dispatch(modifyUser(user, callback));
@@ -67,7 +68,4 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
export default connect( export default compose(connect(mapStateToProps, mapDispatchToProps), withRouter)(EditUser);
mapStateToProps,
mapDispatchToProps
)(withRouter(EditUser));

View File

@@ -95,7 +95,7 @@ class SingleUser extends React.Component<Props> {
} }
} }
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state: any, ownProps: Props) => {
const name = ownProps.match.params.name; const name = ownProps.match.params.name;
const user = getUserByName(state, name); const user = getUserByName(state, name);
const loading = isFetchUserPending(state, name); const loading = isFetchUserPending(state, name);
@@ -110,7 +110,7 @@ const mapStateToProps = (state, ownProps) => {
}; };
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
fetchUserByName: (link: string, name: string) => { fetchUserByName: (link: string, name: string) => {
dispatch(fetchUserByName(link, name)); dispatch(fetchUserByName(link, name));
@@ -118,7 +118,4 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
export default connect( export default connect(mapStateToProps, mapDispatchToProps)(withTranslation("users")(SingleUser));
mapStateToProps,
mapDispatchToProps
)(withTranslation("users")(SingleUser));

View File

@@ -1,6 +1,7 @@
import React from "react"; import React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { WithTranslation, withTranslation } from "react-i18next"; import { WithTranslation, withTranslation } from "react-i18next";
import { RouteComponentProps } from "react-router-dom";
import { History } from "history"; import { History } from "history";
import { User, PagedCollection } from "@scm-manager/ui-types"; import { User, PagedCollection } from "@scm-manager/ui-types";
import { import {
@@ -23,7 +24,8 @@ import {
} from "../modules/users"; } from "../modules/users";
import { UserTable } from "./../components/table"; import { UserTable } from "./../components/table";
type Props = WithTranslation & { type Props = RouteComponentProps &
WithTranslation & {
users: User[]; users: User[];
loading: boolean; loading: boolean;
error: Error; error: Error;
@@ -38,7 +40,7 @@ type Props = WithTranslation & {
// dispatch functions // dispatch functions
fetchUsersByPage: (link: string, page: number, filter?: string) => void; fetchUsersByPage: (link: string, page: number, filter?: string) => void;
}; };
class Users extends React.Component<Props> { class Users extends React.Component<Props> {
componentDidMount() { componentDidMount() {
@@ -100,7 +102,7 @@ class Users extends React.Component<Props> {
} }
} }
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state: any, ownProps: Props) => {
const { match } = ownProps; const { match } = ownProps;
const users = getUsersFromState(state); const users = getUsersFromState(state);
const loading = isFetchUsersPending(state); const loading = isFetchUsersPending(state);
@@ -121,7 +123,7 @@ const mapStateToProps = (state, ownProps) => {
}; };
}; };
const mapDispatchToProps = dispatch => { const mapDispatchToProps = (dispatch: any) => {
return { return {
fetchUsersByPage: (link: string, page: number, filter?: string) => { fetchUsersByPage: (link: string, page: number, filter?: string) => {
dispatch(fetchUsersByPage(link, page, filter)); dispatch(fetchUsersByPage(link, page, filter));
@@ -129,7 +131,4 @@ const mapDispatchToProps = dispatch => {
}; };
}; };
export default connect( export default connect(mapStateToProps, mapDispatchToProps)(withTranslation("users")(Users));
mapStateToProps,
mapDispatchToProps
)(withTranslation("users")(Users));