@truedat/core 6.1.3 → 6.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/api.js +0 -1
- package/src/components/AdminMenu.js +2 -0
- package/src/components/__tests__/__snapshots__/AdminMenu.spec.js.snap +13 -0
- package/src/components/__tests__/__snapshots__/SideMenu.spec.js.snap +6 -0
- package/src/hooks/useLocales.js +6 -31
- package/src/i18n/components/LangProvider.js +47 -0
- package/src/i18n/components/Languages.js +105 -99
- package/src/i18n/components/MessageForm.js +23 -9
- package/src/i18n/components/Messages.js +34 -13
- package/src/i18n/components/__tests__/__snapshots__/MessageForm.spec.js.snap +0 -44
- package/src/i18n/components/__tests__/__snapshots__/Messages.spec.js.snap +11 -113
- package/src/i18n/components/__tests__/__snapshots__/NewMessage.spec.js.snap +0 -44
- package/src/i18n/components/index.js +2 -1
- package/src/messages/en.js +1 -0
- package/src/messages/es.js +1 -0
- package/src/routes.js +2 -0
- package/src/hooks/useAllLocales.js +0 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/core",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.5",
|
|
4
4
|
"description": "Truedat Web Core",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@testing-library/jest-dom": "^5.16.5",
|
|
36
36
|
"@testing-library/react": "^12.0.0",
|
|
37
37
|
"@testing-library/user-event": "^13.2.1",
|
|
38
|
-
"@truedat/test": "6.1.
|
|
38
|
+
"@truedat/test": "6.1.5",
|
|
39
39
|
"babel-jest": "^28.1.0",
|
|
40
40
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
41
41
|
"babel-plugin-lodash": "^3.3.4",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"react-dom": ">= 16.8.6 < 17",
|
|
118
118
|
"semantic-ui-react": ">= 2.0.3 < 2.2"
|
|
119
119
|
},
|
|
120
|
-
"gitHead": "
|
|
120
|
+
"gitHead": "3cbadffa2227cac1cce3c21d8442245082324ac1"
|
|
121
121
|
}
|
package/src/api.js
CHANGED
|
@@ -2,7 +2,6 @@ export const API_COMMENTS = "/api/business_concepts/comments";
|
|
|
2
2
|
export const API_LOCALE = "/api/locales/:id";
|
|
3
3
|
export const API_LOCALE_MESSAGES = "/api/locales/:lang/messages";
|
|
4
4
|
export const API_LOCALES = "/api/locales";
|
|
5
|
-
export const API_ALL_LOCALES = "/api/locales/all_locales";
|
|
6
5
|
export const API_MESSAGE = "/api/messages/:id";
|
|
7
6
|
export const API_MESSAGES = "/api/messages";
|
|
8
7
|
export const API_REINDEX_GRANTS = "/api/grants/search/reindex_all";
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
SUBSCRIPTIONS,
|
|
11
11
|
TASKS,
|
|
12
12
|
TEMPLATES,
|
|
13
|
+
ELASTICINDEXES,
|
|
13
14
|
} from "../routes";
|
|
14
15
|
import Submenu from "./Submenu";
|
|
15
16
|
|
|
@@ -23,6 +24,7 @@ const items = [
|
|
|
23
24
|
{ name: "configurations", routes: [CONFIGURATIONS] },
|
|
24
25
|
{ name: "i18nMessages", routes: [I18N_MESSAGES] },
|
|
25
26
|
{ name: "tasks", routes: [TASKS] },
|
|
27
|
+
{ name: "elasticIndexes", routes: [ELASTICINDEXES] },
|
|
26
28
|
];
|
|
27
29
|
|
|
28
30
|
export const AdminMenu = () => {
|
|
@@ -147,6 +147,19 @@ exports[`<AdminMenu /> matches the latest snapshot 1`] = `
|
|
|
147
147
|
Tasks
|
|
148
148
|
</span>
|
|
149
149
|
</a>
|
|
150
|
+
<a
|
|
151
|
+
aria-checked="false"
|
|
152
|
+
class="item"
|
|
153
|
+
href="/search/elasticIndexes"
|
|
154
|
+
name="elasticIndexes"
|
|
155
|
+
role="option"
|
|
156
|
+
>
|
|
157
|
+
<span
|
|
158
|
+
class="text"
|
|
159
|
+
>
|
|
160
|
+
elasticIndexes
|
|
161
|
+
</span>
|
|
162
|
+
</a>
|
|
150
163
|
</div>
|
|
151
164
|
</div>
|
|
152
165
|
</div>
|
package/src/hooks/useLocales.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import _ from "lodash/fp";
|
|
2
1
|
import { compile } from "path-to-regexp";
|
|
3
2
|
import useSWR from "swr";
|
|
4
3
|
import useSWRMutations from "swr/mutation";
|
|
5
4
|
import { API_LOCALES, API_LOCALE } from "../api";
|
|
6
|
-
import {
|
|
7
|
-
apiJson,
|
|
8
|
-
apiJsonDelete,
|
|
9
|
-
apiJsonPatch,
|
|
10
|
-
apiJsonPost,
|
|
11
|
-
} from "../services/api";
|
|
5
|
+
import { apiJson, apiJsonPatch } from "../services/api";
|
|
12
6
|
|
|
13
7
|
const toApiLocalesPath = compile(API_LOCALES);
|
|
14
8
|
|
|
@@ -20,32 +14,13 @@ export const useLocales = (includeMessages = true) => {
|
|
|
20
14
|
return { locales, error, loading: !error && !data, mutate, isValidating };
|
|
21
15
|
};
|
|
22
16
|
|
|
23
|
-
export const useLocalesUpdate = (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const payload = { id: arg.id, locale: arg };
|
|
29
|
-
apiJsonPatch(url, payload).then(() => {
|
|
17
|
+
export const useLocalesUpdate = () => {
|
|
18
|
+
return useSWRMutations("api/locales", (_url, { arg }) => {
|
|
19
|
+
const { id, locale, mutateData, handleDimmer } = arg;
|
|
20
|
+
const toApiPath = compile(API_LOCALE);
|
|
21
|
+
apiJsonPatch(toApiPath({ id }), { id, locale }).then(() => {
|
|
30
22
|
mutateData();
|
|
31
23
|
handleDimmer(false);
|
|
32
24
|
});
|
|
33
25
|
});
|
|
34
26
|
};
|
|
35
|
-
|
|
36
|
-
export const useLocalesCreate = () => {
|
|
37
|
-
const url = API_LOCALES;
|
|
38
|
-
|
|
39
|
-
return useSWRMutations(url, (url, { arg }) => {
|
|
40
|
-
apiJsonPost(url, arg);
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const useLocalesDelete = (id) => {
|
|
45
|
-
const toApiPath = compile(API_LOCALE);
|
|
46
|
-
const url = toApiPath({ id });
|
|
47
|
-
return useSWRMutations(url, (url, { arg }) => {
|
|
48
|
-
const payload = { id: arg.id };
|
|
49
|
-
apiJsonDelete(url, payload);
|
|
50
|
-
});
|
|
51
|
-
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import React, { useEffect, useState } from "react";
|
|
3
|
+
import { IntlProvider } from "react-intl";
|
|
4
|
+
import { Loading } from "@truedat/core/components";
|
|
5
|
+
import { useLocales } from "../../hooks/useLocales";
|
|
6
|
+
import { useMessages } from "../../hooks/useMessages";
|
|
7
|
+
|
|
8
|
+
const LangProvider = ({ children, defaultMessages }) => {
|
|
9
|
+
const { locales } = useLocales(false);
|
|
10
|
+
const [lang, setLang] = useState("en");
|
|
11
|
+
const [enabledLocales, setEnabledLocales] = useState([]);
|
|
12
|
+
const { messages, loading } = useMessages(lang);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
_.flow(
|
|
15
|
+
_.filter("is_enabled"),
|
|
16
|
+
_.map("lang"),
|
|
17
|
+
setEnabledLocales
|
|
18
|
+
)(locales || []);
|
|
19
|
+
}, [locales, setEnabledLocales]);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
const language =
|
|
22
|
+
(navigator.languages && navigator.languages[0]) ||
|
|
23
|
+
navigator.language ||
|
|
24
|
+
navigator.userLanguage ||
|
|
25
|
+
"en-US";
|
|
26
|
+
const mapLocale = _.cond([
|
|
27
|
+
[(l) => _.includes(l)(enabledLocales), (l) => l],
|
|
28
|
+
[(l) => _.includes(l)(["es", "ca", "eu", "gl"]), _.constant("es")],
|
|
29
|
+
[_.stubTrue, _.constant("en")],
|
|
30
|
+
]);
|
|
31
|
+
_.flow(_.split("-"), _.head, mapLocale, setLang)(language);
|
|
32
|
+
}, [navigator, enabledLocales, setLang]);
|
|
33
|
+
|
|
34
|
+
return loading ? (
|
|
35
|
+
<Loading />
|
|
36
|
+
) : (
|
|
37
|
+
<IntlProvider
|
|
38
|
+
locale={lang}
|
|
39
|
+
defaultLocale={lang}
|
|
40
|
+
messages={messages || defaultMessages[lang]}
|
|
41
|
+
>
|
|
42
|
+
{children}
|
|
43
|
+
</IntlProvider>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default LangProvider;
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
Icon,
|
|
11
11
|
Input,
|
|
12
12
|
Loader,
|
|
13
|
+
Popup,
|
|
13
14
|
Table,
|
|
14
15
|
TableBody,
|
|
15
16
|
TableCell,
|
|
@@ -17,133 +18,127 @@ import {
|
|
|
17
18
|
TableRow,
|
|
18
19
|
} from "semantic-ui-react";
|
|
19
20
|
import { ConfirmModal } from "@truedat/core/components";
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
useLocalesCreate,
|
|
23
|
-
useLocalesDelete,
|
|
24
|
-
useLocalesUpdate,
|
|
25
|
-
useLocales,
|
|
26
|
-
} from "../../hooks/useLocales";
|
|
21
|
+
import { useLocalesUpdate } from "../../hooks/useLocales";
|
|
27
22
|
|
|
28
|
-
const LanguajeRow = ({
|
|
23
|
+
const LanguajeRow = ({
|
|
24
|
+
locale: { id, lang, name, local_name, is_default, is_required, trigger },
|
|
25
|
+
anyDefault,
|
|
26
|
+
mutate,
|
|
27
|
+
handleDimmer,
|
|
28
|
+
}) => {
|
|
29
29
|
const { formatMessage } = useIntl();
|
|
30
|
-
const { trigger } = useLocalesUpdate(config.id);
|
|
31
|
-
const { trigger: triggerDelete } = useLocalesDelete(config.id);
|
|
32
30
|
|
|
33
31
|
const handleChange = (data) => {
|
|
34
|
-
const { name, checked } = data;
|
|
35
|
-
const newConfig = {
|
|
36
|
-
...config,
|
|
37
|
-
[name]: !checked,
|
|
38
|
-
};
|
|
39
32
|
handleDimmer(true);
|
|
40
|
-
trigger({
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const handleDelete = () => {
|
|
44
|
-
triggerDelete(config).then(() => {
|
|
45
|
-
mutate();
|
|
46
|
-
});
|
|
33
|
+
trigger(_.merge({ mutateData: mutate, handleDimmer: handleDimmer })(data));
|
|
47
34
|
};
|
|
48
35
|
|
|
49
36
|
return (
|
|
50
37
|
<TableRow>
|
|
51
38
|
<TableCell>
|
|
52
|
-
{
|
|
39
|
+
{`${name} ( ${local_name} )`}{" "}
|
|
40
|
+
{is_default ? (
|
|
41
|
+
<Popup
|
|
42
|
+
trigger={<Icon name="star" color="yellow" />}
|
|
43
|
+
content={formatMessage({
|
|
44
|
+
id: "i18n.messages.locale.default",
|
|
45
|
+
})}
|
|
46
|
+
/>
|
|
47
|
+
) : null}
|
|
53
48
|
</TableCell>
|
|
54
49
|
<TableCell textAlign="center">
|
|
55
50
|
<Input
|
|
56
51
|
type="checkbox"
|
|
57
52
|
name="is_required"
|
|
58
|
-
checked={
|
|
59
|
-
disabled={
|
|
60
|
-
onChange={(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
<TableCell textAlign="center">
|
|
64
|
-
<Input
|
|
65
|
-
id={`radio-${code}`}
|
|
66
|
-
type="radio"
|
|
67
|
-
name="is_default"
|
|
68
|
-
checked={config.is_default}
|
|
69
|
-
onChange={(_e, data) => handleChange(data)}
|
|
53
|
+
checked={is_required}
|
|
54
|
+
disabled={is_default}
|
|
55
|
+
onChange={() =>
|
|
56
|
+
handleChange({ id, locale: { is_required: !is_required } })
|
|
57
|
+
}
|
|
70
58
|
/>
|
|
71
59
|
</TableCell>
|
|
60
|
+
{!anyDefault ? (
|
|
61
|
+
<TableCell textAlign="center">
|
|
62
|
+
<Input
|
|
63
|
+
id={`radio-${lang}`}
|
|
64
|
+
type="radio"
|
|
65
|
+
name="is_default"
|
|
66
|
+
checked={is_default}
|
|
67
|
+
onChange={() => handleChange({ id, locale: { is_default: true } })}
|
|
68
|
+
/>
|
|
69
|
+
</TableCell>
|
|
70
|
+
) : null}
|
|
71
|
+
|
|
72
72
|
<TableCell>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
73
|
+
{!is_default && !["es", "en"].includes(lang) ? (
|
|
74
|
+
<ConfirmModal
|
|
75
|
+
icon="trash"
|
|
76
|
+
trigger={
|
|
77
|
+
<Icon
|
|
78
|
+
className="lang-manager-delete"
|
|
79
|
+
name="trash alternate outline"
|
|
80
|
+
color="red"
|
|
81
|
+
/>
|
|
82
|
+
}
|
|
83
|
+
header={formatMessage({
|
|
84
|
+
id: "i18n.messages.locale.delete.confirmation.header",
|
|
85
|
+
})}
|
|
86
|
+
content={formatMessage({
|
|
87
|
+
id: "i18n.messages.locale.delete.confirmation.content",
|
|
88
|
+
})}
|
|
89
|
+
onConfirm={() =>
|
|
90
|
+
handleChange({
|
|
91
|
+
id,
|
|
92
|
+
locale: { is_enabled: false, is_required: false },
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
/>
|
|
96
|
+
) : null}
|
|
91
97
|
</TableCell>
|
|
92
98
|
</TableRow>
|
|
93
99
|
);
|
|
94
100
|
};
|
|
95
101
|
|
|
96
102
|
LanguajeRow.propTypes = {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
name: PropTypes.string,
|
|
100
|
-
config: PropTypes.object,
|
|
103
|
+
locale: PropTypes.object,
|
|
104
|
+
anyDefault: PropTypes.bool,
|
|
101
105
|
mutate: PropTypes.func,
|
|
102
106
|
handleDimmer: PropTypes.func,
|
|
103
107
|
};
|
|
104
108
|
|
|
105
|
-
const Languages = () => {
|
|
106
|
-
const includeMessages = false;
|
|
107
|
-
const {
|
|
108
|
-
locales,
|
|
109
|
-
loading: loadingUseLocales,
|
|
110
|
-
mutate,
|
|
111
|
-
isValidating,
|
|
112
|
-
} = useLocales(includeMessages);
|
|
113
|
-
const langs = _.map("lang")(locales);
|
|
114
|
-
|
|
109
|
+
const Languages = ({ locales, mutate, isValidating }) => {
|
|
115
110
|
const { formatMessage } = useIntl();
|
|
116
|
-
const
|
|
117
|
-
const [newLocales, setNewLocales] = useState([]);
|
|
118
|
-
const { trigger } = useLocalesCreate();
|
|
111
|
+
const [newLocale, setNewLocales] = useState(null);
|
|
119
112
|
const [dimmerState, setDimmerState] = useState(false);
|
|
113
|
+
const { trigger } = useLocalesUpdate();
|
|
120
114
|
|
|
121
115
|
const handleDimmer = (isMutating) => {
|
|
122
116
|
setDimmerState(isMutating);
|
|
123
117
|
};
|
|
124
118
|
|
|
125
|
-
const
|
|
126
|
-
_.map((locale) => _.omit("messages")(locale)),
|
|
127
|
-
_.groupBy("lang"),
|
|
128
|
-
_.mapValues(_.first)
|
|
129
|
-
)(locales);
|
|
119
|
+
const anyDefault = !!_.find(({ is_default }) => is_default)(locales);
|
|
130
120
|
|
|
131
121
|
const options = _.flow(
|
|
132
|
-
_.filter(({
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
_.map(({
|
|
136
|
-
return { text: `${
|
|
122
|
+
_.filter(({ is_enabled }) => !is_enabled),
|
|
123
|
+
_.orderBy("lang", "asc"),
|
|
124
|
+
_.keyBy("lang"),
|
|
125
|
+
_.map(({ lang, name, local_name }) => {
|
|
126
|
+
return { text: `${name} ( ${local_name} )`, value: lang };
|
|
137
127
|
})
|
|
138
|
-
)(
|
|
128
|
+
)(locales);
|
|
139
129
|
|
|
140
130
|
const handleOnChange = ({ value }) => {
|
|
141
131
|
setNewLocales(value);
|
|
142
132
|
};
|
|
143
133
|
|
|
144
134
|
const handleSubmit = () => {
|
|
145
|
-
setNewLocales(
|
|
146
|
-
trigger({
|
|
135
|
+
setNewLocales(null);
|
|
136
|
+
trigger({
|
|
137
|
+
id: locales[newLocale].id,
|
|
138
|
+
locale: { is_enabled: true },
|
|
139
|
+
mutateData: mutate,
|
|
140
|
+
handleDimmer,
|
|
141
|
+
}).then(() => {
|
|
147
142
|
mutate();
|
|
148
143
|
});
|
|
149
144
|
};
|
|
@@ -162,12 +157,12 @@ const Languages = () => {
|
|
|
162
157
|
defaultMessage: "Select languaje",
|
|
163
158
|
})}
|
|
164
159
|
name="add-locales"
|
|
165
|
-
multiple={
|
|
160
|
+
multiple={false}
|
|
166
161
|
search={true}
|
|
167
162
|
selection={true}
|
|
168
163
|
options={options}
|
|
169
164
|
clearable={true}
|
|
170
|
-
value={
|
|
165
|
+
value={newLocale}
|
|
171
166
|
onChange={(_e, data) => {
|
|
172
167
|
handleOnChange(data);
|
|
173
168
|
}}
|
|
@@ -175,7 +170,7 @@ const Languages = () => {
|
|
|
175
170
|
<Button
|
|
176
171
|
type="submit"
|
|
177
172
|
className="lang-manager-button"
|
|
178
|
-
disabled={
|
|
173
|
+
disabled={!newLocale}
|
|
179
174
|
>
|
|
180
175
|
{formatMessage({
|
|
181
176
|
id: "i18n.messages.locale.add_lang",
|
|
@@ -196,31 +191,36 @@ const Languages = () => {
|
|
|
196
191
|
id: "i18n.messages.locale.required",
|
|
197
192
|
})}
|
|
198
193
|
</TableCell>
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
194
|
+
{!anyDefault ? (
|
|
195
|
+
<TableCell textAlign="center">
|
|
196
|
+
{formatMessage({
|
|
197
|
+
id: "i18n.messages.locale.default",
|
|
198
|
+
})}
|
|
199
|
+
</TableCell>
|
|
200
|
+
) : null}
|
|
204
201
|
<TableCell></TableCell>
|
|
205
202
|
</TableRow>
|
|
206
203
|
</TableHeader>
|
|
207
204
|
<TableBody>
|
|
208
205
|
{_.flow(
|
|
209
|
-
_.filter(
|
|
210
|
-
_.
|
|
206
|
+
_.filter("is_enabled"),
|
|
207
|
+
_.orderBy(
|
|
208
|
+
["is_default", "is_required", "lang"],
|
|
209
|
+
["desc", "desc", "asc"]
|
|
210
|
+
),
|
|
211
|
+
_.map((locale) => {
|
|
211
212
|
return (
|
|
212
213
|
<LanguajeRow
|
|
213
|
-
key={
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
config={langsConfig[code]}
|
|
214
|
+
key={locale.lang}
|
|
215
|
+
locale={{ ...locale, trigger }}
|
|
216
|
+
locales={locales}
|
|
217
|
+
anyDefault={anyDefault}
|
|
218
218
|
mutate={mutate}
|
|
219
219
|
handleDimmer={handleDimmer}
|
|
220
220
|
/>
|
|
221
221
|
);
|
|
222
222
|
})
|
|
223
|
-
)(
|
|
223
|
+
)(locales)}
|
|
224
224
|
</TableBody>
|
|
225
225
|
</Table>
|
|
226
226
|
</Dimmer.Dimmable>
|
|
@@ -228,4 +228,10 @@ const Languages = () => {
|
|
|
228
228
|
);
|
|
229
229
|
};
|
|
230
230
|
|
|
231
|
+
Languages.propTypes = {
|
|
232
|
+
locales: PropTypes.array,
|
|
233
|
+
mutate: PropTypes.func,
|
|
234
|
+
isValidating: PropTypes.bool,
|
|
235
|
+
};
|
|
236
|
+
|
|
231
237
|
export default Languages;
|
|
@@ -9,7 +9,7 @@ import { useLocales } from "@truedat/core/hooks";
|
|
|
9
9
|
|
|
10
10
|
export const LangForm = ({
|
|
11
11
|
control,
|
|
12
|
-
|
|
12
|
+
locale: { id, lang, name, local_name },
|
|
13
13
|
errors,
|
|
14
14
|
formatMessage,
|
|
15
15
|
}) => {
|
|
@@ -17,7 +17,10 @@ export const LangForm = ({
|
|
|
17
17
|
<Segment>
|
|
18
18
|
<Header
|
|
19
19
|
as="h4"
|
|
20
|
-
content={formatMessage({
|
|
20
|
+
content={formatMessage({
|
|
21
|
+
id: `i18n.messages.locale.${lang}`,
|
|
22
|
+
defaultMessage: `${name} ( ${local_name} )`,
|
|
23
|
+
})}
|
|
21
24
|
/>
|
|
22
25
|
<Controller
|
|
23
26
|
control={control}
|
|
@@ -63,6 +66,13 @@ export const LangForm = ({
|
|
|
63
66
|
);
|
|
64
67
|
};
|
|
65
68
|
|
|
69
|
+
LangForm.propTypes = {
|
|
70
|
+
control: PropTypes.object,
|
|
71
|
+
locale: PropTypes.object,
|
|
72
|
+
errors: PropTypes.object,
|
|
73
|
+
formatMessage: PropTypes.func,
|
|
74
|
+
};
|
|
75
|
+
|
|
66
76
|
export const MessageForm = ({ onSubmit, isSubmitting }) => {
|
|
67
77
|
const { locales, loading } = useLocales();
|
|
68
78
|
const { formatMessage } = useIntl();
|
|
@@ -104,17 +114,22 @@ export const MessageForm = ({ onSubmit, isSubmitting }) => {
|
|
|
104
114
|
)}
|
|
105
115
|
/>
|
|
106
116
|
|
|
107
|
-
{
|
|
108
|
-
.filter(
|
|
109
|
-
.
|
|
117
|
+
{_.flow(
|
|
118
|
+
_.filter("is_enabled"),
|
|
119
|
+
_.orderBy(
|
|
120
|
+
["is_default", "is_required", "lang"],
|
|
121
|
+
["desc", "desc", "asc"]
|
|
122
|
+
),
|
|
123
|
+
_.map((locale) => (
|
|
110
124
|
<LangForm
|
|
111
|
-
key={
|
|
125
|
+
key={locale.lang}
|
|
112
126
|
control={control}
|
|
113
|
-
|
|
127
|
+
locale={locale}
|
|
114
128
|
errors={errors}
|
|
115
129
|
formatMessage={formatMessage}
|
|
116
130
|
/>
|
|
117
|
-
))
|
|
131
|
+
))
|
|
132
|
+
)(locales)}
|
|
118
133
|
|
|
119
134
|
<div className="actions">
|
|
120
135
|
<Button
|
|
@@ -135,7 +150,6 @@ export const MessageForm = ({ onSubmit, isSubmitting }) => {
|
|
|
135
150
|
};
|
|
136
151
|
|
|
137
152
|
MessageForm.propTypes = {
|
|
138
|
-
message: PropTypes.object,
|
|
139
153
|
onSubmit: PropTypes.func,
|
|
140
154
|
isSubmitting: PropTypes.bool,
|
|
141
155
|
};
|
|
@@ -23,11 +23,12 @@ import Languages from "./Languages";
|
|
|
23
23
|
|
|
24
24
|
const ITEMS_PER_PAGE = 30;
|
|
25
25
|
|
|
26
|
-
export function MessagesContent({ locales, loading }) {
|
|
27
|
-
const langs = _.map("lang")(locales);
|
|
28
|
-
|
|
26
|
+
export function MessagesContent({ locales, loading, mutate, isValidating }) {
|
|
29
27
|
const [selectedLang, setSelectedLang] = useState(
|
|
30
|
-
_.
|
|
28
|
+
_.flow(
|
|
29
|
+
_.find(({ is_default }) => is_default),
|
|
30
|
+
_.pathOr("en", "lang")
|
|
31
|
+
)(locales)
|
|
31
32
|
);
|
|
32
33
|
|
|
33
34
|
const [selectedManageView, setSelectedManageView] = useState(false);
|
|
@@ -43,6 +44,7 @@ export function MessagesContent({ locales, loading }) {
|
|
|
43
44
|
const messages = _.flow(
|
|
44
45
|
_.find({ lang: selectedLang }),
|
|
45
46
|
_.prop("messages"),
|
|
47
|
+
_.orderBy("message_id", "asc"),
|
|
46
48
|
_.filter(({ message_id, definition, description }) => {
|
|
47
49
|
const deburrFilter = lowerDeburrTrim(filter);
|
|
48
50
|
return (
|
|
@@ -70,20 +72,28 @@ export function MessagesContent({ locales, loading }) {
|
|
|
70
72
|
>
|
|
71
73
|
<FormattedMessage id="i18n.messages.locale.manage" />
|
|
72
74
|
</Menu.Item>
|
|
73
|
-
{
|
|
74
|
-
.filter(
|
|
75
|
-
.
|
|
75
|
+
{_.flow(
|
|
76
|
+
_.filter("is_enabled"),
|
|
77
|
+
_.orderBy(
|
|
78
|
+
["is_default", "is_required", "lang"],
|
|
79
|
+
["desc", "desc", "asc"]
|
|
80
|
+
),
|
|
81
|
+
_.map(({ lang, name, local_name }) => (
|
|
76
82
|
<Menu.Item
|
|
77
|
-
key={
|
|
83
|
+
key={lang}
|
|
78
84
|
active={lang === selectedLang && !selectedManageView}
|
|
79
85
|
onClick={() => {
|
|
80
86
|
setSelectedLang(lang);
|
|
81
87
|
setSelectedManageView(false);
|
|
82
88
|
}}
|
|
83
89
|
>
|
|
84
|
-
<FormattedMessage
|
|
90
|
+
<FormattedMessage
|
|
91
|
+
id={`i18n.messages.locale.${lang}`}
|
|
92
|
+
defaultMessage={`${name} ( ${local_name} )`}
|
|
93
|
+
/>
|
|
85
94
|
</Menu.Item>
|
|
86
|
-
))
|
|
95
|
+
))
|
|
96
|
+
)(locales)}
|
|
87
97
|
</Menu>
|
|
88
98
|
<Divider hidden />
|
|
89
99
|
{!selectedManageView ? (
|
|
@@ -107,7 +117,11 @@ export function MessagesContent({ locales, loading }) {
|
|
|
107
117
|
/>
|
|
108
118
|
</>
|
|
109
119
|
) : (
|
|
110
|
-
<Languages
|
|
120
|
+
<Languages
|
|
121
|
+
locales={_.keyBy("lang")(locales)}
|
|
122
|
+
mutate={mutate}
|
|
123
|
+
isValidating={isValidating}
|
|
124
|
+
/>
|
|
111
125
|
)}
|
|
112
126
|
</>
|
|
113
127
|
);
|
|
@@ -116,12 +130,14 @@ export function MessagesContent({ locales, loading }) {
|
|
|
116
130
|
MessagesContent.propTypes = {
|
|
117
131
|
locales: PropTypes.array,
|
|
118
132
|
loading: PropTypes.bool,
|
|
133
|
+
mutate: PropTypes.func,
|
|
134
|
+
isValidating: PropTypes.bool,
|
|
119
135
|
};
|
|
120
136
|
|
|
121
137
|
export default function Messages() {
|
|
122
138
|
const { formatMessage } = useIntl();
|
|
123
139
|
|
|
124
|
-
const { locales, loading } = useLocales();
|
|
140
|
+
const { locales, loading, mutate, isValidating } = useLocales();
|
|
125
141
|
|
|
126
142
|
return (
|
|
127
143
|
<Segment>
|
|
@@ -149,7 +165,12 @@ export default function Messages() {
|
|
|
149
165
|
to={I18N_MESSAGES_NEW}
|
|
150
166
|
/>
|
|
151
167
|
{!loading ? (
|
|
152
|
-
<MessagesContent
|
|
168
|
+
<MessagesContent
|
|
169
|
+
locales={locales}
|
|
170
|
+
loading={loading}
|
|
171
|
+
mutate={mutate}
|
|
172
|
+
isValidating={isValidating}
|
|
173
|
+
/>
|
|
153
174
|
) : null}
|
|
154
175
|
</Segment>
|
|
155
176
|
</Segment>
|
|
@@ -23,50 +23,6 @@ exports[`<MessageForm /> matches the latest snapshot 1`] = `
|
|
|
23
23
|
/>
|
|
24
24
|
</div>
|
|
25
25
|
</div>
|
|
26
|
-
<div
|
|
27
|
-
class="ui segment"
|
|
28
|
-
>
|
|
29
|
-
<h4
|
|
30
|
-
class="ui header"
|
|
31
|
-
>
|
|
32
|
-
Spanish
|
|
33
|
-
</h4>
|
|
34
|
-
<div
|
|
35
|
-
class="required field"
|
|
36
|
-
>
|
|
37
|
-
<label>
|
|
38
|
-
Definition
|
|
39
|
-
</label>
|
|
40
|
-
<div
|
|
41
|
-
class="ui input"
|
|
42
|
-
>
|
|
43
|
-
<input
|
|
44
|
-
autocomplete="off"
|
|
45
|
-
placeholder="Definition"
|
|
46
|
-
required=""
|
|
47
|
-
type="text"
|
|
48
|
-
value=""
|
|
49
|
-
/>
|
|
50
|
-
</div>
|
|
51
|
-
</div>
|
|
52
|
-
<div
|
|
53
|
-
class="field"
|
|
54
|
-
>
|
|
55
|
-
<label>
|
|
56
|
-
Description
|
|
57
|
-
</label>
|
|
58
|
-
<div
|
|
59
|
-
class="ui input"
|
|
60
|
-
>
|
|
61
|
-
<input
|
|
62
|
-
autocomplete="off"
|
|
63
|
-
placeholder="Description"
|
|
64
|
-
type="text"
|
|
65
|
-
value=""
|
|
66
|
-
/>
|
|
67
|
-
</div>
|
|
68
|
-
</div>
|
|
69
|
-
</div>
|
|
70
26
|
<div
|
|
71
27
|
class="actions"
|
|
72
28
|
>
|
|
@@ -60,11 +60,6 @@ exports[`<Messages /> matches the latest snapshot 1`] = `
|
|
|
60
60
|
>
|
|
61
61
|
manage
|
|
62
62
|
</a>
|
|
63
|
-
<a
|
|
64
|
-
class="active item"
|
|
65
|
-
>
|
|
66
|
-
Spanish
|
|
67
|
-
</a>
|
|
68
63
|
</div>
|
|
69
64
|
<div
|
|
70
65
|
class="ui hidden divider"
|
|
@@ -82,116 +77,19 @@ exports[`<Messages /> matches the latest snapshot 1`] = `
|
|
|
82
77
|
class="search link icon"
|
|
83
78
|
/>
|
|
84
79
|
</div>
|
|
85
|
-
<
|
|
86
|
-
class="ui
|
|
80
|
+
<h4
|
|
81
|
+
class="ui header"
|
|
87
82
|
>
|
|
88
|
-
<
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
<th
|
|
95
|
-
class=""
|
|
96
|
-
>
|
|
97
|
-
Message ID
|
|
98
|
-
</th>
|
|
99
|
-
<th
|
|
100
|
-
class=""
|
|
101
|
-
>
|
|
102
|
-
Definition
|
|
103
|
-
</th>
|
|
104
|
-
<th
|
|
105
|
-
class=""
|
|
106
|
-
>
|
|
107
|
-
Description
|
|
108
|
-
</th>
|
|
109
|
-
</tr>
|
|
110
|
-
</thead>
|
|
111
|
-
<tbody
|
|
112
|
-
class=""
|
|
113
|
-
>
|
|
114
|
-
<tr
|
|
115
|
-
class=""
|
|
116
|
-
>
|
|
117
|
-
<td
|
|
118
|
-
class="six wide"
|
|
119
|
-
>
|
|
120
|
-
message_id
|
|
121
|
-
</td>
|
|
122
|
-
<td
|
|
123
|
-
class="five wide cursor-pointer"
|
|
124
|
-
>
|
|
125
|
-
definition
|
|
126
|
-
</td>
|
|
127
|
-
<td
|
|
128
|
-
class="five wide cursor-pointer"
|
|
129
|
-
>
|
|
130
|
-
description
|
|
131
|
-
</td>
|
|
132
|
-
</tr>
|
|
133
|
-
</tbody>
|
|
134
|
-
</table>
|
|
135
|
-
<div
|
|
136
|
-
aria-label="Pagination Navigation"
|
|
137
|
-
class="ui pagination menu"
|
|
138
|
-
role="navigation"
|
|
139
|
-
>
|
|
140
|
-
<a
|
|
141
|
-
aria-current="false"
|
|
142
|
-
aria-disabled="true"
|
|
143
|
-
aria-label="First item"
|
|
144
|
-
class="disabled item"
|
|
145
|
-
tabindex="-1"
|
|
146
|
-
type="firstItem"
|
|
147
|
-
value="1"
|
|
148
|
-
>
|
|
149
|
-
«
|
|
150
|
-
</a>
|
|
151
|
-
<a
|
|
152
|
-
aria-current="false"
|
|
153
|
-
aria-disabled="true"
|
|
154
|
-
aria-label="Previous item"
|
|
155
|
-
class="disabled item"
|
|
156
|
-
tabindex="-1"
|
|
157
|
-
type="prevItem"
|
|
158
|
-
value="1"
|
|
159
|
-
>
|
|
160
|
-
⟨
|
|
161
|
-
</a>
|
|
162
|
-
<a
|
|
163
|
-
aria-current="true"
|
|
164
|
-
aria-disabled="true"
|
|
165
|
-
class="active disabled item"
|
|
166
|
-
tabindex="-1"
|
|
167
|
-
type="pageItem"
|
|
168
|
-
value="1"
|
|
169
|
-
>
|
|
170
|
-
1
|
|
171
|
-
</a>
|
|
172
|
-
<a
|
|
173
|
-
aria-current="false"
|
|
174
|
-
aria-disabled="true"
|
|
175
|
-
aria-label="Next item"
|
|
176
|
-
class="disabled item"
|
|
177
|
-
tabindex="-1"
|
|
178
|
-
type="nextItem"
|
|
179
|
-
value="1"
|
|
180
|
-
>
|
|
181
|
-
⟩
|
|
182
|
-
</a>
|
|
183
|
-
<a
|
|
184
|
-
aria-current="false"
|
|
185
|
-
aria-disabled="true"
|
|
186
|
-
aria-label="Last item"
|
|
187
|
-
class="disabled item"
|
|
188
|
-
tabindex="-1"
|
|
189
|
-
type="lastItem"
|
|
190
|
-
value="1"
|
|
83
|
+
<i
|
|
84
|
+
aria-hidden="true"
|
|
85
|
+
class="search icon"
|
|
86
|
+
/>
|
|
87
|
+
<div
|
|
88
|
+
class="content"
|
|
191
89
|
>
|
|
192
|
-
|
|
193
|
-
</
|
|
194
|
-
</
|
|
90
|
+
No messages
|
|
91
|
+
</div>
|
|
92
|
+
</h4>
|
|
195
93
|
</div>
|
|
196
94
|
</div>
|
|
197
95
|
</div>
|
|
@@ -58,50 +58,6 @@ exports[`<NewMessage /> matches the latest snapshot 1`] = `
|
|
|
58
58
|
/>
|
|
59
59
|
</div>
|
|
60
60
|
</div>
|
|
61
|
-
<div
|
|
62
|
-
class="ui segment"
|
|
63
|
-
>
|
|
64
|
-
<h4
|
|
65
|
-
class="ui header"
|
|
66
|
-
>
|
|
67
|
-
Spanish
|
|
68
|
-
</h4>
|
|
69
|
-
<div
|
|
70
|
-
class="required field"
|
|
71
|
-
>
|
|
72
|
-
<label>
|
|
73
|
-
Definition
|
|
74
|
-
</label>
|
|
75
|
-
<div
|
|
76
|
-
class="ui input"
|
|
77
|
-
>
|
|
78
|
-
<input
|
|
79
|
-
autocomplete="off"
|
|
80
|
-
placeholder="Definition"
|
|
81
|
-
required=""
|
|
82
|
-
type="text"
|
|
83
|
-
value=""
|
|
84
|
-
/>
|
|
85
|
-
</div>
|
|
86
|
-
</div>
|
|
87
|
-
<div
|
|
88
|
-
class="field"
|
|
89
|
-
>
|
|
90
|
-
<label>
|
|
91
|
-
Description
|
|
92
|
-
</label>
|
|
93
|
-
<div
|
|
94
|
-
class="ui input"
|
|
95
|
-
>
|
|
96
|
-
<input
|
|
97
|
-
autocomplete="off"
|
|
98
|
-
placeholder="Description"
|
|
99
|
-
type="text"
|
|
100
|
-
value=""
|
|
101
|
-
/>
|
|
102
|
-
</div>
|
|
103
|
-
</div>
|
|
104
|
-
</div>
|
|
105
61
|
<div
|
|
106
62
|
class="actions"
|
|
107
63
|
>
|
package/src/messages/en.js
CHANGED
|
@@ -112,6 +112,7 @@ export default {
|
|
|
112
112
|
"sidemenu.concepts": "Glossary",
|
|
113
113
|
"sidemenu.configurations": "Configuration",
|
|
114
114
|
"sidemenu.dashboard": "Dashboard",
|
|
115
|
+
"sidemenu.elasticIndex": "Elastic Index",
|
|
115
116
|
"sidemenu.executions": "My Executions",
|
|
116
117
|
"sidemenu.glossary": "Glossary",
|
|
117
118
|
"sidemenu.grant_request_approvals": "Approve Grant Requests",
|
package/src/messages/es.js
CHANGED
|
@@ -116,6 +116,7 @@ export default {
|
|
|
116
116
|
"sidemenu.concepts": "Glosario",
|
|
117
117
|
"sidemenu.configurations": "Configuración",
|
|
118
118
|
"sidemenu.dashboard": "Dashboard",
|
|
119
|
+
"sidemenu.elasticIndex": "Elastic Index",
|
|
119
120
|
"sidemenu.executions": "Mis ejecuciones",
|
|
120
121
|
"sidemenu.glossary": "Glosario",
|
|
121
122
|
"sidemenu.grant_request_approvals": "Aprobar Peticiones de Accesos",
|
package/src/routes.js
CHANGED
|
@@ -53,6 +53,7 @@ export const DOMAIN_MEMBERS = "/domains/:id/members";
|
|
|
53
53
|
export const DOMAIN_MEMBERS_NEW = "/domains/:id/members/new";
|
|
54
54
|
export const DOMAIN_NEW = "/domains/:id/new";
|
|
55
55
|
export const DOMAIN_STRUCTURES = "/domains/:id/structures";
|
|
56
|
+
export const ELASTICINDEXES = "/search/elasticIndexes";
|
|
56
57
|
export const EXECUTION_GROUP = "/executionGroups/:id";
|
|
57
58
|
export const EXECUTION_GROUPS = "/executionGroups";
|
|
58
59
|
export const FUNCTIONS = "/functions";
|
|
@@ -290,6 +291,7 @@ const routes = {
|
|
|
290
291
|
DOMAIN_MEMBERS_NEW,
|
|
291
292
|
DOMAIN_NEW,
|
|
292
293
|
DOMAIN_STRUCTURES,
|
|
294
|
+
ELASTICINDEXES,
|
|
293
295
|
EXECUTION_GROUP,
|
|
294
296
|
EXECUTION_GROUPS,
|
|
295
297
|
GRANT,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
|
-
import { API_ALL_LOCALES } from "../api";
|
|
3
|
-
import { apiJson } from "../services/api";
|
|
4
|
-
|
|
5
|
-
export const useAllLocales = () => {
|
|
6
|
-
const { data, loading, error, mutate } = useSWR(API_ALL_LOCALES, apiJson);
|
|
7
|
-
const all_locales = data?.data?.data;
|
|
8
|
-
return { all_locales, error, loading, mutate };
|
|
9
|
-
};
|