@applica-software-guru/react-admin 1.3.126 → 1.3.128
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/ApplicaAdmin.d.ts +14 -29
- package/dist/ApplicaAdmin.d.ts.map +1 -1
- package/dist/components/Layout/Content.d.ts +4 -1
- package/dist/components/Layout/Content.d.ts.map +1 -1
- package/dist/components/Layout/Error.d.ts +27 -0
- package/dist/components/Layout/Error.d.ts.map +1 -0
- package/dist/components/Layout/Layout.d.ts +3 -0
- package/dist/components/Layout/Layout.d.ts.map +1 -1
- package/dist/components/Layout/index.d.ts +1 -0
- package/dist/components/Layout/index.d.ts.map +1 -1
- package/dist/components/ra-forms/LongForm/utils.d.ts.map +1 -1
- package/dist/components/ra-lists/List.d.ts +19 -18
- package/dist/components/ra-lists/List.d.ts.map +1 -1
- package/dist/components/ra-lists/ListView.d.ts +257 -0
- package/dist/components/ra-lists/ListView.d.ts.map +1 -0
- package/dist/dev/CatchResult.d.ts +17 -0
- package/dist/dev/CatchResult.d.ts.map +1 -0
- package/dist/dev/ErrorEventHandler.d.ts +13 -0
- package/dist/dev/ErrorEventHandler.d.ts.map +1 -0
- package/dist/dev/index.d.ts +4 -2
- package/dist/dev/index.d.ts.map +1 -1
- package/dist/dev/useErrorEventCatcher.d.ts +12 -0
- package/dist/dev/useErrorEventCatcher.d.ts.map +1 -0
- package/dist/react-admin.cjs.js +63 -63
- package/dist/react-admin.cjs.js.map +1 -1
- package/dist/react-admin.es.js +9563 -8992
- package/dist/react-admin.es.js.map +1 -1
- package/dist/react-admin.umd.js +66 -66
- package/dist/react-admin.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/ApplicaAdmin.tsx +19 -33
- package/src/components/Layout/Content.tsx +37 -16
- package/src/components/Layout/Error.tsx +81 -0
- package/src/components/Layout/Layout.tsx +3 -2
- package/src/components/Layout/index.ts +1 -0
- package/src/components/ra-forms/LongForm/hooks.tsx +1 -1
- package/src/components/ra-forms/LongForm/utils.ts +3 -1
- package/src/components/ra-lists/List.tsx +117 -2
- package/src/components/ra-lists/ListView.tsx +369 -0
- package/src/components/ra-pages/GenericErrorPage.tsx +1 -1
- package/src/dev/CatchResult.ts +32 -0
- package/src/dev/ErrorEventHandler.ts +51 -0
- package/src/dev/index.ts +4 -2
- package/src/dev/useErrorEventCatcher.ts +50 -0
- package/src/playground/components/pages/CustomPage.jsx +6 -0
- package/dist/dev/useCliErrorCatcher.d.ts +0 -59
- package/dist/dev/useCliErrorCatcher.d.ts.map +0 -1
- package/src/dev/useCliErrorCatcher.ts +0 -142
- /package/src/assets/{genericError.png → generic-error.png} +0 -0
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/* eslint-disable prefer-rest-params */
|
|
2
|
-
/* eslint-disable no-console */
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
|
|
5
|
-
export type CatchResultProps = {
|
|
6
|
-
catch: boolean;
|
|
7
|
-
display: boolean;
|
|
8
|
-
log: boolean;
|
|
9
|
-
error?: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
class CatchResult {
|
|
13
|
-
catch: boolean;
|
|
14
|
-
display: boolean;
|
|
15
|
-
log: boolean;
|
|
16
|
-
error?: string;
|
|
17
|
-
|
|
18
|
-
constructor({ catch: catchErr, display: displayErr, log: logErr, error }: CatchResultProps) {
|
|
19
|
-
this.catch = catchErr;
|
|
20
|
-
this.display = displayErr;
|
|
21
|
-
this.log = logErr;
|
|
22
|
-
this.error = error;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
isCatched() {
|
|
26
|
-
return this.catch;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
logError() {
|
|
30
|
-
return this.log;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
displayError() {
|
|
34
|
-
return this.display;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export type CliErrorCatcherBodyBuilderProps = (error: string | any) => any;
|
|
39
|
-
|
|
40
|
-
type CliErrorCatcherPutProps = {
|
|
41
|
-
apiUrl: string;
|
|
42
|
-
endpoint?: string;
|
|
43
|
-
message: string;
|
|
44
|
-
bodyBuilder: CliErrorCatcherBodyBuilderProps;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const putError = ({ apiUrl, endpoint, message, bodyBuilder }: CliErrorCatcherPutProps) =>
|
|
48
|
-
fetch(`${apiUrl}${endpoint}`, {
|
|
49
|
-
method: 'PUT',
|
|
50
|
-
headers: new Headers({
|
|
51
|
-
Accept: 'application/json',
|
|
52
|
-
'Content-Type': 'application/json'
|
|
53
|
-
}),
|
|
54
|
-
body: JSON.stringify(bodyBuilder(message))
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
export type UseCliErrorCatcherProps = {
|
|
58
|
-
/**
|
|
59
|
-
* Definisce l'URL del server API.
|
|
60
|
-
*/
|
|
61
|
-
apiUrl: string;
|
|
62
|
-
/**
|
|
63
|
-
* Definisce se il catcher è abilitato.
|
|
64
|
-
*/
|
|
65
|
-
enabled?: boolean;
|
|
66
|
-
/**
|
|
67
|
-
* Definisce l'endpoint del server API su cui inviare l'errore.
|
|
68
|
-
* Questo parametro viene aggiunto all'URL del server API (apiUrl) attraverso una semplice concatenazione.
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* // Serve più per ricordarti come funziona quando lo utilizzerai attivamente dopo tanto tempo (ti conosco bene Roberto, dimenticherai tutto!).
|
|
72
|
-
* let apiUrl = 'http://localhost:3000';
|
|
73
|
-
* let endpoint = '/ui-errors/put';
|
|
74
|
-
* let url = apiUrl + endpoint;
|
|
75
|
-
* // url = 'http://localhost:3000/ui-errors/put'
|
|
76
|
-
*/
|
|
77
|
-
endpoint?: string;
|
|
78
|
-
/**
|
|
79
|
-
* Definisce se l'applicazione chiamante è in caricamento.
|
|
80
|
-
* In tal caso il catcher non viene attivato.
|
|
81
|
-
*/
|
|
82
|
-
loading?: boolean;
|
|
83
|
-
/**
|
|
84
|
-
* Definisce la funzione che determina se l'errore deve essere catturato.
|
|
85
|
-
*
|
|
86
|
-
* @param error
|
|
87
|
-
* @returns {CatchResult} Restituisce un oggetto di tipo CatchResult.
|
|
88
|
-
*/
|
|
89
|
-
catcherFn?: (error: string | any) => CatchResult;
|
|
90
|
-
/**
|
|
91
|
-
* Definisce la funzione che costruisce il body da inviare al server API.
|
|
92
|
-
*/
|
|
93
|
-
bodyBuilder?: CliErrorCatcherBodyBuilderProps;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const useCliErrorCatcher = ({
|
|
97
|
-
enabled = true,
|
|
98
|
-
apiUrl,
|
|
99
|
-
endpoint = '/ui-errors/put',
|
|
100
|
-
loading,
|
|
101
|
-
catcherFn = (error) => new CatchResult({ catch: error != undefined, display: false, log: false }),
|
|
102
|
-
bodyBuilder = (error) => ({ message: error })
|
|
103
|
-
}: UseCliErrorCatcherProps) => {
|
|
104
|
-
React.useMemo(() => {
|
|
105
|
-
if (loading) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
if (!enabled) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const consoleError = console.error;
|
|
113
|
-
|
|
114
|
-
console.error = function (error, ...args) {
|
|
115
|
-
if (!error || typeof error !== 'string') {
|
|
116
|
-
consoleError.apply(console, arguments as any);
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
const message = error.replace(/%s/g, () => args.shift());
|
|
120
|
-
const catchResult = catcherFn(message);
|
|
121
|
-
if (!catchResult.isCatched()) {
|
|
122
|
-
consoleError.apply(console, arguments as any);
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (catchResult.logError()) {
|
|
127
|
-
putError({ apiUrl, endpoint, message, bodyBuilder });
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (catchResult.displayError()) {
|
|
131
|
-
consoleError.apply(console, arguments as any);
|
|
132
|
-
} else {
|
|
133
|
-
// eslint-disable-next-line prefer-spread
|
|
134
|
-
console.debug.apply(console, arguments as any);
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
}, [apiUrl, loading, bodyBuilder, endpoint, catcherFn, enabled]);
|
|
138
|
-
return true;
|
|
139
|
-
};
|
|
140
|
-
export { CatchResult };
|
|
141
|
-
|
|
142
|
-
export default useCliErrorCatcher;
|
|
File without changes
|