Migrate react-i18next translate components

This commit is contained in:
Florian Scholdei
2019-10-23 15:47:08 +02:00
parent e4668ae304
commit db075974db
121 changed files with 498 additions and 740 deletions

View File

@@ -2,15 +2,12 @@ import React from "react";
import PluginActionModal from "./PluginActionModal";
import { PendingPlugins } from "@scm-manager/ui-types";
import { apiClient } from "@scm-manager/ui-components";
import { translate } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
type Props = {
type Props = WithTranslation & {
onClose: () => void;
refresh: () => void;
pendingPlugins: PendingPlugins;
// context props
t: (p: string) => string;
};
class CancelPendingActionModal extends React.Component<Props> {
@@ -37,4 +34,4 @@ class CancelPendingActionModal extends React.Component<Props> {
};
}
export default translate("admin")(CancelPendingActionModal);
export default withTranslation("admin")(CancelPendingActionModal);

View File

@@ -1,14 +1,11 @@
import React from "react";
import { Button } from "@scm-manager/ui-components";
import { WithTranslation, withTranslation } from "react-i18next";
import { PendingPlugins } from "@scm-manager/ui-types";
import { translate } from "react-i18next";
import { Button } from "@scm-manager/ui-components";
import ExecutePendingModal from "./ExecutePendingModal";
type Props = {
type Props = WithTranslation & {
pendingPlugins: PendingPlugins;
// context props
t: (p: string) => string;
};
type State = {
@@ -55,4 +52,4 @@ class ExecutePendingAction extends React.Component<Props, State> {
}
}
export default translate("admin")(ExecutePendingAction);
export default withTranslation("admin")(ExecutePendingAction);

View File

@@ -1,16 +1,13 @@
import React from "react";
import PluginActionModal from "./PluginActionModal";
import { WithTranslation, withTranslation } from "react-i18next";
import { PendingPlugins } from "@scm-manager/ui-types";
import waitForRestart from "./waitForRestart";
import { apiClient, Notification } from "@scm-manager/ui-components";
import { translate } from "react-i18next";
import waitForRestart from "./waitForRestart";
import PluginActionModal from "./PluginActionModal";
type Props = {
type Props = WithTranslation & {
onClose: () => void;
pendingPlugins: PendingPlugins;
// context props
t: (p: string) => string;
};
class ExecutePendingActionModal extends React.Component<Props> {
@@ -36,4 +33,4 @@ class ExecutePendingActionModal extends React.Component<Props> {
};
}
export default translate("admin")(ExecutePendingActionModal);
export default withTranslation("admin")(ExecutePendingActionModal);

View File

@@ -1,16 +1,13 @@
import React from "react";
import { apiClient, Button, ButtonGroup, ErrorNotification, Modal, Notification } from "@scm-manager/ui-components";
import { PendingPlugins } from "@scm-manager/ui-types";
import { translate } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import waitForRestart from "./waitForRestart";
import SuccessNotification from "./SuccessNotification";
type Props = {
type Props = WithTranslation & {
onClose: () => void;
pendingPlugins: PendingPlugins;
// context props
t: (p: string) => string;
};
type State = {
@@ -167,4 +164,4 @@ class ExecutePendingModal extends React.Component<Props, State> {
}
}
export default translate("admin")(ExecutePendingModal);
export default withTranslation("admin")(ExecutePendingModal);

View File

@@ -1,10 +1,10 @@
import * as React from "react";
import { Button, ButtonGroup, ErrorNotification, Modal } from "@scm-manager/ui-components";
import { WithTranslation, withTranslation } from "react-i18next";
import { PendingPlugins, PluginCollection } from "@scm-manager/ui-types";
import { translate } from "react-i18next";
import { Button, ButtonGroup, ErrorNotification, Modal } from "@scm-manager/ui-components";
import SuccessNotification from "./SuccessNotification";
type Props = {
type Props = WithTranslation & {
onClose: () => void;
actionType: string;
pendingPlugins?: PendingPlugins;
@@ -15,9 +15,6 @@ type Props = {
label: string;
children?: React.Node;
// context props
t: (p: string) => string;
};
type State = {
@@ -199,4 +196,4 @@ class PluginActionModal extends React.Component<Props, State> {
}
}
export default translate("admin")(PluginActionModal);
export default withTranslation("admin")(PluginActionModal);

View File

@@ -1,6 +1,5 @@
import React from "react";
import { translate } from "react-i18next";
import classNames from "classnames";
import { WithTranslation, withTranslation } from "react-i18next";
import styled from "styled-components";
import { Plugin } from "@scm-manager/ui-types";
import { CardColumn, Icon } from "@scm-manager/ui-components";
@@ -13,12 +12,9 @@ export const PluginAction = {
UNINSTALL: "uninstall"
};
type Props = {
type Props = WithTranslation & {
plugin: Plugin;
refresh: () => void;
// context props
t: (p: string) => string;
};
type State = {
@@ -173,4 +169,4 @@ class PluginEntry extends React.Component<Props, State> {
}
}
export default translate("admin")(PluginEntry);
export default withTranslation("admin")(PluginEntry);

View File

@@ -1,5 +1,5 @@
import React from "react";
import { translate } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import classNames from "classnames";
import styled from "styled-components";
import { Plugin } from "@scm-manager/ui-types";
@@ -16,14 +16,11 @@ import waitForRestart from "./waitForRestart";
import SuccessNotification from "./SuccessNotification";
import { PluginAction } from "./PluginEntry";
type Props = {
type Props = WithTranslation & {
plugin: Plugin;
pluginAction: string;
refresh: () => void;
onClose: () => void;
// context props
t: (key: string, params?: object) => string;
};
type State = {
@@ -268,4 +265,4 @@ class PluginModal extends React.Component<Props, State> {
}
}
export default translate("admin")(PluginModal);
export default withTranslation("admin")(PluginModal);

View File

@@ -1,13 +1,8 @@
import React from "react";
import { translate } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import { Notification } from "@scm-manager/ui-components";
type Props = {
// context props
t: (p: string) => string;
};
class InstallSuccessNotification extends React.Component<Props> {
class InstallSuccessNotification extends React.Component<WithTranslation> {
render() {
const { t } = this.props;
return (
@@ -19,4 +14,4 @@ class InstallSuccessNotification extends React.Component<Props> {
}
}
export default translate("admin")(InstallSuccessNotification);
export default withTranslation("admin")(InstallSuccessNotification);

View File

@@ -1,16 +1,13 @@
import React from "react";
import PluginActionModal from "./PluginActionModal";
import { WithTranslation, withTranslation } from "react-i18next";
import { PluginCollection } from "@scm-manager/ui-types";
import { apiClient } from "@scm-manager/ui-components";
import { translate } from "react-i18next";
import PluginActionModal from "./PluginActionModal";
type Props = {
type Props = WithTranslation & {
onClose: () => void;
refresh: () => void;
installedPlugins: PluginCollection;
// context props
t: (p: string) => string;
};
class UpdateAllActionModal extends React.Component<Props> {
@@ -37,4 +34,4 @@ class UpdateAllActionModal extends React.Component<Props> {
};
}
export default translate("admin")(UpdateAllActionModal);
export default withTranslation("admin")(UpdateAllActionModal);

View File

@@ -1,6 +1,6 @@
import * as React from "react";
import { connect } from "react-redux";
import { translate } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import { compose } from "redux";
import { PendingPlugins, PluginCollection } from "@scm-manager/ui-types";
import {
@@ -32,7 +32,7 @@ import ExecutePendingActionModal from "../components/ExecutePendingActionModal";
import CancelPendingActionModal from "../components/CancelPendingActionModal";
import UpdateAllActionModal from "../components/UpdateAllActionModal";
type Props = {
type Props = WithTranslation & {
loading: boolean;
error: Error;
collection: PluginCollection;
@@ -43,9 +43,6 @@ type Props = {
pendingPluginsLink: string;
pendingPlugins: PendingPlugins;
// context objects
t: (key: string, params?: object) => string;
// dispatched functions
fetchPluginsByLink: (link: string) => void;
fetchPendingPlugins: (link: string) => void;
@@ -291,7 +288,7 @@ const mapDispatchToProps = dispatch => {
};
export default compose(
translate("admin"),
withTranslation("admin"),
connect(
mapStateToProps,
mapDispatchToProps