From a43ffacf03cb65f0dadc7798704e9951c67faa2a Mon Sep 17 00:00:00 2001 From: Eduard Heimbuch Date: Wed, 8 Jan 2020 13:40:07 +0100 Subject: [PATCH] fix a ton of typescript errors --- scm-ui/ui-components/src/forms/DropDown.tsx | 2 +- .../components/table/ArrayConfigTable.tsx | 34 +++++++------- .../ui-webapp/src/admin/containers/Admin.tsx | 5 +-- .../src/admin/containers/GlobalConfig.tsx | 10 ++--- .../plugins/containers/PluginsOverview.tsx | 21 ++++----- .../roles/containers/CreateRepositoryRole.tsx | 12 +++-- .../roles/containers/DeleteRepositoryRole.tsx | 14 +++--- .../roles/containers/EditRepositoryRole.tsx | 15 ++++--- .../roles/containers/RepositoryRoleForm.tsx | 10 ++--- .../roles/containers/RepositoryRoles.tsx | 44 +++++++++---------- .../roles/containers/SingleRepositoryRole.tsx | 16 +++---- scm-ui/ui-webapp/src/containers/App.tsx | 10 ++--- scm-ui/ui-webapp/src/containers/Index.tsx | 10 ++--- scm-ui/ui-webapp/src/containers/Login.tsx | 12 ++--- scm-ui/ui-webapp/src/containers/Logout.tsx | 9 ++-- scm-ui/ui-webapp/src/containers/Profile.tsx | 8 +--- .../src/groups/containers/CreateGroup.tsx | 14 +++--- .../src/groups/containers/DeleteGroup.tsx | 14 +++--- .../src/groups/containers/EditGroup.tsx | 14 +++--- .../src/groups/containers/Groups.tsx | 39 ++++++++-------- .../src/groups/containers/SingleGroup.tsx | 9 ++-- .../permissions/components/SetPermissions.tsx | 2 +- .../repos/branches/containers/BranchRoot.tsx | 9 +--- .../branches/containers/BranchesOverview.tsx | 9 ++-- .../components/CodeViewSwitcher.tsx | 2 +- .../repos/components/form/RepositoryForm.tsx | 21 +++++---- .../src/repos/containers/ChangesetView.tsx | 16 +++---- .../ui-webapp/src/repos/containers/Create.tsx | 9 ++-- .../src/repos/containers/DeleteRepo.tsx | 10 ++--- .../src/repos/containers/EditRepo.tsx | 10 ++--- .../src/repos/containers/Overview.tsx | 13 +++--- .../permissions/containers/Permissions.tsx | 9 ++-- .../containers/SinglePermission.tsx | 9 ++-- .../src/repos/sources/components/FileTree.tsx | 8 +--- .../repos/sources/components/FileTreeLeaf.tsx | 6 ++- .../sources/containers/SourceExtensions.tsx | 7 +-- .../src/users/containers/CreateUser.tsx | 10 ++--- .../src/users/containers/DeleteUser.tsx | 10 ++--- .../src/users/containers/EditUser.tsx | 10 ++--- .../src/users/containers/SingleUser.tsx | 9 ++-- .../ui-webapp/src/users/containers/Users.tsx | 39 ++++++++-------- 41 files changed, 229 insertions(+), 311 deletions(-) diff --git a/scm-ui/ui-components/src/forms/DropDown.tsx b/scm-ui/ui-components/src/forms/DropDown.tsx index 97b31d4413..dac9af2880 100644 --- a/scm-ui/ui-components/src/forms/DropDown.tsx +++ b/scm-ui/ui-components/src/forms/DropDown.tsx @@ -15,7 +15,7 @@ class DropDown extends React.Component { const { options, optionValues, preselectedOption, className, disabled } = this.props; if (preselectedOption && !options.includes(preselectedOption)) { - options.unshift(preselectedOption) + options.unshift(preselectedOption); } return ( diff --git a/scm-ui/ui-webapp/src/admin/components/table/ArrayConfigTable.tsx b/scm-ui/ui-webapp/src/admin/components/table/ArrayConfigTable.tsx index 71097219a0..02edfb7d3f 100644 --- a/scm-ui/ui-webapp/src/admin/components/table/ArrayConfigTable.tsx +++ b/scm-ui/ui-webapp/src/admin/components/table/ArrayConfigTable.tsx @@ -13,27 +13,27 @@ type Props = { class ArrayConfigTable extends React.Component { render() { const { label, disabled, removeLabel, items, helpText } = this.props; - if(items.length > 0) { + if (items.length > 0) { return ( <> - + - {items.map(item => { - return ( - - - - - ); - })} + {items.map(item => { + return ( + + + + + ); + })}
{item} - -
{item} + +
diff --git a/scm-ui/ui-webapp/src/admin/containers/Admin.tsx b/scm-ui/ui-webapp/src/admin/containers/Admin.tsx index 7227725843..f93e0ed282 100644 --- a/scm-ui/ui-webapp/src/admin/containers/Admin.tsx +++ b/scm-ui/ui-webapp/src/admin/containers/Admin.tsx @@ -147,7 +147,4 @@ const mapStateToProps = (state: any) => { }; }; -export default compose( - connect(mapStateToProps), - withTranslation("admin") -)(Admin); +export default compose(connect(mapStateToProps), withTranslation("admin"))(Admin); diff --git a/scm-ui/ui-webapp/src/admin/containers/GlobalConfig.tsx b/scm-ui/ui-webapp/src/admin/containers/GlobalConfig.tsx index 3872205145..956fa98a36 100644 --- a/scm-ui/ui-webapp/src/admin/containers/GlobalConfig.tsx +++ b/scm-ui/ui-webapp/src/admin/containers/GlobalConfig.tsx @@ -22,6 +22,7 @@ import { getNamespaceStrategies, isFetchNamespaceStrategiesPending } from "../modules/namespaceStrategies"; +import { compose } from "redux"; type Props = WithTranslation & { loading: boolean; @@ -137,7 +138,7 @@ class GlobalConfig extends React.Component { }; } -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch: any) => { return { fetchConfig: (link: string) => { dispatch(fetchConfig(link)); @@ -154,7 +155,7 @@ const mapDispatchToProps = dispatch => { }; }; -const mapStateToProps = state => { +const mapStateToProps = (state: any) => { const loading = isFetchConfigPending(state) || isModifyConfigPending(state) || isFetchNamespaceStrategiesPending(state); const error = @@ -175,7 +176,4 @@ const mapStateToProps = state => { }; }; -export default connect( - mapStateToProps, - mapDispatchToProps -)(withTranslation("config")(GlobalConfig)); +export default compose(connect(mapStateToProps, mapDispatchToProps), withTranslation("config"))(GlobalConfig); diff --git a/scm-ui/ui-webapp/src/admin/plugins/containers/PluginsOverview.tsx b/scm-ui/ui-webapp/src/admin/plugins/containers/PluginsOverview.tsx index ab670c1ba8..55c0bacbcb 100644 --- a/scm-ui/ui-webapp/src/admin/plugins/containers/PluginsOverview.tsx +++ b/scm-ui/ui-webapp/src/admin/plugins/containers/PluginsOverview.tsx @@ -31,6 +31,7 @@ import PluginBottomActions from "../components/PluginBottomActions"; import ExecutePendingActionModal from "../components/ExecutePendingActionModal"; import CancelPendingActionModal from "../components/CancelPendingActionModal"; import UpdateAllActionModal from "../components/UpdateAllActionModal"; +import {Plugin} from "@scm-manager/ui-types/src"; type Props = WithTranslation & { loading: boolean; @@ -68,7 +69,7 @@ class PluginsOverview extends React.Component { this.fetchPlugins(); } - componentDidUpdate(prevProps) { + componentDidUpdate(prevProps: Props) { const { installed } = this.props; if (prevProps.installed !== installed) { this.fetchPlugins(); @@ -90,7 +91,7 @@ class PluginsOverview extends React.Component { } }; - renderHeader = (actions: React.Node) => { + renderHeader = (actions: React.ReactNode) => { const { installed, t } = this.props; return (
@@ -103,7 +104,7 @@ class PluginsOverview extends React.Component { ); }; - renderFooter = (actions: React.Node) => { + renderFooter = (actions: React.ReactNode) => { if (actions) { return {actions}; } @@ -173,7 +174,7 @@ class PluginsOverview extends React.Component { computeUpdateAllSize = () => { 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", { count: outdatedPlugins }); @@ -256,7 +257,7 @@ class PluginsOverview extends React.Component { } } -const mapStateToProps = state => { +const mapStateToProps = (state: any) => { const collection = getPluginCollection(state); const loading = isFetchPluginsPending(state); const error = getFetchPluginsFailure(state); @@ -276,7 +277,7 @@ const mapStateToProps = state => { }; }; -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch: any) => { return { fetchPluginsByLink: (link: string) => { dispatch(fetchPluginsByLink(link)); @@ -287,10 +288,4 @@ const mapDispatchToProps = dispatch => { }; }; -export default compose( - withTranslation("admin"), - connect( - mapStateToProps, - mapDispatchToProps - ) -)(PluginsOverview); +export default compose(withTranslation("admin"), connect(mapStateToProps, mapDispatchToProps))(PluginsOverview); diff --git a/scm-ui/ui-webapp/src/admin/roles/containers/CreateRepositoryRole.tsx b/scm-ui/ui-webapp/src/admin/roles/containers/CreateRepositoryRole.tsx index 63ce9d26ec..8e9e504d75 100644 --- a/scm-ui/ui-webapp/src/admin/roles/containers/CreateRepositoryRole.tsx +++ b/scm-ui/ui-webapp/src/admin/roles/containers/CreateRepositoryRole.tsx @@ -1,5 +1,6 @@ import React from "react"; import { connect } from "react-redux"; +import { compose } from "redux"; import { WithTranslation, withTranslation } from "react-i18next"; import { History } from "history"; import { RepositoryRole } from "@scm-manager/ui-types"; @@ -38,13 +39,13 @@ class CreateRepositoryRole extends React.Component { <> <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 error = getFetchVerbsFailure(state) || getCreateRoleFailure(state); const verbsLink = getRepositoryVerbsLink(state); @@ -58,7 +59,7 @@ const mapStateToProps = (state) => { }; }; -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch: any) => { return { addRole: (link: string, role: RepositoryRole, callback?: () => void) => { dispatch(createRole(link, role, callback)); @@ -66,7 +67,4 @@ const mapDispatchToProps = dispatch => { }; }; -export default connect( - mapStateToProps, - mapDispatchToProps -)(withTranslation("admin")(CreateRepositoryRole)); +export default compose(connect(mapStateToProps, mapDispatchToProps), withTranslation("admin"))(CreateRepositoryRole); diff --git a/scm-ui/ui-webapp/src/admin/roles/containers/DeleteRepositoryRole.tsx b/scm-ui/ui-webapp/src/admin/roles/containers/DeleteRepositoryRole.tsx index 93efa5b3dc..4314be9ebd 100644 --- a/scm-ui/ui-webapp/src/admin/roles/containers/DeleteRepositoryRole.tsx +++ b/scm-ui/ui-webapp/src/admin/roles/containers/DeleteRepositoryRole.tsx @@ -1,5 +1,6 @@ import React from "react"; import { connect } from "react-redux"; +import { compose } from "redux"; import { withRouter } from "react-router-dom"; import { WithTranslation, withTranslation } from "react-i18next"; 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 error = getDeleteRoleFailure(state, ownProps.role.name); return { @@ -81,7 +82,7 @@ const mapStateToProps = (state, ownProps) => { }; }; -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch: any) => { return { deleteRole: (role: RepositoryRole, callback?: () => void) => { dispatch(deleteRole(role, callback)); @@ -89,7 +90,8 @@ const mapDispatchToProps = dispatch => { }; }; -export default connect( - mapStateToProps, - mapDispatchToProps -)(withRouter(withTranslation("admin")(DeleteRepositoryRole))); +export default compose( + connect(mapStateToProps, mapDispatchToProps), + withRouter, + withTranslation("admin") +)(DeleteRepositoryRole); diff --git a/scm-ui/ui-webapp/src/admin/roles/containers/EditRepositoryRole.tsx b/scm-ui/ui-webapp/src/admin/roles/containers/EditRepositoryRole.tsx index 7114a8efc7..07f61d59c7 100644 --- a/scm-ui/ui-webapp/src/admin/roles/containers/EditRepositoryRole.tsx +++ b/scm-ui/ui-webapp/src/admin/roles/containers/EditRepositoryRole.tsx @@ -7,6 +7,7 @@ import { ErrorNotification, Subtitle, Loading } from "@scm-manager/ui-components import { RepositoryRole } from "@scm-manager/ui-types"; import { History } from "history"; import DeleteRepositoryRole from "./DeleteRepositoryRole"; +import { compose } from "redux"; type Props = WithTranslation & { disabled: boolean; @@ -43,14 +44,17 @@ class EditRepositoryRole extends React.Component<Props> { return ( <> <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} /> </> ); } } -const mapStateToProps = (state, ownProps) => { +const mapStateToProps = (state: any, ownProps: Props) => { const loading = isModifyRolePending(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 { updateRole: (role: RepositoryRole, callback?: () => void) => { dispatch(modifyRole(role, callback)); @@ -68,7 +72,4 @@ const mapDispatchToProps = dispatch => { }; }; -export default connect( - mapStateToProps, - mapDispatchToProps -)(withTranslation("admin")(EditRepositoryRole)); +export default compose(connect(mapStateToProps, mapDispatchToProps), withTranslation("admin"))(EditRepositoryRole); diff --git a/scm-ui/ui-webapp/src/admin/roles/containers/RepositoryRoleForm.tsx b/scm-ui/ui-webapp/src/admin/roles/containers/RepositoryRoleForm.tsx index 3dd47b0feb..6405899f0c 100644 --- a/scm-ui/ui-webapp/src/admin/roles/containers/RepositoryRoleForm.tsx +++ b/scm-ui/ui-webapp/src/admin/roles/containers/RepositoryRoleForm.tsx @@ -6,6 +6,7 @@ import { InputField, Level, SubmitButton } from "@scm-manager/ui-components"; import { getRepositoryRolesLink, getRepositoryVerbsLink } from "../../../modules/indexResource"; import { fetchAvailableVerbs, getFetchVerbsFailure, getVerbsFromState, isFetchVerbsPending } from "../modules/roles"; import PermissionsWrapper from "../../../permissions/components/PermissionsWrapper"; +import { compose } from "redux"; type Props = WithTranslation & { 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 error = getFetchVerbsFailure(state); const verbsLink = getRepositoryVerbsLink(state); @@ -136,7 +137,7 @@ const mapStateToProps = state => { }; }; -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch: any) => { return { fetchAvailableVerbs: (link: string) => { dispatch(fetchAvailableVerbs(link)); @@ -144,7 +145,4 @@ const mapDispatchToProps = dispatch => { }; }; -export default connect( - mapStateToProps, - mapDispatchToProps -)(withTranslation("admin")(RepositoryRoleForm)); +export default compose(connect(mapStateToProps, mapDispatchToProps), withTranslation("admin"))(RepositoryRoleForm); diff --git a/scm-ui/ui-webapp/src/admin/roles/containers/RepositoryRoles.tsx b/scm-ui/ui-webapp/src/admin/roles/containers/RepositoryRoles.tsx index 5a3aa2618d..d664651c55 100644 --- a/scm-ui/ui-webapp/src/admin/roles/containers/RepositoryRoles.tsx +++ b/scm-ui/ui-webapp/src/admin/roles/containers/RepositoryRoles.tsx @@ -1,6 +1,6 @@ import React from "react"; 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 { History } from "history"; import { RepositoryRole, PagedCollection } from "@scm-manager/ui-types"; @@ -16,23 +16,24 @@ import { import PermissionRoleTable from "../components/PermissionRoleTable"; import { getRepositoryRolesLink } from "../../../modules/indexResource"; -type Props = WithTranslation & { - baseUrl: string; - roles: RepositoryRole[]; - loading: boolean; - error: Error; - canAddRoles: boolean; - list: PagedCollection; - page: number; - rolesLink: string; +type Props = RouteComponentProps & + WithTranslation & { + baseUrl: string; + roles: RepositoryRole[]; + loading: boolean; + error: Error; + canAddRoles: boolean; + list: PagedCollection; + page: number; + rolesLink: string; - // context objects - history: History; - location: any; + // context objects + history: History; + location: any; - // dispatch functions - fetchRolesByPage: (link: string, page: number) => void; -}; + // dispatch functions + fetchRolesByPage: (link: string, page: number) => void; + }; class RepositoryRoles extends React.Component<Props> { 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 roles = getRolesFromState(state); const loading = isFetchRolesPending(state); @@ -110,7 +111,7 @@ const mapStateToProps = (state, ownProps) => { }; }; -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch: any) => { return { fetchRolesByPage: (link: string, page: number) => { dispatch(fetchRolesByPage(link, page)); @@ -118,9 +119,4 @@ const mapDispatchToProps = dispatch => { }; }; -export default withRouter( - connect( - mapStateToProps, - mapDispatchToProps - )(withTranslation("admin")(RepositoryRoles)) -); +export default withRouter(connect(mapStateToProps, mapDispatchToProps)(withTranslation("admin")(RepositoryRoles))); diff --git a/scm-ui/ui-webapp/src/admin/roles/containers/SingleRepositoryRole.tsx b/scm-ui/ui-webapp/src/admin/roles/containers/SingleRepositoryRole.tsx index 389eae87c2..3e3f20da56 100644 --- a/scm-ui/ui-webapp/src/admin/roles/containers/SingleRepositoryRole.tsx +++ b/scm-ui/ui-webapp/src/admin/roles/containers/SingleRepositoryRole.tsx @@ -10,6 +10,7 @@ import { getRepositoryRolesLink } from "../../../modules/indexResource"; import { fetchRoleByName, getFetchRoleFailure, getRoleByName, isFetchRolePending } from "../modules/roles"; import PermissionRoleDetail from "../components/PermissionRoleDetails"; import EditRepositoryRole from "./EditRepositoryRole"; +import { compose } from "redux"; type Props = WithTranslation & { 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 role = getRoleByName(state, roleName); const loading = isFetchRolePending(state, roleName); @@ -93,7 +94,7 @@ const mapStateToProps = (state, ownProps) => { }; }; -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch: any) => { return { fetchRoleByName: (link: string, name: string) => { dispatch(fetchRoleByName(link, name)); @@ -101,9 +102,8 @@ const mapDispatchToProps = dispatch => { }; }; -export default withRouter( - connect( - mapStateToProps, - mapDispatchToProps - )(withTranslation("admin")(SingleRepositoryRole)) -); +export default compose( + withRouter, + connect(mapStateToProps, mapDispatchToProps), + withTranslation("admin") +)(SingleRepositoryRole); diff --git a/scm-ui/ui-webapp/src/containers/App.tsx b/scm-ui/ui-webapp/src/containers/App.tsx index 76f75c119b..281e47e920 100644 --- a/scm-ui/ui-webapp/src/containers/App.tsx +++ b/scm-ui/ui-webapp/src/containers/App.tsx @@ -1,6 +1,7 @@ import React, { Component } from "react"; import Main from "./Main"; import { connect } from "react-redux"; +import { compose } from "redux"; import { WithTranslation, withTranslation } from "react-i18next"; import { withRouter } from "react-router-dom"; 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 me = getMe(state); const loading = isFetchMePending(state) || isFetchIndexResourcesPending(state); @@ -78,9 +79,4 @@ const mapStateToProps = state => { }; }; -export default withRouter( - connect( - mapStateToProps, - mapDispatchToProps - )(withTranslation("commons")(App)) -); +export default compose(withRouter, connect(mapStateToProps, mapDispatchToProps), withTranslation("commons"))(App); diff --git a/scm-ui/ui-webapp/src/containers/Index.tsx b/scm-ui/ui-webapp/src/containers/Index.tsx index dba46117bf..21d2e2335d 100644 --- a/scm-ui/ui-webapp/src/containers/Index.tsx +++ b/scm-ui/ui-webapp/src/containers/Index.tsx @@ -1,6 +1,7 @@ import React, { Component } from "react"; import App from "./App"; import { connect } from "react-redux"; +import { compose } from "redux"; import { WithTranslation, withTranslation } from "react-i18next"; import { withRouter } from "react-router-dom"; 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 error = getFetchIndexResourcesFailure(state); const indexResources = getLinks(state); @@ -85,9 +86,4 @@ const mapStateToProps = state => { }; }; -export default withRouter( - connect( - mapStateToProps, - mapDispatchToProps - )(withTranslation("commons")(Index)) -); +export default compose(withRouter, connect(mapStateToProps, mapDispatchToProps), withTranslation("commons"))(Index); diff --git a/scm-ui/ui-webapp/src/containers/Login.tsx b/scm-ui/ui-webapp/src/containers/Login.tsx index 6ad2c5b737..12331cc42e 100644 --- a/scm-ui/ui-webapp/src/containers/Login.tsx +++ b/scm-ui/ui-webapp/src/containers/Login.tsx @@ -62,7 +62,7 @@ class Login extends React.Component<Props> { } } -const mapStateToProps = state => { +const mapStateToProps = (state: any) => { const authenticated = isAuthenticated(state); const loading = isLoginPending(state); const error = getLoginFailure(state); @@ -77,16 +77,10 @@ const mapStateToProps = state => { }; }; -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch: any) => { return { login: (loginLink: string, username: string, password: string) => dispatch(login(loginLink, username, password)) }; }; -export default compose( - withRouter, - connect( - mapStateToProps, - mapDispatchToProps - ) -)(Login); +export default compose(withRouter, connect(mapStateToProps, mapDispatchToProps))(Login); diff --git a/scm-ui/ui-webapp/src/containers/Logout.tsx b/scm-ui/ui-webapp/src/containers/Logout.tsx index 7a1ee0d9ad..75078eb58e 100644 --- a/scm-ui/ui-webapp/src/containers/Logout.tsx +++ b/scm-ui/ui-webapp/src/containers/Logout.tsx @@ -35,7 +35,7 @@ class Logout extends React.Component<Props> { } } -const mapStateToProps = state => { +const mapStateToProps = (state: any) => { const authenticated = isAuthenticated(state); const loading = isLogoutPending(state); const redirecting = isRedirecting(state); @@ -50,13 +50,10 @@ const mapStateToProps = state => { }; }; -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch: any) => { return { logout: (link: string) => dispatch(logout(link)) }; }; -export default connect( - mapStateToProps, - mapDispatchToProps -)(withTranslation("commons")(Logout)); +export default connect(mapStateToProps, mapDispatchToProps)(withTranslation("commons")(Logout)); diff --git a/scm-ui/ui-webapp/src/containers/Profile.tsx b/scm-ui/ui-webapp/src/containers/Profile.tsx index 4b1aab3b5f..7f4af5a468 100644 --- a/scm-ui/ui-webapp/src/containers/Profile.tsx +++ b/scm-ui/ui-webapp/src/containers/Profile.tsx @@ -78,14 +78,10 @@ class Profile extends React.Component<Props, State> { } } -const mapStateToProps = state => { +const mapStateToProps = (state: any) => { return { me: getMe(state) }; }; -export default compose( - withTranslation("commons"), - connect(mapStateToProps), - withRouter -)(Profile); +export default compose(withTranslation("commons"), connect(mapStateToProps), withRouter)(Profile); diff --git a/scm-ui/ui-webapp/src/groups/containers/CreateGroup.tsx b/scm-ui/ui-webapp/src/groups/containers/CreateGroup.tsx index 0a1ee6bf6b..6b8ff2bc97 100644 --- a/scm-ui/ui-webapp/src/groups/containers/CreateGroup.tsx +++ b/scm-ui/ui-webapp/src/groups/containers/CreateGroup.tsx @@ -1,8 +1,9 @@ import React from "react"; import { connect } from "react-redux"; +import { compose } from "redux"; import { WithTranslation, withTranslation } from "react-i18next"; 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 { getGroupsLink, getUserAutoCompleteLink } from "../../modules/indexResource"; import { createGroup, isCreateGroupPending, getCreateGroupFailure, createGroupReset } from "../modules/groups"; @@ -45,7 +46,7 @@ class CreateGroup extends React.Component<Props> { .get(url + inputValue) .then(response => response.json()) .then(json => { - return json.map(element => { + return json.map((element: DisplayedUser) => { return { value: element, label: `${element.displayName} (${element.id})` @@ -61,7 +62,7 @@ class CreateGroup extends React.Component<Props> { }; } -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch: any) => { return { createGroup: (link: string, group: Group, callback?: () => void) => dispatch(createGroup(link, group, callback)), resetForm: () => { @@ -70,7 +71,7 @@ const mapDispatchToProps = dispatch => { }; }; -const mapStateToProps = state => { +const mapStateToProps = (state: any) => { const loading = isCreateGroupPending(state); const error = getCreateGroupFailure(state); const createLink = getGroupsLink(state); @@ -83,7 +84,4 @@ const mapStateToProps = state => { }; }; -export default connect( - mapStateToProps, - mapDispatchToProps -)(withTranslation("groups")(CreateGroup)); +export default compose(connect(mapStateToProps, mapDispatchToProps), withTranslation("groups"))(CreateGroup); diff --git a/scm-ui/ui-webapp/src/groups/containers/DeleteGroup.tsx b/scm-ui/ui-webapp/src/groups/containers/DeleteGroup.tsx index d9e8e4e6b5..3b4137b2ac 100644 --- a/scm-ui/ui-webapp/src/groups/containers/DeleteGroup.tsx +++ b/scm-ui/ui-webapp/src/groups/containers/DeleteGroup.tsx @@ -1,5 +1,6 @@ import React from "react"; import { connect } from "react-redux"; +import { compose } from "redux"; import { withRouter } from "react-router-dom"; import { WithTranslation, withTranslation } from "react-i18next"; 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 error = getDeleteGroupFailure(state, ownProps.group.name); return { @@ -81,7 +82,7 @@ const mapStateToProps = (state, ownProps) => { }; }; -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch: any) => { return { deleteGroup: (group: Group, callback?: () => void) => { dispatch(deleteGroup(group, callback)); @@ -89,7 +90,8 @@ const mapDispatchToProps = dispatch => { }; }; -export default connect( - mapStateToProps, - mapDispatchToProps -)(withRouter(withTranslation("groups")(DeleteGroup))); +export default compose( + connect(mapStateToProps, mapDispatchToProps), + withRouter, + withTranslation("groups") +)(DeleteGroup); diff --git a/scm-ui/ui-webapp/src/groups/containers/EditGroup.tsx b/scm-ui/ui-webapp/src/groups/containers/EditGroup.tsx index f34faaac26..98f0492d99 100644 --- a/scm-ui/ui-webapp/src/groups/containers/EditGroup.tsx +++ b/scm-ui/ui-webapp/src/groups/containers/EditGroup.tsx @@ -4,11 +4,12 @@ import GroupForm from "../components/GroupForm"; import { modifyGroup, getModifyGroupFailure, isModifyGroupPending, modifyGroupReset } from "../modules/groups"; import { History } from "history"; 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 { getUserAutoCompleteLink } from "../../modules/indexResource"; import DeleteGroup from "./DeleteGroup"; import { apiClient } from "@scm-manager/ui-components/src"; +import { compose } from "redux"; type Props = { group: Group; @@ -41,7 +42,7 @@ class EditGroup extends React.Component<Props> { .get(url + inputValue) .then(response => response.json()) .then(json => { - return json.map(element => { + return json.map((element: DisplayedUser) => { return { value: element, 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 error = getModifyGroupFailure(state, ownProps.group.name); const autocompleteLink = getUserAutoCompleteLink(state); @@ -80,7 +81,7 @@ const mapStateToProps = (state, ownProps) => { }; }; -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch: any) => { return { modifyGroup: (group: Group, callback?: () => void) => { dispatch(modifyGroup(group, callback)); @@ -91,7 +92,4 @@ const mapDispatchToProps = dispatch => { }; }; -export default connect( - mapStateToProps, - mapDispatchToProps -)(withRouter(EditGroup)); +export default compose(connect(mapStateToProps, mapDispatchToProps), withRouter)(EditGroup); diff --git a/scm-ui/ui-webapp/src/groups/containers/Groups.tsx b/scm-ui/ui-webapp/src/groups/containers/Groups.tsx index 4661eb57a5..d9b8a91e01 100644 --- a/scm-ui/ui-webapp/src/groups/containers/Groups.tsx +++ b/scm-ui/ui-webapp/src/groups/containers/Groups.tsx @@ -1,6 +1,7 @@ import React from "react"; import { connect } from "react-redux"; import { WithTranslation, withTranslation } from "react-i18next"; +import { RouteComponentProps } from "react-router-dom"; import { History } from "history"; import { Group, PagedCollection } from "@scm-manager/ui-types"; import { @@ -23,22 +24,23 @@ import { } from "../modules/groups"; import { GroupTable } from "./../components/table"; -type Props = WithTranslation & { - groups: Group[]; - loading: boolean; - error: Error; - canAddGroups: boolean; - list: PagedCollection; - page: number; - groupLink: string; +type Props = RouteComponentProps & + WithTranslation & { + groups: Group[]; + loading: boolean; + error: Error; + canAddGroups: boolean; + list: PagedCollection; + page: number; + groupLink: string; - // context objects - history: History; - location: any; + // context objects + history: History; + location: any; - // dispatch functions - fetchGroupsByPage: (link: string, page: number, filter?: string) => void; -}; + // dispatch functions + fetchGroupsByPage: (link: string, page: number, filter?: string) => void; + }; class Groups extends React.Component<Props> { 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 groups = getGroupsFromState(state); const loading = isFetchGroupsPending(state); @@ -121,7 +123,7 @@ const mapStateToProps = (state, ownProps) => { }; }; -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch: any) => { return { fetchGroupsByPage: (link: string, page: number, filter?: string) => { dispatch(fetchGroupsByPage(link, page, filter)); @@ -129,7 +131,4 @@ const mapDispatchToProps = dispatch => { }; }; -export default connect( - mapStateToProps, - mapDispatchToProps -)(withTranslation("groups")(Groups)); +export default connect(mapStateToProps, mapDispatchToProps)(withTranslation("groups")(Groups)); diff --git a/scm-ui/ui-webapp/src/groups/containers/SingleGroup.tsx b/scm-ui/ui-webapp/src/groups/containers/SingleGroup.tsx index 0eccff38f9..c547114708 100644 --- a/scm-ui/ui-webapp/src/groups/containers/SingleGroup.tsx +++ b/scm-ui/ui-webapp/src/groups/containers/SingleGroup.tsx @@ -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 group = getGroupByName(state, name); const loading = isFetchGroupPending(state, name); @@ -110,7 +110,7 @@ const mapStateToProps = (state, ownProps) => { }; }; -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch: any) => { return { fetchGroupByName: (link: string, name: string) => { dispatch(fetchGroupByName(link, name)); @@ -118,7 +118,4 @@ const mapDispatchToProps = dispatch => { }; }; -export default connect( - mapStateToProps, - mapDispatchToProps -)(withTranslation("groups")(SingleGroup)); +export default connect(mapStateToProps, mapDispatchToProps)(withTranslation("groups")(SingleGroup)); diff --git a/scm-ui/ui-webapp/src/permissions/components/SetPermissions.tsx b/scm-ui/ui-webapp/src/permissions/components/SetPermissions.tsx index 83c3b2e284..3d1d9b17f0 100644 --- a/scm-ui/ui-webapp/src/permissions/components/SetPermissions.tsx +++ b/scm-ui/ui-webapp/src/permissions/components/SetPermissions.tsx @@ -151,7 +151,7 @@ class SetPermissions extends React.Component<Props, State> { }; } -const mapStateToProps = state => { +const mapStateToProps = (state: any) => { const availablePermissionLink = getLink(state, "permissions"); return { availablePermissionLink diff --git a/scm-ui/ui-webapp/src/repos/branches/containers/BranchRoot.tsx b/scm-ui/ui-webapp/src/repos/branches/containers/BranchRoot.tsx index 34ada822b6..e1497c92bd 100644 --- a/scm-ui/ui-webapp/src/repos/branches/containers/BranchRoot.tsx +++ b/scm-ui/ui-webapp/src/repos/branches/containers/BranchRoot.tsx @@ -1,6 +1,7 @@ import React from "react"; import BranchView from "../components/BranchView"; import { connect } from "react-redux"; +import { compose } from "redux"; import { Redirect, Route, Switch, withRouter } from "react-router-dom"; import { Repository, Branch } from "@scm-manager/ui-types"; import { fetchBranch, getBranch, getFetchBranchFailure, isFetchBranchPending } from "../modules/branches"; @@ -28,7 +29,6 @@ type Props = { class BranchRoot extends React.Component<Props> { componentDidMount() { const { fetchBranch, repository, branchName } = this.props; - fetchBranch(repository, branchName); } @@ -96,9 +96,4 @@ const mapDispatchToProps = (dispatch: any) => { }; }; -export default withRouter( - connect( - mapStateToProps, - mapDispatchToProps - )(BranchRoot) -); +export default compose(withRouter, connect(mapStateToProps, mapDispatchToProps))(BranchRoot); diff --git a/scm-ui/ui-webapp/src/repos/branches/containers/BranchesOverview.tsx b/scm-ui/ui-webapp/src/repos/branches/containers/BranchesOverview.tsx index 1d12a5db60..956a8ecf60 100644 --- a/scm-ui/ui-webapp/src/repos/branches/containers/BranchesOverview.tsx +++ b/scm-ui/ui-webapp/src/repos/branches/containers/BranchesOverview.tsx @@ -75,7 +75,7 @@ class BranchesOverview extends React.Component<Props> { } } -const mapStateToProps = (state, ownProps) => { +const mapStateToProps = (state: any, ownProps: Props) => { const { repository } = ownProps; const loading = isFetchBranchesPending(state, repository); const error = getFetchBranchesFailure(state, repository); @@ -91,7 +91,7 @@ const mapStateToProps = (state, ownProps) => { }; }; -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch: any) => { return { fetchBranches: (repository: Repository) => { dispatch(fetchBranches(repository)); @@ -102,8 +102,5 @@ const mapDispatchToProps = dispatch => { export default compose( withTranslation("repos"), withRouter, - connect( - mapStateToProps, - mapDispatchToProps - ) + connect(mapStateToProps, mapDispatchToProps) )(BranchesOverview); diff --git a/scm-ui/ui-webapp/src/repos/codeSection/components/CodeViewSwitcher.tsx b/scm-ui/ui-webapp/src/repos/codeSection/components/CodeViewSwitcher.tsx index 66b9622693..a6f8a70d7e 100644 --- a/scm-ui/ui-webapp/src/repos/codeSection/components/CodeViewSwitcher.tsx +++ b/scm-ui/ui-webapp/src/repos/codeSection/components/CodeViewSwitcher.tsx @@ -20,7 +20,7 @@ const CodeViewSwitcher: FC<Props> = ({ url }) => { const createDestinationUrl = (destination: string) => { let splittedUrl = url.split("/"); splittedUrl[5] = destination; - return splittedUrl.join("/") + return splittedUrl.join("/"); }; return ( diff --git a/scm-ui/ui-webapp/src/repos/components/form/RepositoryForm.tsx b/scm-ui/ui-webapp/src/repos/components/form/RepositoryForm.tsx index 37fd072880..01cefb6760 100644 --- a/scm-ui/ui-webapp/src/repos/components/form/RepositoryForm.tsx +++ b/scm-ui/ui-webapp/src/repos/components/form/RepositoryForm.tsx @@ -8,8 +8,8 @@ import * as validator from "./repositoryValidation"; type Props = WithTranslation & { submitForm: (p: Repository) => void; repository?: Repository; - repositoryTypes: RepositoryType[]; - namespaceStrategy: string; + repositoryTypes?: RepositoryType[]; + namespaceStrategy?: string; loading?: boolean; }; @@ -127,13 +127,16 @@ class RepositoryForm extends React.Component<Props, State> { ); } - createSelectOptions(repositoryTypes: RepositoryType[]) { - return repositoryTypes.map(repositoryType => { - return { - label: repositoryType.displayName, - value: repositoryType.name - }; - }); + createSelectOptions(repositoryTypes?: RepositoryType[]) { + if (repositoryTypes) { + return repositoryTypes.map(repositoryType => { + return { + label: repositoryType.displayName, + value: repositoryType.name + }; + }); + } + return []; } renderNamespaceField = () => { diff --git a/scm-ui/ui-webapp/src/repos/containers/ChangesetView.tsx b/scm-ui/ui-webapp/src/repos/containers/ChangesetView.tsx index b165ceb0ad..41df464c2f 100644 --- a/scm-ui/ui-webapp/src/repos/containers/ChangesetView.tsx +++ b/scm-ui/ui-webapp/src/repos/containers/ChangesetView.tsx @@ -1,5 +1,6 @@ import React from "react"; import { connect } from "react-redux"; +import { compose } from "redux"; import { withRouter } from "react-router-dom"; import { WithTranslation, withTranslation } from "react-i18next"; 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 id = ownProps.match.params.id; const changeset = getChangeset(state, repository, id); @@ -55,7 +56,7 @@ const mapStateToProps = (state, ownProps: Props) => { }; }; -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch: any) => { return { fetchChangesetIfNeeded: (repository: Repository, id: string) => { dispatch(fetchChangesetIfNeeded(repository, id)); @@ -63,9 +64,8 @@ const mapDispatchToProps = dispatch => { }; }; -export default withRouter( - connect( - mapStateToProps, - mapDispatchToProps - )(withTranslation("repos")(ChangesetView)) -); +export default compose( + withRouter, + connect(mapStateToProps, mapDispatchToProps), + withTranslation("repos") +)(ChangesetView); diff --git a/scm-ui/ui-webapp/src/repos/containers/Create.tsx b/scm-ui/ui-webapp/src/repos/containers/Create.tsx index ec2eca0529..c68435aece 100644 --- a/scm-ui/ui-webapp/src/repos/containers/Create.tsx +++ b/scm-ui/ui-webapp/src/repos/containers/Create.tsx @@ -76,7 +76,7 @@ class Create extends React.Component<Props> { } } -const mapStateToProps = state => { +const mapStateToProps = (state: any) => { const repositoryTypes = getRepositoryTypes(state); const namespaceStrategies = getNamespaceStrategies(state); const pageLoading = isFetchRepositoryTypesPending(state) || isFetchNamespaceStrategiesPending(state); @@ -94,7 +94,7 @@ const mapStateToProps = state => { }; }; -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch: any) => { return { fetchRepositoryTypesIfNeeded: () => { dispatch(fetchRepositoryTypesIfNeeded()); @@ -111,7 +111,4 @@ const mapDispatchToProps = dispatch => { }; }; -export default connect( - mapStateToProps, - mapDispatchToProps -)(withTranslation("repos")(Create)); +export default connect(mapStateToProps, mapDispatchToProps)(withTranslation("repos")(Create)); diff --git a/scm-ui/ui-webapp/src/repos/containers/DeleteRepo.tsx b/scm-ui/ui-webapp/src/repos/containers/DeleteRepo.tsx index a8b8c97f84..58f9303845 100644 --- a/scm-ui/ui-webapp/src/repos/containers/DeleteRepo.tsx +++ b/scm-ui/ui-webapp/src/repos/containers/DeleteRepo.tsx @@ -1,5 +1,6 @@ import React from "react"; import { connect } from "react-redux"; +import { compose } from "redux"; import { withRouter } from "react-router-dom"; import { WithTranslation, withTranslation } from "react-i18next"; 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 loading = isDeleteRepoPending(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 { deleteRepo: (repo: Repository, callback: () => void) => { dispatch(deleteRepo(repo, callback)); @@ -90,7 +91,4 @@ const mapDispatchToProps = dispatch => { }; }; -export default connect( - mapStateToProps, - mapDispatchToProps -)(withRouter(withTranslation("repos")(DeleteRepo))); +export default compose(connect(mapStateToProps, mapDispatchToProps), withRouter, withTranslation("repos"))(DeleteRepo); diff --git a/scm-ui/ui-webapp/src/repos/containers/EditRepo.tsx b/scm-ui/ui-webapp/src/repos/containers/EditRepo.tsx index 3bc9818536..d626a98423 100644 --- a/scm-ui/ui-webapp/src/repos/containers/EditRepo.tsx +++ b/scm-ui/ui-webapp/src/repos/containers/EditRepo.tsx @@ -8,6 +8,7 @@ import { modifyRepo, isModifyRepoPending, getModifyRepoFailure, modifyRepoReset import { History } from "history"; import { ErrorNotification } from "@scm-manager/ui-components"; import { ExtensionPoint } from "@scm-manager/ui-extensions"; +import { compose } from "redux"; type Props = { 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 loading = isModifyRepoPending(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 { modifyRepo: (repo: Repository, callback: () => void) => { dispatch(modifyRepo(repo, callback)); @@ -92,7 +93,4 @@ const mapDispatchToProps = dispatch => { }; }; -export default connect( - mapStateToProps, - mapDispatchToProps -)(withRouter(EditRepo)); +export default compose(connect(mapStateToProps, mapDispatchToProps), withRouter)(EditRepo); diff --git a/scm-ui/ui-webapp/src/repos/containers/Overview.tsx b/scm-ui/ui-webapp/src/repos/containers/Overview.tsx index 0b5b8d01da..2b386127df 100644 --- a/scm-ui/ui-webapp/src/repos/containers/Overview.tsx +++ b/scm-ui/ui-webapp/src/repos/containers/Overview.tsx @@ -1,6 +1,6 @@ import React from "react"; 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 { History } from "history"; import { RepositoryCollection } from "@scm-manager/ui-types"; @@ -23,7 +23,7 @@ import { } from "../modules/repos"; import RepositoryList from "../components/list"; -type Props = WithTranslation & { +type Props = WithTranslation & RouteComponentProps & { loading: boolean; error: Error; 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 collection = getRepositoryCollection(state); const loading = isFetchReposPending(state); @@ -121,14 +121,11 @@ const mapStateToProps = (state, ownProps) => { }; }; -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch: any) => { return { fetchReposByPage: (link: string, page: number, filter?: string) => { dispatch(fetchReposByPage(link, page, filter)); } }; }; -export default connect( - mapStateToProps, - mapDispatchToProps -)(withTranslation("repos")(withRouter(Overview))); +export default connect(mapStateToProps, mapDispatchToProps)(withTranslation("repos")(withRouter(Overview))); diff --git a/scm-ui/ui-webapp/src/repos/permissions/containers/Permissions.tsx b/scm-ui/ui-webapp/src/repos/permissions/containers/Permissions.tsx index 0c937075d9..f775bb7878 100644 --- a/scm-ui/ui-webapp/src/repos/permissions/containers/Permissions.tsx +++ b/scm-ui/ui-webapp/src/repos/permissions/containers/Permissions.tsx @@ -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 repoName = ownProps.repoName; const error = @@ -216,7 +216,7 @@ const mapStateToProps = (state, ownProps) => { }; }; -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch: any) => { return { fetchPermissions: (link: string, namespace: string, repoName: string) => { dispatch(fetchPermissions(link, namespace, repoName)); @@ -245,7 +245,4 @@ const mapDispatchToProps = dispatch => { }; }; -export default connect( - mapStateToProps, - mapDispatchToProps -)(withTranslation("repos")(Permissions)); +export default connect(mapStateToProps, mapDispatchToProps)(withTranslation("repos")(Permissions)); diff --git a/scm-ui/ui-webapp/src/repos/permissions/containers/SinglePermission.tsx b/scm-ui/ui-webapp/src/repos/permissions/containers/SinglePermission.tsx index 4ac49674de..5b68278f4c 100644 --- a/scm-ui/ui-webapp/src/repos/permissions/containers/SinglePermission.tsx +++ b/scm-ui/ui-webapp/src/repos/permissions/containers/SinglePermission.tsx @@ -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 loading = isModifyPermissionPending(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 { modifyPermission: (permission: Permission, namespace: string, repoName: string) => { dispatch(modifyPermission(permission, namespace, repoName)); @@ -229,7 +229,4 @@ const mapDispatchToProps = dispatch => { } }; }; -export default connect( - mapStateToProps, - mapDispatchToProps -)(withTranslation("repos")(SinglePermission)); +export default connect(mapStateToProps, mapDispatchToProps)(withTranslation("repos")(SinglePermission)); diff --git a/scm-ui/ui-webapp/src/repos/sources/components/FileTree.tsx b/scm-ui/ui-webapp/src/repos/sources/components/FileTree.tsx index c1384b5192..6b2c7b1ee3 100644 --- a/scm-ui/ui-webapp/src/repos/sources/components/FileTree.tsx +++ b/scm-ui/ui-webapp/src/repos/sources/components/FileTree.tsx @@ -174,10 +174,4 @@ const mapStateToProps = (state: any, ownProps: Props) => { }; }; -export default compose( - withRouter, - connect( - mapStateToProps, - mapDispatchToProps - ) -)(withTranslation("repos")(FileTree)); +export default compose(withRouter, connect(mapStateToProps, mapDispatchToProps))(withTranslation("repos")(FileTree)); diff --git a/scm-ui/ui-webapp/src/repos/sources/components/FileTreeLeaf.tsx b/scm-ui/ui-webapp/src/repos/sources/components/FileTreeLeaf.tsx index cd6baea395..1019e97c98 100644 --- a/scm-ui/ui-webapp/src/repos/sources/components/FileTreeLeaf.tsx +++ b/scm-ui/ui-webapp/src/repos/sources/components/FileTreeLeaf.tsx @@ -88,14 +88,16 @@ class FileTreeLeaf extends React.Component<Props> { render() { 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} />; return ( <tr> <td>{this.createFileIcon(file)}</td> <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> <MinWidthTd className={classNames("is-word-break", "is-hidden-touch")}> {this.contentIfPresent(file, "description", file => file.description)} diff --git a/scm-ui/ui-webapp/src/repos/sources/containers/SourceExtensions.tsx b/scm-ui/ui-webapp/src/repos/sources/containers/SourceExtensions.tsx index 613bf51828..e507c4dded 100644 --- a/scm-ui/ui-webapp/src/repos/sources/containers/SourceExtensions.tsx +++ b/scm-ui/ui-webapp/src/repos/sources/containers/SourceExtensions.tsx @@ -85,9 +85,4 @@ const mapDispatchToProps = (dispatch: any) => { }; }; -export default withRouter( - connect( - mapStateToProps, - mapDispatchToProps - )(withTranslation("repos")(SourceExtensions)) -); +export default withRouter(connect(mapStateToProps, mapDispatchToProps)(withTranslation("repos")(SourceExtensions))); diff --git a/scm-ui/ui-webapp/src/users/containers/CreateUser.tsx b/scm-ui/ui-webapp/src/users/containers/CreateUser.tsx index 66a48498ed..15f7b3d389 100644 --- a/scm-ui/ui-webapp/src/users/containers/CreateUser.tsx +++ b/scm-ui/ui-webapp/src/users/containers/CreateUser.tsx @@ -1,5 +1,6 @@ import React from "react"; import { connect } from "react-redux"; +import { compose } from "redux"; import { WithTranslation, withTranslation } from "react-i18next"; import { History } from "history"; 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 { addUser: (link: string, user: User, callback?: () => void) => { 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 error = getCreateUserFailure(state); const usersLink = getUsersLink(state); @@ -68,7 +69,4 @@ const mapStateToProps = (state, ownProps) => { }; }; -export default connect( - mapStateToProps, - mapDispatchToProps -)(withTranslation("users")(CreateUser)); +export default compose(connect(mapStateToProps, mapDispatchToProps), withTranslation("users"))(CreateUser); diff --git a/scm-ui/ui-webapp/src/users/containers/DeleteUser.tsx b/scm-ui/ui-webapp/src/users/containers/DeleteUser.tsx index 6feafaaf91..3bc4c2c574 100644 --- a/scm-ui/ui-webapp/src/users/containers/DeleteUser.tsx +++ b/scm-ui/ui-webapp/src/users/containers/DeleteUser.tsx @@ -1,5 +1,6 @@ import React from "react"; import { connect } from "react-redux"; +import { compose } from "redux"; import { withRouter } from "react-router-dom"; import { WithTranslation, withTranslation } from "react-i18next"; 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 error = getDeleteUserFailure(state, ownProps.user.name); return { @@ -81,7 +82,7 @@ const mapStateToProps = (state, ownProps) => { }; }; -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch: any) => { return { deleteUser: (user: User, callback?: () => void) => { dispatch(deleteUser(user, callback)); @@ -89,7 +90,4 @@ const mapDispatchToProps = dispatch => { }; }; -export default connect( - mapStateToProps, - mapDispatchToProps -)(withRouter(withTranslation("users")(DeleteUser))); +export default compose(connect(mapStateToProps, mapDispatchToProps), withRouter, withTranslation("users"))(DeleteUser); diff --git a/scm-ui/ui-webapp/src/users/containers/EditUser.tsx b/scm-ui/ui-webapp/src/users/containers/EditUser.tsx index 81f639535c..e757157dcc 100644 --- a/scm-ui/ui-webapp/src/users/containers/EditUser.tsx +++ b/scm-ui/ui-webapp/src/users/containers/EditUser.tsx @@ -7,6 +7,7 @@ import { User } from "@scm-manager/ui-types"; import { modifyUser, isModifyUserPending, getModifyUserFailure, modifyUserReset } from "../modules/users"; import { History } from "history"; import { ErrorNotification } from "@scm-manager/ui-components"; +import { compose } from "redux"; type Props = { 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 error = getModifyUserFailure(state, ownProps.user.name); return { @@ -56,7 +57,7 @@ const mapStateToProps = (state, ownProps) => { }; }; -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch: any) => { return { modifyUser: (user: User, callback?: () => void) => { dispatch(modifyUser(user, callback)); @@ -67,7 +68,4 @@ const mapDispatchToProps = dispatch => { }; }; -export default connect( - mapStateToProps, - mapDispatchToProps -)(withRouter(EditUser)); +export default compose(connect(mapStateToProps, mapDispatchToProps), withRouter)(EditUser); diff --git a/scm-ui/ui-webapp/src/users/containers/SingleUser.tsx b/scm-ui/ui-webapp/src/users/containers/SingleUser.tsx index fac65b369c..fc92fc4966 100644 --- a/scm-ui/ui-webapp/src/users/containers/SingleUser.tsx +++ b/scm-ui/ui-webapp/src/users/containers/SingleUser.tsx @@ -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 user = getUserByName(state, name); const loading = isFetchUserPending(state, name); @@ -110,7 +110,7 @@ const mapStateToProps = (state, ownProps) => { }; }; -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch: any) => { return { fetchUserByName: (link: string, name: string) => { dispatch(fetchUserByName(link, name)); @@ -118,7 +118,4 @@ const mapDispatchToProps = dispatch => { }; }; -export default connect( - mapStateToProps, - mapDispatchToProps -)(withTranslation("users")(SingleUser)); +export default connect(mapStateToProps, mapDispatchToProps)(withTranslation("users")(SingleUser)); diff --git a/scm-ui/ui-webapp/src/users/containers/Users.tsx b/scm-ui/ui-webapp/src/users/containers/Users.tsx index d634ed5ca7..d1ebfe4026 100644 --- a/scm-ui/ui-webapp/src/users/containers/Users.tsx +++ b/scm-ui/ui-webapp/src/users/containers/Users.tsx @@ -1,6 +1,7 @@ import React from "react"; import { connect } from "react-redux"; import { WithTranslation, withTranslation } from "react-i18next"; +import { RouteComponentProps } from "react-router-dom"; import { History } from "history"; import { User, PagedCollection } from "@scm-manager/ui-types"; import { @@ -23,22 +24,23 @@ import { } from "../modules/users"; import { UserTable } from "./../components/table"; -type Props = WithTranslation & { - users: User[]; - loading: boolean; - error: Error; - canAddUsers: boolean; - list: PagedCollection; - page: number; - usersLink: string; +type Props = RouteComponentProps & + WithTranslation & { + users: User[]; + loading: boolean; + error: Error; + canAddUsers: boolean; + list: PagedCollection; + page: number; + usersLink: string; - // context objects - history: History; - location: any; + // context objects + history: History; + location: any; - // dispatch functions - fetchUsersByPage: (link: string, page: number, filter?: string) => void; -}; + // dispatch functions + fetchUsersByPage: (link: string, page: number, filter?: string) => void; + }; class Users extends React.Component<Props> { 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 users = getUsersFromState(state); const loading = isFetchUsersPending(state); @@ -121,7 +123,7 @@ const mapStateToProps = (state, ownProps) => { }; }; -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch: any) => { return { fetchUsersByPage: (link: string, page: number, filter?: string) => { dispatch(fetchUsersByPage(link, page, filter)); @@ -129,7 +131,4 @@ const mapDispatchToProps = dispatch => { }; }; -export default connect( - mapStateToProps, - mapDispatchToProps -)(withTranslation("users")(Users)); +export default connect(mapStateToProps, mapDispatchToProps)(withTranslation("users")(Users));