@truedat/core 7.8.1 → 7.8.3
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/core",
|
|
3
|
-
"version": "7.8.
|
|
3
|
+
"version": "7.8.3",
|
|
4
4
|
"description": "Truedat Web Core",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@testing-library/jest-dom": "^6.6.3",
|
|
49
49
|
"@testing-library/react": "^16.3.0",
|
|
50
50
|
"@testing-library/user-event": "^14.6.1",
|
|
51
|
-
"@truedat/test": "7.
|
|
51
|
+
"@truedat/test": "7.8.3",
|
|
52
52
|
"identity-obj-proxy": "^3.0.0",
|
|
53
53
|
"jest": "^29.7.0",
|
|
54
54
|
"redux-saga-test-plan": "^4.0.6"
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"slate-react": "^0.22.10",
|
|
86
86
|
"swr": "^2.3.3"
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "b1f7af3f2c1b6969817a27f1fa44d31b264f4a55"
|
|
89
89
|
}
|
package/src/components/Alert.js
CHANGED
|
@@ -38,6 +38,9 @@ const formatMessages = ({ id, defaultMessage, fields = {} }, formatMessage) => {
|
|
|
38
38
|
return formatMessage({ id, defaultMessage: defaultMessage || id }, fields);
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Ideal to use AlertMessage instead as we are moving away from redux to use context.
|
|
43
|
+
*/
|
|
41
44
|
export const Alert = ({
|
|
42
45
|
message: {
|
|
43
46
|
error,
|
|
@@ -70,9 +73,9 @@ export const Alert = ({
|
|
|
70
73
|
const message_content =
|
|
71
74
|
content && !existingList(errors) && !existingList(formattedMessages)
|
|
72
75
|
? formatMessage(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
{ id: content, defaultMessage: content },
|
|
77
|
+
{ text, ...fields }
|
|
78
|
+
)
|
|
76
79
|
: undefined;
|
|
77
80
|
return content || header ? (
|
|
78
81
|
<>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import { Message } from "semantic-ui-react";
|
|
3
|
+
import { useIntl } from "react-intl";
|
|
4
|
+
import { useWebContext } from "../webContext";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This component is meant to replace ../Alert.js as we are moving away from redux.
|
|
8
|
+
*/
|
|
9
|
+
export const AlertMessage = () => {
|
|
10
|
+
const { formatMessage } = useIntl();
|
|
11
|
+
const { alertMessage, setAlertMessage } = useWebContext();
|
|
12
|
+
|
|
13
|
+
if (_.isEmpty(alertMessage)) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const { error, header, icon, color, content, anchor } = alertMessage;
|
|
18
|
+
|
|
19
|
+
return <Message
|
|
20
|
+
error={error}
|
|
21
|
+
header={header && formatMessage({ id: header, defaultMessage: header })}
|
|
22
|
+
icon={icon}
|
|
23
|
+
color={color}
|
|
24
|
+
content={
|
|
25
|
+
<>
|
|
26
|
+
{content && formatMessage({ id: content, defaultMessage: content })}
|
|
27
|
+
{anchor && <a href={anchor.reference}>{formatMessage({ id: anchor.label, defaultMessage: anchor.label })}</a>}
|
|
28
|
+
</>
|
|
29
|
+
}
|
|
30
|
+
visible
|
|
31
|
+
onDismiss={() => setAlertMessage({})}
|
|
32
|
+
/>;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default AlertMessage;
|
package/src/components/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import ActiveRoute from "./ActiveRoute";
|
|
2
2
|
import AdminMenu from "./AdminMenu";
|
|
3
3
|
import Alert from "./Alert";
|
|
4
|
+
import AlertMessage from "./AlertMessage";
|
|
4
5
|
import Authorized from "./Authorized";
|
|
5
6
|
import AvailableFilters from "./AvailableFilters";
|
|
6
7
|
import CardGroupsAccordion from "./CardGroupsAccordion";
|
|
@@ -61,6 +62,7 @@ export {
|
|
|
61
62
|
ActiveRoute,
|
|
62
63
|
AdminMenu,
|
|
63
64
|
Alert,
|
|
65
|
+
AlertMessage,
|
|
64
66
|
Authorized,
|
|
65
67
|
AvailableFilters,
|
|
66
68
|
CardGroupsAccordion,
|
package/src/webContext.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { use, createContext } from "react";
|
|
1
|
+
import { use, createContext, useState } from "react";
|
|
2
2
|
|
|
3
3
|
const defaultContext = { disable_td_ai: false };
|
|
4
4
|
export const WebContext = createContext(defaultContext);
|
|
5
5
|
export const WebContextProvider = ({ children, value = {} }) => {
|
|
6
|
+
const [alertMessage, setAlertMessage] = useState({});
|
|
7
|
+
|
|
6
8
|
return (
|
|
7
|
-
<WebContext.Provider value={{ ...defaultContext, ...value }}>
|
|
9
|
+
<WebContext.Provider value={{ ...defaultContext, ...value, alertMessage, setAlertMessage }}>
|
|
8
10
|
{children}
|
|
9
11
|
</WebContext.Provider>
|
|
10
12
|
);
|