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

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

View File

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

View File

@@ -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<Props, State> {
};
}
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);

View File

@@ -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<Props, State> {
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<Props, State> {
}
};
renderHeader = (actions: React.Node) => {
renderHeader = (actions: React.ReactNode) => {
const { installed, t } = this.props;
return (
<div className="columns">
@@ -103,7 +104,7 @@ class PluginsOverview extends React.Component<Props, State> {
);
};
renderFooter = (actions: React.Node) => {
renderFooter = (actions: React.ReactNode) => {
if (actions) {
return <PluginBottomActions>{actions}</PluginBottomActions>;
}
@@ -173,7 +174,7 @@ class PluginsOverview extends React.Component<Props, State> {
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<Props, State> {
}
}
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);

View File

@@ -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<Props> {
<>
<Title title={t("repositoryRole.title")} />
<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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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)));

View File

@@ -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);