Merge pull request #246 from pi-hole/dependabot/npm_and_yarn/development/react-i18next-10.11.0

Bump react-i18next from 9.0.7 to 10.11.0
This commit is contained in:
Mark Drobnak
2019-06-01 00:36:48 -04:00
committed by GitHub
42 changed files with 159 additions and 153 deletions
+3 -12
View File
@@ -18764,12 +18764,11 @@
"dev": true
},
"react-i18next": {
"version": "9.0.7",
"resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-9.0.7.tgz",
"integrity": "sha512-+MaYI/MrjHPgcyKapuCflWurLB1GeOkzoU9qU1OAz9Lt3xxZo7q7IULhQQjH433kabikUu1qbiKx2n5MaCCH/A==",
"version": "10.11.0",
"resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-10.11.0.tgz",
"integrity": "sha512-jmxLZK8mf+KxG3RUIiu/COperTq1c7+iHNsna7LODOYEYaoj6EXFuchOytnB80GoUOb0JC1csT37Zp+U5nPQqQ==",
"requires": {
"@babel/runtime": "^7.3.1",
"hoist-non-react-statics": "3.2.1",
"html-parse-stringify2": "2.0.1"
},
"dependencies": {
@@ -18781,14 +18780,6 @@
"regenerator-runtime": "^0.13.2"
}
},
"hoist-non-react-statics": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.2.1.tgz",
"integrity": "sha512-TFsu3TV3YLY+zFTZDrN8L2DTFanObwmBLpWvJs1qfUuEQ5bTAdFcwfx2T/bsCXfM9QHSLvjfP+nihEl0yvozxw==",
"requires": {
"react-is": "^16.3.2"
}
},
"regenerator-runtime": {
"version": "0.13.2",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz",
+1 -1
View File
@@ -56,7 +56,7 @@
"react-bootstrap-typeahead": "^3.4.4",
"react-chartjs-2": "^2.7.6",
"react-dom": "^16.8.6",
"react-i18next": "^9.0.7",
"react-i18next": "^10.11.0",
"react-router-dom": "^5.0.0",
"react-table": "^6.10.0",
"reactstrap": "^8.0.0",
+3 -3
View File
@@ -11,7 +11,7 @@
/* eslint-disable jsx-a11y/anchor-is-valid */
import React, { Component, FormEvent } from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import NavButton from "./NavButton";
import NavDropdown from "./NavDropdown";
import { StatusContext } from "./context/StatusContext";
@@ -32,7 +32,7 @@ import {
ModalHeader
} from "reactstrap";
export interface EnableDisableProps extends WithNamespaces {
export interface EnableDisableProps extends WithTranslation {
status: Status;
refresh: (data?: ApiStatus) => void;
onSetStatus: (
@@ -249,7 +249,7 @@ export class EnableDisable extends Component<
}
}
export const TranslatedEnableDisable = withNamespaces("common")(EnableDisable);
export const TranslatedEnableDisable = withTranslation("common")(EnableDisable);
export const EnableDisableContainer = () => (
<StatusContext.Consumer>
+9 -3
View File
@@ -8,8 +8,8 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */
import React from "react";
import { withNamespaces } from "react-i18next";
import React, { Suspense } from "react";
import { withTranslation } from "react-i18next";
import FooterUpdateStatus from "./FooterUpdateStatus";
const Footer = (props: any) => {
@@ -32,4 +32,10 @@ const Footer = (props: any) => {
);
};
export default withNamespaces(["common", "footer"])(Footer);
const TranslatedFooter = withTranslation(["common", "footer"])(Footer);
export default () => (
<Suspense fallback={null}>
<TranslatedFooter />
</Suspense>
);
+3 -3
View File
@@ -9,10 +9,10 @@
* Please see LICENSE file for your rights under this license. */
import React from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import { Link } from "react-router-dom";
const FooterUpdateStatus = (props: WithNamespaces) => {
const FooterUpdateStatus = (props: WithTranslation) => {
const { t } = props;
const updateAvailable = false;
@@ -27,4 +27,4 @@ const FooterUpdateStatus = (props: WithNamespaces) => {
}
};
export default withNamespaces("footer")(FooterUpdateStatus);
export default withTranslation("footer")(FooterUpdateStatus);
+10 -4
View File
@@ -8,8 +8,8 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */
import React, { Fragment, ReactElement } from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import React, { Fragment, ReactElement, Suspense } from "react";
import { WithTranslation, withTranslation } from "react-i18next";
import { NavLink } from "react-router-dom";
import { Nav, NavItem } from "reactstrap";
import logo from "../../img/logo.svg";
@@ -124,7 +124,7 @@ export const NavList = ({
</Fragment>
);
export interface SidebarProps extends WithNamespaces {
export interface SidebarProps extends WithTranslation {
items: Array<RouteData>;
location: Location;
}
@@ -172,4 +172,10 @@ const Sidebar = ({ items, t, location }: SidebarProps): ReactElement => (
</div>
);
export default withNamespaces(["common", "location"])(Sidebar);
const TranslatedSidebar = withTranslation(["common", "location"])(Sidebar);
export default (props: any) => (
<Suspense fallback={null}>
<TranslatedSidebar {...props} />
</Suspense>
);
+3 -3
View File
@@ -9,10 +9,10 @@
* Please see LICENSE file for your rights under this license. */
import React, { Component } from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import { StatusContext } from "./context/StatusContext";
export interface StatusBadgeProps extends WithNamespaces {
export interface StatusBadgeProps extends WithTranslation {
status: string;
}
@@ -36,7 +36,7 @@ class StatusBadge extends Component<StatusBadgeProps, {}> {
}
}
export const TranslatedStatusBadge = withNamespaces("common")(StatusBadge);
export const TranslatedStatusBadge = withTranslation("common")(StatusBadge);
export default () => (
<StatusContext.Consumer>
@@ -184,7 +184,9 @@ it("renders the NavList in the sidebar", () => {
};
const location = {} as Location;
const wrapper = shallow(<Sidebar items={[item]} location={location} />);
const wrapper = shallow(<Sidebar items={[item]} location={location} />)
.dive()
.dive();
const props = wrapper.find(NavList).props();
expect(props.items).toEqual([item]);
+4 -4
View File
@@ -11,7 +11,7 @@
import React, { Component, RefObject } from "react";
import ReactDOM from "react-dom";
import { Line } from "react-chartjs-2";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import { getIntervalForRange, padNumber } from "../../util/graphUtils";
import api from "../../util/api";
import ChartTooltip from "./ChartTooltip";
@@ -30,10 +30,10 @@ export interface ClientsGraphProps {
datasets: Array<ChartDataSets>;
}
class ClientsGraph extends Component<ClientsGraphProps & WithNamespaces, {}> {
class ClientsGraph extends Component<ClientsGraphProps & WithTranslation, {}> {
private readonly graphRef: RefObject<Line>;
constructor(props: ClientsGraphProps & WithNamespaces) {
constructor(props: ClientsGraphProps & WithTranslation) {
super(props);
this.graphRef = React.createRef();
}
@@ -232,7 +232,7 @@ export const loadingProps: ClientsGraphProps = {
datasets: []
};
export const TranslatedClientsGraph = withNamespaces([
export const TranslatedClientsGraph = withTranslation([
"dashboard",
"time-ranges"
])(ClientsGraph);
+3 -3
View File
@@ -9,7 +9,7 @@
* Please see LICENSE file for your rights under this license. */
import React, { Component } from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import { getIntervalForRange, padNumber } from "../../util/graphUtils";
import api from "../../util/api";
import { WithAPIData } from "../common/WithAPIData";
@@ -29,7 +29,7 @@ export interface QueriesGraphProps {
blocked_over_time: Array<number>;
}
class QueriesGraph extends Component<QueriesGraphProps & WithNamespaces, {}> {
class QueriesGraph extends Component<QueriesGraphProps & WithTranslation, {}> {
render() {
const { t } = this.props;
@@ -210,7 +210,7 @@ export const loadingProps: QueriesGraphProps = {
blocked_over_time: []
};
export const TranslatedQueriesGraph = withNamespaces([
export const TranslatedQueriesGraph = withTranslation([
"dashboard",
"time-ranges"
])(QueriesGraph);
+4 -4
View File
@@ -9,7 +9,7 @@
* Please see LICENSE file for your rights under this license. */
import React from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import api from "../../util/api";
import GenericDoughnutChart from "./GenericDoughnutChart";
import { TimeRangeContext } from "../common/context/TimeRangeContext";
@@ -17,7 +17,7 @@ import { TimeRangeContext } from "../common/context/TimeRangeContext";
const QueryTypesChart = ({
t,
apiCall
}: WithNamespaces & { apiCall: () => Promise<Array<ApiQueryType>> }) => (
}: WithTranslation & { apiCall: () => Promise<Array<ApiQueryType>> }) => (
<GenericDoughnutChart
title={t("Query Types")}
apiCall={apiCall}
@@ -35,7 +35,7 @@ const QueryTypesChart = ({
/>
);
export const QueryTypesChartContainer = (props: WithNamespaces) => (
export const QueryTypesChartContainer = (props: WithTranslation) => (
<TimeRangeContext.Consumer>
{context => (
<QueryTypesChart
@@ -50,4 +50,4 @@ export const QueryTypesChartContainer = (props: WithNamespaces) => (
</TimeRangeContext.Consumer>
);
export default withNamespaces("dashboard")(QueryTypesChartContainer);
export default withTranslation("dashboard")(QueryTypesChartContainer);
+3 -3
View File
@@ -9,7 +9,7 @@
* Please see LICENSE file for your rights under this license. */
import React, { Component, Fragment } from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import { WithAPIData } from "../common/WithAPIData";
import api from "../../util/api";
import { TimeRangeContext } from "../common/context/TimeRangeContext";
@@ -22,7 +22,7 @@ export interface SummaryStatsProps {
uniqueClients: number;
}
class SummaryStats extends Component<SummaryStatsProps & WithNamespaces, {}> {
class SummaryStats extends Component<SummaryStatsProps & WithTranslation, {}> {
render() {
const { t } = this.props;
@@ -128,7 +128,7 @@ export const initialProps: SummaryStatsProps = {
uniqueClients: 0
};
export const TranslatedSummaryStats = withNamespaces(["common", "dashboard"])(
export const TranslatedSummaryStats = withTranslation(["common", "dashboard"])(
SummaryStats
);
+13 -11
View File
@@ -8,7 +8,7 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */
import React, { Fragment } from "react";
import React, { Fragment, Suspense } from "react";
import DateRangePicker from "react-bootstrap-daterangepicker";
import { Button } from "reactstrap";
import {
@@ -16,7 +16,7 @@ import {
TimeRangeContext
} from "../common/context/TimeRangeContext";
import "bootstrap-daterangepicker/daterangepicker.css";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import { dateRanges } from "../../util/dateRanges";
export interface TimeRangeSelectorProps {
@@ -49,7 +49,7 @@ export interface TimeRangeSelectorProps {
* @param props The selector props
*/
const renderLabel = (
props: TimeRangeSelectorProps & WithNamespaces
props: TimeRangeSelectorProps & WithTranslation
): string | null => {
const { t } = props;
@@ -77,7 +77,7 @@ const renderLabel = (
* predefined, or time range if custom)
*/
export const TimeRangeSelector = (
props: TimeRangeSelectorProps & WithNamespaces
props: TimeRangeSelectorProps & WithTranslation
) => {
const { range, onSelect, t } = props;
@@ -125,19 +125,21 @@ export const TimeRangeSelector = (
);
};
export const TranslatedTimeRangeSelector = withNamespaces("time-ranges")(
export const TranslatedTimeRangeSelector = withTranslation("time-ranges")(
TimeRangeSelector
);
export const TimeRangeSelectorContainer = ({ size }: { size?: string }) => (
<TimeRangeContext.Consumer>
{context => (
<TranslatedTimeRangeSelector
range={context.range}
onSelect={context.update}
showLabel={true}
size={size}
/>
<Suspense fallback={null}>
<TranslatedTimeRangeSelector
range={context.range}
onSelect={context.update}
showLabel={true}
size={size}
/>
</Suspense>
)}
</TimeRangeContext.Consumer>
);
@@ -9,7 +9,7 @@
* Please see LICENSE file for your rights under this license. */
import React, { ReactNode } from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import api from "../../util/api";
import TopTable from "./TopTable";
import i18next from "i18next";
@@ -72,7 +72,7 @@ const TopBlockedClients = ({
apiCall,
t,
...props
}: WithNamespaces & { apiCall: () => Promise<ApiTopBlockedClients> }) => (
}: WithTranslation & { apiCall: () => Promise<ApiTopBlockedClients> }) => (
<TopTable
{...props}
title={t("Top Blocked Clients")}
@@ -89,7 +89,7 @@ const TopBlockedClients = ({
/>
);
const TopBlockedClientsContainer = (props: WithNamespaces) => (
const TopBlockedClientsContainer = (props: WithTranslation) => (
<TimeRangeContext.Consumer>
{context => (
<TopBlockedClients
@@ -104,6 +104,6 @@ const TopBlockedClientsContainer = (props: WithNamespaces) => (
</TimeRangeContext.Consumer>
);
export default withNamespaces(["common", "dashboard"])(
export default withTranslation(["common", "dashboard"])(
TopBlockedClientsContainer
);
@@ -9,7 +9,7 @@
* Please see LICENSE file for your rights under this license. */
import React from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import api from "../../util/api";
import TopTable from "./TopTable";
import i18next from "i18next";
@@ -72,7 +72,7 @@ const TopBlockedDomains = ({
apiCall,
t,
...props
}: WithNamespaces & { apiCall: () => Promise<ApiTopBlockedDomains> }) => (
}: WithTranslation & { apiCall: () => Promise<ApiTopBlockedDomains> }) => (
<TopTable
{...props}
title={t("Top Blocked Domains")}
@@ -89,7 +89,7 @@ const TopBlockedDomains = ({
/>
);
const TopBlockedDomainsContainer = (props: WithNamespaces) => (
const TopBlockedDomainsContainer = (props: WithTranslation) => (
<TimeRangeContext.Consumer>
{context => (
<TopBlockedDomains
@@ -104,6 +104,6 @@ const TopBlockedDomainsContainer = (props: WithNamespaces) => (
</TimeRangeContext.Consumer>
);
export default withNamespaces(["common", "dashboard"])(
export default withTranslation(["common", "dashboard"])(
TopBlockedDomainsContainer
);
+4 -4
View File
@@ -9,7 +9,7 @@
* Please see LICENSE file for your rights under this license. */
import React from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import api from "../../util/api";
import TopTable from "./TopTable";
import i18next from "i18next";
@@ -70,7 +70,7 @@ const TopClients = ({
apiCall,
t,
...props
}: WithNamespaces & { apiCall: () => Promise<ApiTopClients> }) => (
}: WithTranslation & { apiCall: () => Promise<ApiTopClients> }) => (
<TopTable
{...props}
title={t("Top Clients")}
@@ -87,7 +87,7 @@ const TopClients = ({
/>
);
const TopClientsContainer = (props: WithNamespaces) => (
const TopClientsContainer = (props: WithTranslation) => (
<TimeRangeContext.Consumer>
{context => (
<TopClients
@@ -102,4 +102,4 @@ const TopClientsContainer = (props: WithNamespaces) => (
</TimeRangeContext.Consumer>
);
export default withNamespaces(["common", "dashboard"])(TopClientsContainer);
export default withTranslation(["common", "dashboard"])(TopClientsContainer);
+4 -4
View File
@@ -9,7 +9,7 @@
* Please see LICENSE file for your rights under this license. */
import React from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import api from "../../util/api";
import TopTable from "./TopTable";
import i18next from "i18next";
@@ -70,7 +70,7 @@ const TopDomains = ({
apiCall,
t,
...props
}: WithNamespaces & { apiCall: () => Promise<ApiTopDomains> }) => (
}: WithTranslation & { apiCall: () => Promise<ApiTopDomains> }) => (
<TopTable
{...props}
title={t("Top Permitted Domains")}
@@ -87,7 +87,7 @@ const TopDomains = ({
/>
);
const TopDomainsContainer = (props: WithNamespaces) => (
const TopDomainsContainer = (props: WithTranslation) => (
<TimeRangeContext.Consumer>
{context => (
<TopDomains
@@ -102,4 +102,4 @@ const TopDomainsContainer = (props: WithNamespaces) => (
</TimeRangeContext.Consumer>
);
export default withNamespaces(["common", "dashboard"])(TopDomainsContainer);
export default withTranslation(["common", "dashboard"])(TopDomainsContainer);
+1 -2
View File
@@ -10,7 +10,6 @@
import React, { Component, ReactNode } from "react";
import { WithAPIData } from "../common/WithAPIData";
import { Subtract } from "react-i18next";
export interface TopTableInnerProps<T> {
loading: boolean;
@@ -87,7 +86,7 @@ export class TopTable<T> extends Component<TopTableInnerProps<T>, {}> {
}
export interface TopTableProps<T, D>
extends Subtract<TopTableInnerProps<T>, { loading: boolean; data: T }> {
extends Omit<TopTableInnerProps<T>, "loading" | "data"> {
apiCall: () => Promise<D>;
initialData: T;
apiHandler: (data: D) => T;
+4 -4
View File
@@ -9,7 +9,7 @@
* Please see LICENSE file for your rights under this license. */
import React from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import api from "../../util/api";
import GenericDoughnutChart from "./GenericDoughnutChart";
import { TimeRangeContext } from "../common/context/TimeRangeContext";
@@ -17,7 +17,7 @@ import { TimeRangeContext } from "../common/context/TimeRangeContext";
const UpstreamsChart = ({
t,
apiCall
}: WithNamespaces & { apiCall: () => Promise<ApiUpstreams> }) => (
}: WithTranslation & { apiCall: () => Promise<ApiUpstreams> }) => (
<GenericDoughnutChart
title={t("Queries Answered By Destination")}
apiCall={apiCall}
@@ -31,7 +31,7 @@ const UpstreamsChart = ({
/>
);
export const UpstreamsChartContainer = (props: WithNamespaces) => (
export const UpstreamsChartContainer = (props: WithTranslation) => (
<TimeRangeContext.Consumer>
{context => (
<UpstreamsChart
@@ -44,4 +44,4 @@ export const UpstreamsChartContainer = (props: WithNamespaces) => (
</TimeRangeContext.Consumer>
);
export default withNamespaces("dashboard")(UpstreamsChartContainer);
export default withTranslation("dashboard")(UpstreamsChartContainer);
+3 -3
View File
@@ -9,10 +9,10 @@
* Please see LICENSE file for your rights under this license. */
import React, { ChangeEvent, Component, FormEvent } from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import api from "../../util/api";
export interface DomainInputProps extends WithNamespaces {
export interface DomainInputProps extends WithTranslation {
placeholder?: string;
onEnter: (domain: string) => void;
onRefresh: () => void;
@@ -92,4 +92,4 @@ class DomainInput extends Component<DomainInputProps, DomainInputState> {
}
}
export default withNamespaces(["common", "lists"])(DomainInput);
export default withTranslation(["common", "lists"])(DomainInput);
+3 -3
View File
@@ -9,12 +9,12 @@
* Please see LICENSE file for your rights under this license. */
import React from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import api from "../../util/api";
import { Button } from "reactstrap";
import Alert from "../common/Alert";
export interface DomainListProps extends WithNamespaces {
export interface DomainListProps extends WithTranslation {
domains: string[];
onRemove: (domain: string) => void;
}
@@ -66,4 +66,4 @@ const DomainList = ({ domains, onRemove, t }: DomainListProps) => {
return <ul className="list-group">{body}</ul>;
};
export default withNamespaces(["common", "lists"])(DomainList);
export default withTranslation(["common", "lists"])(DomainList);
+3 -3
View File
@@ -9,7 +9,7 @@
* Please see LICENSE file for your rights under this license. */
import React, { Component } from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import DomainInput from "./DomainInput";
import Alert, { AlertType } from "../common/Alert";
import DomainList from "./DomainList";
@@ -19,7 +19,7 @@ import {
makeCancelable
} from "../../util/CancelablePromise";
export interface ListPageProps extends WithNamespaces {
export interface ListPageProps extends WithTranslation {
title: string;
note?: {} | string;
placeholder: string;
@@ -178,4 +178,4 @@ export class ListPage extends Component<ListPageProps, ListPageState> {
}
}
export default withNamespaces(["common", "lists"])(ListPage);
export default withTranslation(["common", "lists"])(ListPage);
+6 -4
View File
@@ -17,7 +17,7 @@ import ReactTable, {
} from "react-table";
import i18n from "i18next";
import i18next from "i18next";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import debounce from "lodash.debounce";
import moment from "moment";
import { padNumber } from "../../util/graphUtils";
@@ -58,7 +58,7 @@ const getDefaultRange = (t: i18next.TFunction): TimeRange => {
};
};
class QueryLog extends Component<WithNamespaces, QueryLogState> {
class QueryLog extends Component<WithTranslation, QueryLogState> {
private updateHandler: null | CancelablePromise<ApiHistoryResponse> = null;
state: QueryLogState = {
@@ -70,7 +70,7 @@ class QueryLog extends Component<WithNamespaces, QueryLogState> {
filters: []
};
constructor(props: WithNamespaces) {
constructor(props: WithTranslation) {
super(props);
const { t } = this.props;
@@ -545,4 +545,6 @@ const columns = (t: i18next.TFunction) => [
}
];
export default withNamespaces(["common", "query-log", "time-ranges"])(QueryLog);
export default withTranslation(["common", "query-log", "time-ranges"])(
QueryLog
);
+3 -3
View File
@@ -9,9 +9,9 @@
* Please see LICENSE file for your rights under this license. */
import React, { Component } from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
export interface ForgotPasswordProps extends WithNamespaces {
export interface ForgotPasswordProps extends WithTranslation {
error: boolean;
}
@@ -91,4 +91,4 @@ class ForgotPassword extends Component<
}
}
export default withNamespaces("login")(ForgotPassword);
export default withTranslation("login")(ForgotPassword);
+3 -3
View File
@@ -9,7 +9,7 @@
* Please see LICENSE file for your rights under this license. */
import React, { ChangeEvent, Component, FormEvent } from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import {
CancelablePromise,
ignoreCancel,
@@ -37,7 +37,7 @@ export interface DHCPInfoState {
settings: ApiDhcpSettings;
}
class DHCPInfo extends Component<WithNamespaces, DHCPInfoState> {
class DHCPInfo extends Component<WithTranslation, DHCPInfoState> {
state: DHCPInfoState = {
alertMessage: "",
alertType: "info",
@@ -332,4 +332,4 @@ class DHCPInfo extends Component<WithNamespaces, DHCPInfoState> {
}
}
export default withNamespaces(["common", "settings", "api-errors"])(DHCPInfo);
export default withTranslation(["common", "settings", "api-errors"])(DHCPInfo);
+3 -3
View File
@@ -9,7 +9,7 @@
* Please see LICENSE file for your rights under this license. */
import React, { Component, FormEvent } from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import {
CancelablePromise,
ignoreCancel,
@@ -35,7 +35,7 @@ export interface DNSInfoState {
options: DnsOptionsObject;
}
class DNSInfo extends Component<WithNamespaces, DNSInfoState> {
class DNSInfo extends Component<WithTranslation, DNSInfoState> {
state: DNSInfoState = {
alertMessage: "",
alertType: "info",
@@ -252,4 +252,4 @@ class DNSInfo extends Component<WithNamespaces, DNSInfoState> {
}
}
export default withNamespaces(["common", "settings"])(DNSInfo);
export default withTranslation(["common", "settings"])(DNSInfo);
+4 -4
View File
@@ -11,7 +11,7 @@
import React, { Component, RefObject } from "react";
import { Button, InputGroup, InputGroupAddon, ListGroupItem } from "reactstrap";
import { Typeahead } from "react-bootstrap-typeahead";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import {
PreconfiguredUpstreamOption,
preconfiguredUpstreamOptions
@@ -33,7 +33,7 @@ export interface DnsListNewItemState {
* a list of preconfigured upstreams, or custom servers can be input.
*/
class DnsListNewItem extends Component<
DnsListNewItemProps & WithNamespaces,
DnsListNewItemProps & WithTranslation,
DnsListNewItemState
> {
state: DnsListNewItemState = {
@@ -43,7 +43,7 @@ class DnsListNewItem extends Component<
private readonly typeahead: RefObject<any>;
constructor(props: DnsListNewItemProps & WithNamespaces) {
constructor(props: DnsListNewItemProps & WithTranslation) {
super(props);
this.typeahead = React.createRef();
}
@@ -105,4 +105,4 @@ class DnsListNewItem extends Component<
}
}
export default withNamespaces("settings")(DnsListNewItem);
export default withTranslation("settings")(DnsListNewItem);
+3 -3
View File
@@ -9,7 +9,7 @@
* Please see LICENSE file for your rights under this license. */
import React, { Component } from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import api from "../../util/api";
import { WithAPIData } from "../common/WithAPIData";
@@ -19,7 +19,7 @@ export interface FTLInfoProps {
sqliteVersion: string;
}
class FTLInfo extends Component<FTLInfoProps & WithNamespaces, {}> {
class FTLInfo extends Component<FTLInfoProps & WithTranslation, {}> {
render() {
const { t } = this.props;
@@ -47,7 +47,7 @@ export const initialData = {
sqliteVersion: ""
};
export const TranslatedFTLInfo = withNamespaces(["settings"])(FTLInfo);
export const TranslatedFTLInfo = withTranslation(["settings"])(FTLInfo);
export default (props: any) => (
<WithAPIData
+4 -4
View File
@@ -9,12 +9,12 @@
* Please see LICENSE file for your rights under this license. */
import React, { Component } from "react";
import { Subtract, WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import api from "../../util/api";
import { Col, Form, FormGroup, Input, Label } from "reactstrap";
import { WithAPIData } from "../common/WithAPIData";
export interface NetworkInfoProps extends WithNamespaces {
export interface NetworkInfoProps extends WithTranslation {
interface: string;
ipv4Address: string;
ipv6Address: string;
@@ -86,7 +86,7 @@ class NetworkInfo extends Component<NetworkInfoProps, {}> {
export const transformData = (
data: ApiNetworkSettings
): Subtract<NetworkInfoProps, WithNamespaces> => ({
): Omit<NetworkInfoProps, keyof WithTranslation> => ({
interface: data.interface,
ipv4Address: data.ipv4_address,
ipv6Address: data.ipv6_address,
@@ -100,7 +100,7 @@ export const initialData = () => ({
hostname: ""
});
export const TranslatedNetworkInfo = withNamespaces(["common", "settings"])(
export const TranslatedNetworkInfo = withTranslation(["common", "settings"])(
NetworkInfo
);
@@ -9,7 +9,7 @@
* Please see LICENSE file for your rights under this license. */
import React, { ChangeEvent, Component, FormEvent } from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import {
CancelablePromise,
ignoreCancel,
@@ -37,7 +37,7 @@ export interface PreferenceSettingsState {
}
class PreferenceSettings extends Component<
PreferenceSettingsProps & WithNamespaces,
PreferenceSettingsProps & WithTranslation,
PreferenceSettingsState
> {
state: PreferenceSettingsState = {
@@ -236,7 +236,7 @@ class PreferenceSettings extends Component<
}
}
const TranslatedPreferenceSettings = withNamespaces([
const TranslatedPreferenceSettings = withTranslation([
"common",
"settings",
"api-errors",
+3 -3
View File
@@ -9,10 +9,10 @@
* Please see LICENSE file for your rights under this license. */
import React, { Component } from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import { Collapse } from "reactstrap";
export interface VersionCardProps extends WithNamespaces {
export interface VersionCardProps extends WithTranslation {
branch: string;
hash: string;
name: string;
@@ -79,4 +79,4 @@ class VersionCard extends Component<VersionCardProps, VersionCardState> {
}
}
export default withNamespaces(["common", "settings"])(VersionCard);
export default withTranslation(["common", "settings"])(VersionCard);
+3 -3
View File
@@ -9,12 +9,12 @@
* Please see LICENSE file for your rights under this license. */
import React, { Component } from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import api from "../../util/api";
import VersionCard from "./VersionCard";
import { WithAPIData } from "../common/WithAPIData";
class VersionInfo extends Component<ApiVersions & WithNamespaces, {}> {
class VersionInfo extends Component<ApiVersions & WithTranslation, {}> {
render() {
const { t } = this.props;
@@ -84,7 +84,7 @@ export const initialData: ApiVersions = {
}
};
export const TranslatedVersionInfo = withNamespaces(["common"])(VersionInfo);
export const TranslatedVersionInfo = withTranslation(["common"])(VersionInfo);
export default (props: any) => (
<WithAPIData
@@ -12,7 +12,7 @@ import React from "react";
import { shallow, ShallowWrapper } from "enzyme";
import DHCPInfo, { DHCPInfoState } from "../DHCPInfo";
import fetchMock from "fetch-mock";
import { WithNamespaces } from "react-i18next";
import { WithTranslation } from "react-i18next";
const tick = global.tick;
@@ -55,7 +55,7 @@ it("disables the apply button if an input is invalid", async () => {
it("disables inputs only when DHCP is not enabled", async () => {
fetchMock.mock(endpoint, { body: fakeData });
const wrapper: ShallowWrapper<WithNamespaces, DHCPInfoState> = shallow(
const wrapper: ShallowWrapper<WithTranslation, DHCPInfoState> = shallow(
<DHCPInfo />
);
@@ -75,7 +75,7 @@ it("disables the apply button when processing setting update", async () => {
fetchMock.get(endpoint, { body: fakeData });
fetchMock.put(endpoint, { body: { status: "success" } });
const wrapper: ShallowWrapper<WithNamespaces, DHCPInfoState> = shallow(
const wrapper: ShallowWrapper<WithTranslation, DHCPInfoState> = shallow(
<DHCPInfo />
);
@@ -94,7 +94,7 @@ it("sends the correct data to the API when apply is clicked", async () => {
fetchMock.get(endpoint, { body: fakeData });
fetchMock.put(endpoint, { body: { status: "success" } });
const wrapper: ShallowWrapper<WithNamespaces, DHCPInfoState> = shallow(
const wrapper: ShallowWrapper<WithTranslation, DHCPInfoState> = shallow(
<DHCPInfo />
);
+8 -6
View File
@@ -8,7 +8,7 @@
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */
import React, { ComponentType, ReactNode } from "react";
import React, { ComponentType, ReactNode, Suspense } from "react";
import { Redirect, Route, Switch } from "react-router-dom";
import Header, { mobileSidebarHide } from "../components/common/Header";
import Sidebar from "../components/common/Sidebar";
@@ -35,10 +35,12 @@ export default (props: any) => (
<Sidebar items={nav} {...props} />
<main className="main" onClick={mobileSidebarHide}>
<div className="container-fluid" style={{ marginTop: "1.5rem" }}>
<Switch>
<Redirect exact from="/" to="/dashboard" />
{nav.map(createRoute)}
</Switch>
<Suspense fallback={null}>
<Switch>
<Redirect exact from="/" to="/dashboard" />
{nav.map(createRoute)}
</Switch>
</Suspense>
</div>
</main>
</div>
@@ -54,7 +56,7 @@ export default (props: any) => (
* @param routeData the route data (see routes.tsx)
*/
const createRoute = (routeData: RouteData): ReactNode => {
if ((routeData as RouteCustomItem).fakeRoute === true) {
if ((routeData as RouteCustomItem).fakeRoute) {
return;
}
+2 -2
View File
@@ -24,8 +24,8 @@ global.t = ((key: string) => key) as i18next.TFunction;
// Mock out react-i18next
jest.mock("react-i18next", () => ({
// This mock makes sure any components using the withNamespaces HoC receive the t function as a prop
withNamespaces: () => (component: any) => {
// This mock makes sure any components using the withTranslation HoC receive the t function as a prop
withTranslation: () => (component: any) => {
component.defaultProps = {
...component.defaultProps,
t: global.t
+1 -1
View File
@@ -14,7 +14,7 @@ import { setupI18n } from "../i18n";
// testing.
// https://github.com/i18next/react-i18next/issues/434
jest.mock("react-i18next", () => ({
reactI18nextModule: {
initReactI18next: {
type: "3rdParty",
init: () => {}
}
+2 -6
View File
@@ -11,7 +11,7 @@
import i18n from "i18next";
import XHR from "i18next-xhr-backend";
import LanguageDetector from "i18next-browser-languagedetector";
import { reactI18nextModule } from "react-i18next";
import { initReactI18next } from "react-i18next";
import config from "../config";
import languages from "../languages.json";
@@ -24,7 +24,7 @@ export function setupI18n(ajax?: any) {
return i18n
.use(XHR)
.use(LanguageDetector)
.use(reactI18nextModule)
.use(initReactI18next)
.init({
fallbackLng: "en",
whitelist: languages,
@@ -53,10 +53,6 @@ export function setupI18n(ajax?: any) {
backend: {
loadPath: process.env.PUBLIC_URL + "/i18n/{{lng}}/{{ns}}.json",
ajax
},
react: {
// Wait until translations are loaded before rendering
wait: true
}
});
}
+3 -3
View File
@@ -9,12 +9,12 @@
* Please see LICENSE file for your rights under this license. */
import React, { FunctionComponent } from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import api from "../util/api";
import ListPage from "../components/list/ListPage";
import { isValidHostname } from "../util/validate";
const Blacklist: FunctionComponent<WithNamespaces> = props => {
const Blacklist: FunctionComponent<WithTranslation> = props => {
const { t } = props;
return (
@@ -31,4 +31,4 @@ const Blacklist: FunctionComponent<WithNamespaces> = props => {
);
};
export default withNamespaces(["location", "lists"])(Blacklist);
export default withTranslation(["location", "lists"])(Blacklist);
+3 -3
View File
@@ -15,11 +15,11 @@ import api from "../util/api";
import logo from "../img/logo.svg";
import { routes } from "../routes";
import ForgotPassword from "../components/login/ForgotPassword";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import config from "../config";
import { History, LocationDescriptorObject } from "history";
export interface LoginProps extends WithNamespaces {
export interface LoginProps extends WithTranslation {
location: LocationDescriptorObject<{ from: Location }>;
history: History;
}
@@ -176,4 +176,4 @@ class Login extends Component<LoginProps, LoginState> {
}
}
export default withNamespaces(["login", "location"])(Login);
export default withTranslation(["login", "location"])(Login);
+3 -3
View File
@@ -9,7 +9,7 @@
* Please see LICENSE file for your rights under this license. */
import React, { Component, ReactNode } from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import { Nav, NavItem, NavLink, TabContent, TabPane } from "reactstrap";
import DHCPInfo from "../components/settings/DHCPInfo";
import DNSInfo from "../components/settings/DNSInfo";
@@ -20,7 +20,7 @@ export interface NetworkingState {
activeTab: string;
}
class Networking extends Component<WithNamespaces, NetworkingState> {
class Networking extends Component<WithTranslation, NetworkingState> {
state = {
activeTab: "network"
};
@@ -89,4 +89,4 @@ class Networking extends Component<WithNamespaces, NetworkingState> {
}
}
export default withNamespaces(["common", "settings"])(Networking);
export default withTranslation(["common", "settings"])(Networking);
+3 -3
View File
@@ -9,12 +9,12 @@
* Please see LICENSE file for your rights under this license. */
import React, { FunctionComponent } from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import ListPage from "../components/list/ListPage";
import api from "../util/api";
import { isValidRegex } from "../util/validate";
const Regexlist: FunctionComponent<WithNamespaces> = props => {
const Regexlist: FunctionComponent<WithTranslation> = props => {
const { t } = props;
return (
@@ -31,4 +31,4 @@ const Regexlist: FunctionComponent<WithNamespaces> = props => {
);
};
export default withNamespaces(["location", "lists"])(Regexlist);
export default withTranslation(["location", "lists"])(Regexlist);
+3 -3
View File
@@ -9,12 +9,12 @@
* Please see LICENSE file for your rights under this license. */
import React, { FunctionComponent } from "react";
import { WithNamespaces, withNamespaces } from "react-i18next";
import { WithTranslation, withTranslation } from "react-i18next";
import ListPage from "../components/list/ListPage";
import api from "../util/api";
import { isValidHostname } from "../util/validate";
const Whitelist: FunctionComponent<WithNamespaces> = props => {
const Whitelist: FunctionComponent<WithTranslation> = props => {
const { t } = props;
return (
@@ -31,4 +31,4 @@ const Whitelist: FunctionComponent<WithNamespaces> = props => {
);
};
export default withNamespaces(["location", "lists"])(Whitelist);
export default withTranslation(["location", "lists"])(Whitelist);