aefis-core-ui 2.2.3-rc4 → 2.3.0-rc2
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/dist/index.modern.js +83 -75
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -42,7 +42,7 @@ import { AnimatePresence, motion } from 'framer-motion';
|
|
|
42
42
|
import CircularProgress$1 from '@mui/material/CircularProgress';
|
|
43
43
|
import { useQuery, useInfiniteQuery, useQueryClient, useMutation, QueryClient, QueryClientProvider } from 'react-query';
|
|
44
44
|
import axios from 'axios';
|
|
45
|
-
import _ from 'lodash';
|
|
45
|
+
import _, { merge } from 'lodash';
|
|
46
46
|
import qs from 'query-string';
|
|
47
47
|
import SortIcon from '@mui/icons-material/Sort';
|
|
48
48
|
import { useSnackbar, SnackbarProvider } from 'notistack';
|
|
@@ -6882,12 +6882,9 @@ const sanitizedEval = (code, context, options) => {
|
|
|
6882
6882
|
}
|
|
6883
6883
|
};
|
|
6884
6884
|
|
|
6885
|
+
// TODO: move this to a state
|
|
6885
6886
|
let token = "";
|
|
6886
|
-
const apiClient = axios.create({
|
|
6887
|
-
validateStatus: false
|
|
6888
|
-
//baseURL: process.env.NODE_ENV === "development" ? "" : "/ui"
|
|
6889
|
-
});
|
|
6890
|
-
|
|
6887
|
+
const apiClient = axios.create({});
|
|
6891
6888
|
const parseQueryParam = url => {
|
|
6892
6889
|
const hashIndex = url.indexOf("#");
|
|
6893
6890
|
const noHashExists = hashIndex === -1;
|
|
@@ -6934,44 +6931,11 @@ apiClient.interceptors.request.use(config => {
|
|
|
6934
6931
|
for (const key in queryParams) {
|
|
6935
6932
|
queryParams[key] = objectParse(queryParams[key]);
|
|
6936
6933
|
}
|
|
6937
|
-
config.params =
|
|
6934
|
+
config.params = merge(queryParams, config.params);
|
|
6938
6935
|
config.url = urlOrigin;
|
|
6939
6936
|
}
|
|
6940
6937
|
return config;
|
|
6941
6938
|
});
|
|
6942
|
-
const getLoggerErrorMessage = error => {
|
|
6943
|
-
if (error.response) {
|
|
6944
|
-
var _error$response, _error$request, _error$response2, _error$response2$conf, _error$response2$conf2;
|
|
6945
|
-
const status = (_error$response = error.response) == null ? void 0 : _error$response.status;
|
|
6946
|
-
const URL = (_error$request = error.request) == null ? void 0 : _error$request.responseURL;
|
|
6947
|
-
const method = (_error$response2 = error.response) == null ? void 0 : (_error$response2$conf = _error$response2.config) == null ? void 0 : (_error$response2$conf2 = _error$response2$conf.method) == null ? void 0 : _error$response2$conf2.toUpperCase();
|
|
6948
|
-
const message = `RequestError: [${method}] ${status} ${URL}`;
|
|
6949
|
-
return message;
|
|
6950
|
-
} else if (error.request) {
|
|
6951
|
-
return "RequestError: No Response";
|
|
6952
|
-
} else {
|
|
6953
|
-
return `RequestError: ${error.message.toString()}`;
|
|
6954
|
-
}
|
|
6955
|
-
};
|
|
6956
|
-
|
|
6957
|
-
// Error is formatted to react query and reporting is handled by react-query
|
|
6958
|
-
// This prevent re-tried queries to trigger logger request
|
|
6959
|
-
const loggerForwardError = promise => (...args) => {
|
|
6960
|
-
return promise(...args).catch(error => {
|
|
6961
|
-
if (window.logger) {
|
|
6962
|
-
var _error$response3, _error$response3$conf, _window$logger;
|
|
6963
|
-
const message = getLoggerErrorMessage(error);
|
|
6964
|
-
const requestBody = ((_error$response3 = error.response) == null ? void 0 : (_error$response3$conf = _error$response3.config) == null ? void 0 : _error$response3$conf.data) || null;
|
|
6965
|
-
(_window$logger = window.logger) == null ? void 0 : _window$logger.logELKEvent == null ? void 0 : _window$logger.logELKEvent({
|
|
6966
|
-
name: message,
|
|
6967
|
-
data: requestBody
|
|
6968
|
-
});
|
|
6969
|
-
throw message;
|
|
6970
|
-
} else {
|
|
6971
|
-
throw error;
|
|
6972
|
-
}
|
|
6973
|
-
});
|
|
6974
|
-
};
|
|
6975
6939
|
function download(url) {
|
|
6976
6940
|
apiClient.request({
|
|
6977
6941
|
url: url,
|
|
@@ -6992,33 +6956,32 @@ function download(url) {
|
|
|
6992
6956
|
link.remove();
|
|
6993
6957
|
});
|
|
6994
6958
|
}
|
|
6995
|
-
function get() {
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
Authorization:
|
|
7000
|
-
}
|
|
7001
|
-
}
|
|
7002
|
-
return apiClient.get(...args);
|
|
6959
|
+
function get(endPoint, config = {}) {
|
|
6960
|
+
const isGateway = endPoint.includes("http://gateway") || endPoint.includes("https://gateway");
|
|
6961
|
+
return apiClient.get(endPoint, _extends({}, config, {
|
|
6962
|
+
headers: _extends({}, config.headers, isGateway && {
|
|
6963
|
+
Authorization: `Bearer ${token}`
|
|
6964
|
+
})
|
|
6965
|
+
}));
|
|
7003
6966
|
}
|
|
7004
|
-
function post() {
|
|
7005
|
-
return apiClient.post(...
|
|
6967
|
+
function post(...args) {
|
|
6968
|
+
return apiClient.post(...args);
|
|
7006
6969
|
}
|
|
7007
|
-
function put() {
|
|
7008
|
-
return apiClient.put(...
|
|
6970
|
+
function put(...args) {
|
|
6971
|
+
return apiClient.put(...args);
|
|
7009
6972
|
}
|
|
7010
|
-
function destroy() {
|
|
7011
|
-
return apiClient.
|
|
6973
|
+
function destroy(...args) {
|
|
6974
|
+
return apiClient.delete(...args);
|
|
7012
6975
|
}
|
|
7013
6976
|
async function setUserToken(t) {
|
|
7014
6977
|
token = t;
|
|
7015
6978
|
}
|
|
7016
6979
|
var http = {
|
|
7017
|
-
get
|
|
7018
|
-
post
|
|
7019
|
-
put
|
|
7020
|
-
download
|
|
7021
|
-
delete:
|
|
6980
|
+
get,
|
|
6981
|
+
post,
|
|
6982
|
+
put,
|
|
6983
|
+
download,
|
|
6984
|
+
delete: destroy,
|
|
7022
6985
|
setUserToken
|
|
7023
6986
|
};
|
|
7024
6987
|
|
|
@@ -7200,6 +7163,23 @@ let dataSourceConfiguration = {
|
|
|
7200
7163
|
}
|
|
7201
7164
|
};
|
|
7202
7165
|
|
|
7166
|
+
// TODO: move this function to logger
|
|
7167
|
+
const getLoggerErrorMessage = error => {
|
|
7168
|
+
if (!error.isAxiosError) return (error == null ? void 0 : error.toString()) || "Undefined error";
|
|
7169
|
+
if (error.response) {
|
|
7170
|
+
var _error$response, _error$request, _error$response2, _error$response2$conf, _error$response2$conf2;
|
|
7171
|
+
const status = (_error$response = error.response) == null ? void 0 : _error$response.status;
|
|
7172
|
+
const URL = (_error$request = error.request) == null ? void 0 : _error$request.responseURL;
|
|
7173
|
+
const method = (_error$response2 = error.response) == null ? void 0 : (_error$response2$conf = _error$response2.config) == null ? void 0 : (_error$response2$conf2 = _error$response2$conf.method) == null ? void 0 : _error$response2$conf2.toUpperCase();
|
|
7174
|
+
const message = `RequestError: [${method}] ${status} ${URL}`;
|
|
7175
|
+
return message;
|
|
7176
|
+
} else if (error.request) {
|
|
7177
|
+
return "RequestError: No Response";
|
|
7178
|
+
} else {
|
|
7179
|
+
return `RequestError: ${error.message.toString()}`;
|
|
7180
|
+
}
|
|
7181
|
+
};
|
|
7182
|
+
|
|
7203
7183
|
/**
|
|
7204
7184
|
* wraps function and reports (fire request) to Logger
|
|
7205
7185
|
* @param {function} onError
|
|
@@ -7208,11 +7188,29 @@ let dataSourceConfiguration = {
|
|
|
7208
7188
|
const logger = onError => (error, ...rest) => {
|
|
7209
7189
|
var _window$logger;
|
|
7210
7190
|
onError == null ? void 0 : onError(error, ...rest);
|
|
7211
|
-
|
|
7212
|
-
name: (error
|
|
7213
|
-
|
|
7214
|
-
|
|
7191
|
+
(_window$logger = window.logger) == null ? void 0 : _window$logger.sendLog({
|
|
7192
|
+
name: getLoggerErrorMessage(error),
|
|
7193
|
+
data: error
|
|
7194
|
+
});
|
|
7215
7195
|
};
|
|
7196
|
+
|
|
7197
|
+
/**
|
|
7198
|
+
* Promisify fetch, this is required for useQuery to handle error properly.
|
|
7199
|
+
* @param {Promise} fetch
|
|
7200
|
+
* @returns Promise
|
|
7201
|
+
*/
|
|
7202
|
+
const promisifyRequest = fetch => (...args) => new Promise(async (resolve, reject) => {
|
|
7203
|
+
try {
|
|
7204
|
+
const res = await fetch(...args);
|
|
7205
|
+
resolve(res);
|
|
7206
|
+
} catch (error) {
|
|
7207
|
+
var _window$logger2;
|
|
7208
|
+
reject(error);
|
|
7209
|
+
(_window$logger2 = window.logger) == null ? void 0 : _window$logger2.logEvent({
|
|
7210
|
+
name: getLoggerErrorMessage(error)
|
|
7211
|
+
});
|
|
7212
|
+
}
|
|
7213
|
+
});
|
|
7216
7214
|
const getGenericBusinessObjectAction = source => {
|
|
7217
7215
|
var typeAction = source.split("_");
|
|
7218
7216
|
return typeAction.length === 2 ? `businessObject_${typeAction[1]}` : source;
|
|
@@ -7368,7 +7366,7 @@ const useDataSourceQuery = (dataSource, parameters, options, templateContext) =>
|
|
|
7368
7366
|
return runQuery(dataSource, parameters, templateContext);
|
|
7369
7367
|
};
|
|
7370
7368
|
const fetchStrategy = configuration && typeof configuration.endPoint === "function" ? configuration.endPoint : fetch;
|
|
7371
|
-
return useQuery([dataSource, parameters], fetchStrategy, _extends({}, (configuration == null ? void 0 : configuration.options) || {}, options, {
|
|
7369
|
+
return useQuery([dataSource, parameters], promisifyRequest(fetchStrategy), _extends({}, (configuration == null ? void 0 : configuration.options) || {}, options, {
|
|
7372
7370
|
onError: logger(options == null ? void 0 : options.onError)
|
|
7373
7371
|
}));
|
|
7374
7372
|
};
|
|
@@ -7391,12 +7389,11 @@ const useDataSourceInfiniteQuery = (dataSource, parameters, initialParameters, o
|
|
|
7391
7389
|
const configuration = getConfiguration(dataSource);
|
|
7392
7390
|
const fetch = ({
|
|
7393
7391
|
pageParam: _pageParam = initialParameters
|
|
7394
|
-
}) => {
|
|
7395
|
-
return runQuery(dataSource, _extends({}, parameters, _pageParam));
|
|
7396
|
-
};
|
|
7392
|
+
}) => runQuery(dataSource, _extends({}, parameters, _pageParam));
|
|
7397
7393
|
const fetchStrategy = configuration && typeof configuration.endPoint === "function" ? configuration.endPoint : fetch;
|
|
7398
|
-
return useInfiniteQuery([dataSource, parameters], fetchStrategy, _extends({}, configuration ? configuration.options : {}, options, {
|
|
7399
|
-
onError: logger(options == null ? void 0 : options.onError)
|
|
7394
|
+
return useInfiniteQuery([dataSource, parameters], promisifyRequest(fetchStrategy), _extends({}, configuration ? configuration.options : {}, options, {
|
|
7395
|
+
onError: logger(options == null ? void 0 : options.onError),
|
|
7396
|
+
retry: false
|
|
7400
7397
|
}));
|
|
7401
7398
|
};
|
|
7402
7399
|
|
|
@@ -7415,7 +7412,6 @@ const useDataSourceMutation = (dataSource, baseParameters, options, invalidateQu
|
|
|
7415
7412
|
var _mutationOptions;
|
|
7416
7413
|
const queryClient = useQueryClient();
|
|
7417
7414
|
const configuration = getConfiguration(dataSource);
|
|
7418
|
-
getEndpoint(dataSource, configuration);
|
|
7419
7415
|
const invalidateFunction = () => {
|
|
7420
7416
|
if (invalidateQueries) {
|
|
7421
7417
|
for (let q of invalidateQueries) {
|
|
@@ -7442,11 +7438,11 @@ const useDataSourceMutation = (dataSource, baseParameters, options, invalidateQu
|
|
|
7442
7438
|
};
|
|
7443
7439
|
}
|
|
7444
7440
|
function requestCall(requestBody) {
|
|
7445
|
-
const request =
|
|
7441
|
+
const request = http[httpMethodType];
|
|
7446
7442
|
const endPoint = getEndpoint(dataSource, configuration); //?
|
|
7447
7443
|
if (httpMethodType === "get" || httpMethodType === "delete") {
|
|
7448
7444
|
// INFO (Caveat!): requestBody is used as query param in case of
|
|
7449
|
-
// httpMethodType is
|
|
7445
|
+
// httpMethodType is GET or DELETE
|
|
7450
7446
|
const params = _extends({}, baseParameters, requestBody);
|
|
7451
7447
|
return request(endPoint, {
|
|
7452
7448
|
params
|
|
@@ -7454,7 +7450,7 @@ const useDataSourceMutation = (dataSource, baseParameters, options, invalidateQu
|
|
|
7454
7450
|
}
|
|
7455
7451
|
return request(endPoint, requestBody);
|
|
7456
7452
|
}
|
|
7457
|
-
return useMutation(requestCall, _extends({}, mutationOptions, {
|
|
7453
|
+
return useMutation(promisifyRequest(requestCall), _extends({}, mutationOptions, {
|
|
7458
7454
|
onError: logger((_mutationOptions = mutationOptions) == null ? void 0 : _mutationOptions.onError)
|
|
7459
7455
|
}));
|
|
7460
7456
|
};
|
|
@@ -10751,7 +10747,7 @@ const RichDataTable = /*#__PURE__*/forwardRef(function RichDatatable(props, ref)
|
|
|
10751
10747
|
exportOptions: props.exportOptions,
|
|
10752
10748
|
actions: props.actions && props.actions.length > 0 || props.addAction ? updateActions(props.actions, handleDrawerOpen, enableTableRowAction, selectedRowCount, Add) : undefined,
|
|
10753
10749
|
onFilterClick: isFilterPanelEnabled ? handleFilterClick : undefined,
|
|
10754
|
-
hasFilters: filterPanelState.filterCount > 0 || filterPanelState.sortCount > 0 || filterPanelState.searchText,
|
|
10750
|
+
hasFilters: filterPanelState.filterCount > 0 || filterPanelState.sortCount > 0 || !!filterPanelState.searchText,
|
|
10755
10751
|
disableFilterButton: isFetching
|
|
10756
10752
|
}, props.titleAndActionHeaderProps)), /*#__PURE__*/jsx(DataTable, _extends({}, props, {
|
|
10757
10753
|
tableRef: DataTableRef,
|
|
@@ -17289,6 +17285,9 @@ const Upload = props => {
|
|
|
17289
17285
|
type: (message == null ? void 0 : message.type) || "info",
|
|
17290
17286
|
canDismiss: (message == null ? void 0 : message.canDismiss) || true
|
|
17291
17287
|
};
|
|
17288
|
+
const {
|
|
17289
|
+
error
|
|
17290
|
+
} = useNotify();
|
|
17292
17291
|
const filePondProps = {
|
|
17293
17292
|
acceptedFileTypes: acceptedFileTypes ? acceptedFileTypes : isImage ? ["image/*"] : null,
|
|
17294
17293
|
files,
|
|
@@ -17300,7 +17299,16 @@ const Upload = props => {
|
|
|
17300
17299
|
headers: {
|
|
17301
17300
|
Methods: "POST"
|
|
17302
17301
|
},
|
|
17303
|
-
onload: handleUploadResponse
|
|
17302
|
+
onload: handleUploadResponse,
|
|
17303
|
+
onerror: e => {
|
|
17304
|
+
var _window$logger;
|
|
17305
|
+
const message = `The image could not be uploaded.`;
|
|
17306
|
+
error(message);
|
|
17307
|
+
(_window$logger = window.logger) == null ? void 0 : _window$logger.sendLog({
|
|
17308
|
+
name: message,
|
|
17309
|
+
data: e
|
|
17310
|
+
});
|
|
17311
|
+
}
|
|
17304
17312
|
},
|
|
17305
17313
|
load: handleLoad,
|
|
17306
17314
|
revert: handleDelete
|