diff --git a/pom.xml b/pom.xml
index a7e6daba5b..910287abf0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -398,6 +398,14 @@
1.1.1
+
+
+
+ commons-codec
+ commons-codec
+ 1.13
+
+
@@ -826,7 +834,7 @@
3.6.2.Final
1.19.4
2.11.1
- 2.9.8
+ 2.10.0
4.0
2.3.0
@@ -834,12 +842,12 @@
1.5.1
- 9.4.14.v20181114
- 9.4.14.v20181114
+ 9.4.22.v20191022
+ 9.4.22.v20191022
1.2.0
- 1.4.0
+ 1.4.1
v5.4.0.201906121030-r-scm2
diff --git a/scm-ui/ui-components/src/DateFromNow.test.ts b/scm-ui/ui-components/src/DateFromNow.test.ts
new file mode 100644
index 0000000000..b791b5019d
--- /dev/null
+++ b/scm-ui/ui-components/src/DateFromNow.test.ts
@@ -0,0 +1,25 @@
+import { chooseLocale, supportedLocales } from "./DateFromNow";
+
+describe("test choose locale", () => {
+
+ it("should choose de", () => {
+ const locale = chooseLocale("de_DE", ["de", "en"]);
+ expect(locale).toBe(supportedLocales.de);
+ });
+
+ it("should choose de, even without language array", () => {
+ const locale = chooseLocale("de", []);
+ expect(locale).toBe(supportedLocales.de);
+ });
+
+ it("should choose es", () => {
+ const locale = chooseLocale("de", ["af", "be", "es"]);
+ expect(locale).toBe(supportedLocales.es);
+ });
+
+ it("should fallback en", () => {
+ const locale = chooseLocale("af", ["af", "be"]);
+ expect(locale).toBe(supportedLocales.en);
+ });
+
+});
diff --git a/scm-ui/ui-components/src/DateFromNow.tsx b/scm-ui/ui-components/src/DateFromNow.tsx
index a81cd625ba..4f2a70c7ee 100644
--- a/scm-ui/ui-components/src/DateFromNow.tsx
+++ b/scm-ui/ui-components/src/DateFromNow.tsx
@@ -10,8 +10,9 @@ type LocaleMap = {
type DateInput = Date | string;
-const supportedLocales: LocaleMap = {
+export const supportedLocales: LocaleMap = {
enUS,
+ en: enUS,
de,
es
};
@@ -40,14 +41,26 @@ const DateElement = styled.time`
cursor: help;
`;
+export const chooseLocale = (language: string, languages?: string[]) => {
+ for (const lng of languages || []) {
+ const locale = supportedLocales[lng];
+ if (locale) {
+ return locale;
+ }
+ }
+
+ const locale = supportedLocales[language];
+ if (locale) {
+ return locale;
+ }
+
+ return enUS;
+};
+
class DateFromNow extends React.Component {
getLocale = (): Locale => {
const { i18n } = this.props;
- const locale = supportedLocales[i18n.language];
- if (!locale) {
- return enUS;
- }
- return locale;
+ return chooseLocale(i18n.language, i18n.languages);
};
createOptions = () => {
@@ -64,7 +77,7 @@ class DateFromNow extends React.Component {
toDate = (value: DateInput): Date => {
if (value instanceof Date) {
- return value as Date;
+ return value;
}
return parseISO(value);
};
diff --git a/scm-ui/ui-webapp/src/containers/PluginLoader.tsx b/scm-ui/ui-webapp/src/containers/PluginLoader.tsx
index e24dd7e0f2..dd7d7b5152 100644
--- a/scm-ui/ui-webapp/src/containers/PluginLoader.tsx
+++ b/scm-ui/ui-webapp/src/containers/PluginLoader.tsx
@@ -1,4 +1,4 @@
-import * as React from "react";
+import React, { ReactNode } from "react";
import { apiClient, Loading } from "@scm-manager/ui-components";
import { getUiPluginsLink } from "../modules/indexResource";
import { connect } from "react-redux";
@@ -6,7 +6,7 @@ import loadBundle from "./loadBundle";
type Props = {
loaded: boolean;
- children: React.Node;
+ children: ReactNode;
link: string;
callback: () => void;
};
@@ -55,7 +55,7 @@ class PluginLoader extends React.Component {
});
const promises = [];
- const sortedPlugins = plugins.sort(comparePluginsByName);
+ const sortedPlugins = [...plugins].sort(comparePluginsByName);
for (const plugin of sortedPlugins) {
promises.push(this.loadPlugin(plugin));
}
@@ -96,7 +96,8 @@ const comparePluginsByName = (a: Plugin, b: Plugin) => {
}
return 0;
};
-const mapStateToProps = state => {
+
+const mapStateToProps = (state: any) => {
const link = getUiPluginsLink(state);
return {
link
diff --git a/scm-ui/ui-webapp/src/i18n.ts b/scm-ui/ui-webapp/src/i18n.ts
index f7dc75d910..14898b402d 100644
--- a/scm-ui/ui-webapp/src/i18n.ts
+++ b/scm-ui/ui-webapp/src/i18n.ts
@@ -7,8 +7,6 @@ import { urls } from "@scm-manager/ui-components";
const loadPath = urls.withContextPath("/locales/{{lng}}/{{ns}}.json");
-// TODO load locales for moment
-
i18n
.use(Backend)
.use(LanguageDetector)
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 575544e1f5..150e4d1eb6 100644
--- a/scm-ui/ui-webapp/src/repos/sources/components/FileTree.tsx
+++ b/scm-ui/ui-webapp/src/repos/sources/components/FileTree.tsx
@@ -87,7 +87,8 @@ class FileTree extends React.Component {
};
if (tree._embedded && tree._embedded.children) {
- files.push(...tree._embedded.children.sort(compareFiles));
+ const children = [...tree._embedded.children].sort(compareFiles);
+ files.push(...children);
}
if (files && files.length > 0) {
diff --git a/scm-webapp/pom.xml b/scm-webapp/pom.xml
index 73431b780e..571c3b5370 100644
--- a/scm-webapp/pom.xml
+++ b/scm-webapp/pom.xml
@@ -235,7 +235,6 @@
commons-codec
commons-codec
- 1.9
@@ -273,7 +272,7 @@
org.apache.tika
tika-core
- 1.20
+ 1.22