@truedat/core 4.59.6 → 4.59.8

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.59.7] 2023-01-13
4
+
5
+ - [TD-1968] Fix some issues from I18n messages management view
6
+
3
7
  ## [4.59.0] 2023-01-09
4
8
 
5
9
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/core",
3
- "version": "4.59.6",
3
+ "version": "4.59.8",
4
4
  "description": "Truedat Web Core",
5
5
  "sideEffects": false,
6
6
  "jsnext:main": "src/index.js",
@@ -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": "b50a4a3640b53ebf1289b7d46f311c643c508c23"
120
+ "gitHead": "679895d762c466ab983d13bbdad90a58261da3b2"
121
121
  }
@@ -1,7 +1,13 @@
1
1
  import { compile } from "path-to-regexp";
2
- import useSWRImmutable from "swr/immutable";
2
+ import { mutate } from "swr";
3
+ import useSWR from "swr";
3
4
  import useSWRMutations from "swr/mutation";
4
- import { API_LOCALE_MESSAGES, API_MESSAGE, API_MESSAGES } from "../api";
5
+ import {
6
+ API_LOCALE_MESSAGES,
7
+ API_MESSAGE,
8
+ API_MESSAGES,
9
+ API_LOCALES,
10
+ } from "../api";
5
11
  import { apiJson, apiJsonPatch, apiJsonPost } from "../services/api";
6
12
 
7
13
  const toApiLocaleMessagesPath = compile(API_LOCALE_MESSAGES);
@@ -9,14 +15,16 @@ const toApiMessagePath = compile(API_MESSAGE);
9
15
 
10
16
  export const useMessages = (lang) => {
11
17
  const url = toApiLocaleMessagesPath({ lang });
12
- const { data, error } = useSWRImmutable(url, apiJson);
18
+ const { data, error } = useSWR(url, apiJson);
13
19
  const messages = data?.data;
14
20
  return { messages, error, loading: !error && !data };
15
21
  };
16
22
 
17
23
  export const useMessagePatch = (id) => {
18
24
  const url = toApiMessagePath({ id });
19
- return useSWRMutations(url, (url, { arg }) => apiJsonPatch(url, arg));
25
+ return useSWRMutations(url, (url, { arg }) =>
26
+ apiJsonPatch(url, arg).then(() => mutate(API_LOCALES))
27
+ );
20
28
  };
21
29
 
22
30
  export const useMessagePost = () => {
@@ -9,12 +9,13 @@ export default function EditableCell({
9
9
  value: propValue,
10
10
  placeholder,
11
11
  onChange,
12
+ clearable = false,
12
13
  }) {
13
14
  const [editionMode, setEditMode] = useState(false);
14
15
  const [value, setValue] = useState(propValue || "");
15
16
 
16
17
  const onBlur = () => {
17
- if (_.isEmpty(value)) setValue(propValue);
18
+ if (!clearable && _.isEmpty(value)) setValue(propValue);
18
19
  else if (value != propValue) onChange(value);
19
20
  setEditMode(false);
20
21
  };
@@ -50,4 +51,5 @@ EditableCell.propTypes = {
50
51
  value: PropTypes.string,
51
52
  placeholder: PropTypes.string,
52
53
  onChange: PropTypes.func,
54
+ clearable: PropTypes.bool,
53
55
  };
@@ -23,6 +23,7 @@ export const MessageRow = ({ message, formatMessage }) => {
23
23
  })}
24
24
  />
25
25
  <EditableCell
26
+ clearable
26
27
  value={message?.description}
27
28
  onChange={doPatch("description")}
28
29
  placeholder={formatMessage({