@reltio/components 1.4.1169 → 1.4.1170
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/cjs/hooks/useAPI/API.js +4 -0
- package/cjs/hooks/useAPI/helpers.d.ts +1 -0
- package/cjs/hooks/useAPI/helpers.js +10 -1
- package/cjs/hooks/useAPI/useAPI.d.ts +0 -2
- package/cjs/hooks/useAPI/useAPI.js +15 -18
- package/cjs/hooks/useCustomScripts.js +9 -0
- package/esm/hooks/useAPI/API.js +4 -0
- package/esm/hooks/useAPI/helpers.d.ts +1 -0
- package/esm/hooks/useAPI/helpers.js +8 -0
- package/esm/hooks/useAPI/useAPI.d.ts +0 -2
- package/esm/hooks/useAPI/useAPI.js +17 -20
- package/esm/hooks/useCustomScripts.js +10 -1
- package/package.json +3 -3
package/cjs/hooks/useAPI/API.js
CHANGED
|
@@ -195,6 +195,10 @@ var processRequest = function (_a) {
|
|
|
195
195
|
window.open(paramObject.params.url, '_blank');
|
|
196
196
|
break;
|
|
197
197
|
}
|
|
198
|
+
case mdm_sdk_1.RequestAction.RELOAD_PAGE: {
|
|
199
|
+
location.reload();
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
198
202
|
}
|
|
199
203
|
};
|
|
200
204
|
exports.processRequest = processRequest;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getWorkerURL = void 0;
|
|
3
|
+
exports.getFullApiPath = exports.getWorkerURL = void 0;
|
|
4
4
|
var getWorkerURL = function (uiPath, tenant) {
|
|
5
5
|
if (uiPath === null || uiPath === void 0 ? void 0 : uiPath.includes('nui')) {
|
|
6
6
|
return uiPath.replace(tenant + "/", '') + "worker_api.js";
|
|
@@ -10,3 +10,12 @@ var getWorkerURL = function (uiPath, tenant) {
|
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
12
|
exports.getWorkerURL = getWorkerURL;
|
|
13
|
+
var getFullApiPath = function (apiPath) {
|
|
14
|
+
if (apiPath === null || apiPath === void 0 ? void 0 : apiPath.includes('nui')) {
|
|
15
|
+
return "" + window.location.origin + apiPath;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return apiPath;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
exports.getFullApiPath = getFullApiPath;
|
|
@@ -46,7 +46,7 @@ var useAPI = function (config) {
|
|
|
46
46
|
var _c = react_1.useState(true), visible = _c[0], setVisible = _c[1];
|
|
47
47
|
var _d = react_1.useState(null), tooltip = _d[0], setTooltip = _d[1];
|
|
48
48
|
var _e = react_1.useState(null), customStyles = _e[0], setCustomStyles = _e[1];
|
|
49
|
-
var
|
|
49
|
+
var showSnackbarMessage = react_1.useContext(contexts_1.SnackbarContext);
|
|
50
50
|
var dispatch = react_redux_1.useDispatch();
|
|
51
51
|
var metadata = react_redux_1.useSelector(mdm_module_1.default.selectors.getMetadata) || {};
|
|
52
52
|
var entity = react_redux_1.useSelector(mdm_module_1.default.selectors.getEntity) || {};
|
|
@@ -60,7 +60,7 @@ var useAPI = function (config) {
|
|
|
60
60
|
var environment = react_redux_1.useSelector(mdm_module_1.default.selectors.getWorkflowEnvironmentUrl);
|
|
61
61
|
var qxApi = react_1.useContext(contexts_1.SandboxAPIContext);
|
|
62
62
|
var workflowCheckPermission = workflow_1.useWorkflowCheckPermission();
|
|
63
|
-
var
|
|
63
|
+
var _f = react_redux_1.useSelector(mdm_module_1.default.selectors.getSearchProviderData) || {}, typeSearch = _f.type, search = _f.data;
|
|
64
64
|
var openSearch = function (search) { return dispatch(mdm_module_1.ui.actions.openSearch(search)); };
|
|
65
65
|
var workerRef = react_1.useRef();
|
|
66
66
|
var process = function (_a) {
|
|
@@ -108,10 +108,17 @@ var useAPI = function (config) {
|
|
|
108
108
|
setListenersToReset(handlersToReset_1);
|
|
109
109
|
setHtml(docBlock);
|
|
110
110
|
};
|
|
111
|
-
if (task.action === mdm_sdk_1.CustomAction.SET_HTML && innerText !== task.params.html) {
|
|
112
|
-
resetHtml(task.params.html);
|
|
113
|
-
}
|
|
114
111
|
switch (task.action) {
|
|
112
|
+
case mdm_sdk_1.CustomAction.SET_HTML: {
|
|
113
|
+
if (task.params.id) {
|
|
114
|
+
var elem = document.getElementById(task.params.id);
|
|
115
|
+
elem.innerHTML = task.params.html;
|
|
116
|
+
}
|
|
117
|
+
else if (innerText !== task.params.html) {
|
|
118
|
+
resetHtml(task.params.html);
|
|
119
|
+
}
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
115
122
|
case mdm_sdk_1.CustomAction.LOG: {
|
|
116
123
|
console.log(task.params); //eslint-disable-line no-console
|
|
117
124
|
break;
|
|
@@ -153,14 +160,12 @@ var useAPI = function (config) {
|
|
|
153
160
|
break;
|
|
154
161
|
}
|
|
155
162
|
case mdm_sdk_1.CustomAction.MESSAGE: {
|
|
156
|
-
|
|
163
|
+
showSnackbarMessage(task.params);
|
|
157
164
|
break;
|
|
158
165
|
}
|
|
159
166
|
case mdm_sdk_1.CustomAction.REQUEST: {
|
|
160
167
|
API_1.processRequest(__assign({ name: task.params.name, paramObject: task, permissions: config.action.permissions, worker: worker,
|
|
161
|
-
metadata: metadata, config: config, user: user,
|
|
162
|
-
apiPath: apiPath,
|
|
163
|
-
tenant: tenant,
|
|
168
|
+
metadata: metadata, config: config, user: user, apiPath: helpers_1.getFullApiPath(apiPath), tenant: tenant,
|
|
164
169
|
workflowPath: workflowPath,
|
|
165
170
|
entity: entity,
|
|
166
171
|
entityUri: entityUri,
|
|
@@ -190,14 +195,6 @@ var useAPI = function (config) {
|
|
|
190
195
|
data: null
|
|
191
196
|
});
|
|
192
197
|
}, [config]);
|
|
193
|
-
return {
|
|
194
|
-
html: html,
|
|
195
|
-
visible: visible,
|
|
196
|
-
tooltip: tooltip,
|
|
197
|
-
customStyles: customStyles,
|
|
198
|
-
message: message,
|
|
199
|
-
onClosePopup: function () { return setMessage(''); },
|
|
200
|
-
onClick: onClick
|
|
201
|
-
};
|
|
198
|
+
return { html: html, visible: visible, tooltip: tooltip, customStyles: customStyles, onClick: onClick };
|
|
202
199
|
};
|
|
203
200
|
exports.useAPI = useAPI;
|
|
@@ -77,6 +77,7 @@ var useCustomScripts = function (config, _a) {
|
|
|
77
77
|
}
|
|
78
78
|
return acc;
|
|
79
79
|
}, []);
|
|
80
|
+
var showSnackbarMessage = react_1.useContext(contexts_1.SnackbarContext);
|
|
80
81
|
var dispatch = react_redux_1.useDispatch();
|
|
81
82
|
var metadata = react_redux_1.useSelector(mdm_module_1.default.selectors.getMetadata) || {};
|
|
82
83
|
var entity = react_redux_1.useSelector(mdm_module_1.default.selectors.getEntity) || {};
|
|
@@ -101,6 +102,14 @@ var useCustomScripts = function (config, _a) {
|
|
|
101
102
|
var task = _a.task, worker = _a.worker, config = _a.config;
|
|
102
103
|
if (task) {
|
|
103
104
|
switch (task.action) {
|
|
105
|
+
case mdm_sdk_1.CustomAction.LOG: {
|
|
106
|
+
console.log(task.params); //eslint-disable-line no-console
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
case mdm_sdk_1.CustomAction.MESSAGE: {
|
|
110
|
+
showSnackbarMessage(task.params);
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
104
113
|
case mdm_sdk_1.CustomAction.REQUEST: {
|
|
105
114
|
if (((_c = (_b = task.params) === null || _b === void 0 ? void 0 : _b.headers) === null || _c === void 0 ? void 0 : _c.origin) !== 'ui') {
|
|
106
115
|
useAPI_1.processRequest(__assign({ name: task.params.name, paramObject: task, permissions: config.action.permissions, worker: worker,
|
package/esm/hooks/useAPI/API.js
CHANGED
|
@@ -6,3 +6,11 @@ export var getWorkerURL = function (uiPath, tenant) {
|
|
|
6
6
|
return uiPath + "worker_api.js";
|
|
7
7
|
}
|
|
8
8
|
};
|
|
9
|
+
export var getFullApiPath = function (apiPath) {
|
|
10
|
+
if (apiPath === null || apiPath === void 0 ? void 0 : apiPath.includes('nui')) {
|
|
11
|
+
return "" + window.location.origin + apiPath;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
return apiPath;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -14,9 +14,9 @@ import { useDispatch, useSelector } from 'react-redux';
|
|
|
14
14
|
import mdmModule, { ui } from '@reltio/mdm-module';
|
|
15
15
|
import { CustomAction, CustomScriptPlatform, initializeWebWorker, isEmptyValue } from '@reltio/mdm-sdk';
|
|
16
16
|
import { useWorkflowCheckPermission } from '../../components/workflow';
|
|
17
|
-
import { SandboxAPIContext } from '../../contexts';
|
|
17
|
+
import { SandboxAPIContext, SnackbarContext } from '../../contexts';
|
|
18
18
|
import { processRequest } from './API';
|
|
19
|
-
import { getWorkerURL } from './helpers';
|
|
19
|
+
import { getFullApiPath, getWorkerURL } from './helpers';
|
|
20
20
|
export var useAPI = function (config) {
|
|
21
21
|
if (config === void 0) { config = {}; }
|
|
22
22
|
var _a = useState(), html = _a[0], setHtml = _a[1];
|
|
@@ -24,7 +24,7 @@ export var useAPI = function (config) {
|
|
|
24
24
|
var _c = useState(true), visible = _c[0], setVisible = _c[1];
|
|
25
25
|
var _d = useState(null), tooltip = _d[0], setTooltip = _d[1];
|
|
26
26
|
var _e = useState(null), customStyles = _e[0], setCustomStyles = _e[1];
|
|
27
|
-
var
|
|
27
|
+
var showSnackbarMessage = useContext(SnackbarContext);
|
|
28
28
|
var dispatch = useDispatch();
|
|
29
29
|
var metadata = useSelector(mdmModule.selectors.getMetadata) || {};
|
|
30
30
|
var entity = useSelector(mdmModule.selectors.getEntity) || {};
|
|
@@ -38,7 +38,7 @@ export var useAPI = function (config) {
|
|
|
38
38
|
var environment = useSelector(mdmModule.selectors.getWorkflowEnvironmentUrl);
|
|
39
39
|
var qxApi = useContext(SandboxAPIContext);
|
|
40
40
|
var workflowCheckPermission = useWorkflowCheckPermission();
|
|
41
|
-
var
|
|
41
|
+
var _f = useSelector(mdmModule.selectors.getSearchProviderData) || {}, typeSearch = _f.type, search = _f.data;
|
|
42
42
|
var openSearch = function (search) { return dispatch(ui.actions.openSearch(search)); };
|
|
43
43
|
var workerRef = useRef();
|
|
44
44
|
var process = function (_a) {
|
|
@@ -86,10 +86,17 @@ export var useAPI = function (config) {
|
|
|
86
86
|
setListenersToReset(handlersToReset_1);
|
|
87
87
|
setHtml(docBlock);
|
|
88
88
|
};
|
|
89
|
-
if (task.action === CustomAction.SET_HTML && innerText !== task.params.html) {
|
|
90
|
-
resetHtml(task.params.html);
|
|
91
|
-
}
|
|
92
89
|
switch (task.action) {
|
|
90
|
+
case CustomAction.SET_HTML: {
|
|
91
|
+
if (task.params.id) {
|
|
92
|
+
var elem = document.getElementById(task.params.id);
|
|
93
|
+
elem.innerHTML = task.params.html;
|
|
94
|
+
}
|
|
95
|
+
else if (innerText !== task.params.html) {
|
|
96
|
+
resetHtml(task.params.html);
|
|
97
|
+
}
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
93
100
|
case CustomAction.LOG: {
|
|
94
101
|
console.log(task.params); //eslint-disable-line no-console
|
|
95
102
|
break;
|
|
@@ -131,14 +138,12 @@ export var useAPI = function (config) {
|
|
|
131
138
|
break;
|
|
132
139
|
}
|
|
133
140
|
case CustomAction.MESSAGE: {
|
|
134
|
-
|
|
141
|
+
showSnackbarMessage(task.params);
|
|
135
142
|
break;
|
|
136
143
|
}
|
|
137
144
|
case CustomAction.REQUEST: {
|
|
138
145
|
processRequest(__assign({ name: task.params.name, paramObject: task, permissions: config.action.permissions, worker: worker,
|
|
139
|
-
metadata: metadata, config: config, user: user,
|
|
140
|
-
apiPath: apiPath,
|
|
141
|
-
tenant: tenant,
|
|
146
|
+
metadata: metadata, config: config, user: user, apiPath: getFullApiPath(apiPath), tenant: tenant,
|
|
142
147
|
workflowPath: workflowPath,
|
|
143
148
|
entity: entity,
|
|
144
149
|
entityUri: entityUri,
|
|
@@ -168,13 +173,5 @@ export var useAPI = function (config) {
|
|
|
168
173
|
data: null
|
|
169
174
|
});
|
|
170
175
|
}, [config]);
|
|
171
|
-
return {
|
|
172
|
-
html: html,
|
|
173
|
-
visible: visible,
|
|
174
|
-
tooltip: tooltip,
|
|
175
|
-
customStyles: customStyles,
|
|
176
|
-
message: message,
|
|
177
|
-
onClosePopup: function () { return setMessage(''); },
|
|
178
|
-
onClick: onClick
|
|
179
|
-
};
|
|
176
|
+
return { html: html, visible: visible, tooltip: tooltip, customStyles: customStyles, onClick: onClick };
|
|
180
177
|
};
|
|
@@ -32,7 +32,7 @@ import { CustomAction, CustomScriptPlatform, initializeWebWorker, isEmptyValue }
|
|
|
32
32
|
import nanoid from 'nanoid';
|
|
33
33
|
import { find, map, omit, pick, pipe, prop } from 'ramda';
|
|
34
34
|
import { useWorkflowCheckPermission } from '../components/workflow';
|
|
35
|
-
import { SandboxAPIContext } from '../contexts';
|
|
35
|
+
import { SandboxAPIContext, SnackbarContext } from '../contexts';
|
|
36
36
|
import { getWorkerURL, processRequest } from './useAPI';
|
|
37
37
|
var isURLtoProcess = function (processApi, url) {
|
|
38
38
|
return (processApi || []).some(function (request) {
|
|
@@ -52,6 +52,7 @@ export var useCustomScripts = function (config, _a) {
|
|
|
52
52
|
}
|
|
53
53
|
return acc;
|
|
54
54
|
}, []);
|
|
55
|
+
var showSnackbarMessage = useContext(SnackbarContext);
|
|
55
56
|
var dispatch = useDispatch();
|
|
56
57
|
var metadata = useSelector(mdmModule.selectors.getMetadata) || {};
|
|
57
58
|
var entity = useSelector(mdmModule.selectors.getEntity) || {};
|
|
@@ -76,6 +77,14 @@ export var useCustomScripts = function (config, _a) {
|
|
|
76
77
|
var task = _a.task, worker = _a.worker, config = _a.config;
|
|
77
78
|
if (task) {
|
|
78
79
|
switch (task.action) {
|
|
80
|
+
case CustomAction.LOG: {
|
|
81
|
+
console.log(task.params); //eslint-disable-line no-console
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
case CustomAction.MESSAGE: {
|
|
85
|
+
showSnackbarMessage(task.params);
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
79
88
|
case CustomAction.REQUEST: {
|
|
80
89
|
if (((_c = (_b = task.params) === null || _b === void 0 ? void 0 : _b.headers) === null || _c === void 0 ? void 0 : _c.origin) !== 'ui') {
|
|
81
90
|
processRequest(__assign({ name: task.params.name, paramObject: task, permissions: config.action.permissions, worker: worker,
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1170",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE FILE",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@date-io/moment": "^1.3.5",
|
|
9
9
|
"@react-google-maps/api": "2.7.0",
|
|
10
|
-
"@reltio/mdm-module": "^1.4.
|
|
11
|
-
"@reltio/mdm-sdk": "^1.4.
|
|
10
|
+
"@reltio/mdm-module": "^1.4.1170",
|
|
11
|
+
"@reltio/mdm-sdk": "^1.4.1170",
|
|
12
12
|
"classnames": "^2.2.5",
|
|
13
13
|
"d3-cloud": "^1.2.5",
|
|
14
14
|
"d3-geo": "^2.0.1",
|