@inventreedb/ui 0.8.2 → 0.9.0
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 +6 -0
- package/dist/.vite/manifest.json +32 -7
- package/dist/components/RowActions.js +4 -4
- package/dist/hooks/MonitorBackgroundTask.d.ts +20 -0
- package/dist/hooks/MonitorBackgroundTask.js +77 -0
- package/dist/hooks/MonitorBackgroundTask.js.map +1 -0
- package/dist/hooks/MonitorDataOutput.d.ts +6 -5
- package/dist/hooks/MonitorDataOutput.js +19 -25
- package/dist/hooks/MonitorDataOutput.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/createReactComponent.js +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/createReactComponent.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.js +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowRight.js +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowRight.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleCheck.js +2 -2
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleCheck.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleX.js +2 -2
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleX.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCopy.js +2 -2
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCopy.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconDots.js +2 -2
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconDots.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconEdit.js +2 -2
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconEdit.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconExclamationCircle.js +2 -2
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconExclamationCircle.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconPlus.js +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconPlus.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconSearch.js +2 -2
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconSearch.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconTrash.js +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconTrash.js.map +1 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/notifyManager.js +2 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/notifyManager.js.map +1 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/query.js.map +1 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/queryObserver.js +20 -14
- package/dist/node_modules/@tanstack/query-core/build/modern/queryObserver.js.map +1 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/timeoutManager.js +69 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/timeoutManager.js.map +1 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/utils.js +3 -2
- package/dist/node_modules/@tanstack/query-core/build/modern/utils.js.map +1 -1
- package/dist/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js +3 -2
- package/dist/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js.map +1 -1
- package/dist/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js +4 -3
- package/dist/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js.map +1 -1
- package/dist/types/Plugins.js +3 -3
- package/lib/hooks/MonitorBackgroundTask.tsx +118 -0
- package/lib/hooks/MonitorDataOutput.tsx +25 -29
- package/lib/index.ts +8 -1
- package/package.json +28 -25
|
@@ -21,6 +21,7 @@ function useBaseQuery(options, Observer, queryClient) {
|
|
|
21
21
|
client.getDefaultOptions().queries?._experimental_beforeQuery?.(
|
|
22
22
|
defaultedOptions
|
|
23
23
|
);
|
|
24
|
+
const query = client.getQueryCache().get(defaultedOptions.queryHash);
|
|
24
25
|
if (process.env.NODE_ENV !== "production") {
|
|
25
26
|
if (!defaultedOptions.queryFn) {
|
|
26
27
|
console.error(
|
|
@@ -30,7 +31,7 @@ function useBaseQuery(options, Observer, queryClient) {
|
|
|
30
31
|
}
|
|
31
32
|
defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
|
|
32
33
|
ensureSuspenseTimers(defaultedOptions);
|
|
33
|
-
ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
|
|
34
|
+
ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary, query);
|
|
34
35
|
useClearResetErrorBoundary(errorResetBoundary);
|
|
35
36
|
const isNewCacheEntry = !client.getQueryCache().get(defaultedOptions.queryHash);
|
|
36
37
|
const [observer] = React.useState(
|
|
@@ -63,7 +64,7 @@ function useBaseQuery(options, Observer, queryClient) {
|
|
|
63
64
|
result,
|
|
64
65
|
errorResetBoundary,
|
|
65
66
|
throwOnError: defaultedOptions.throwOnError,
|
|
66
|
-
query
|
|
67
|
+
query,
|
|
67
68
|
suspense: defaultedOptions.suspense
|
|
68
69
|
})) {
|
|
69
70
|
throw result.error;
|
|
@@ -78,7 +79,7 @@ function useBaseQuery(options, Observer, queryClient) {
|
|
|
78
79
|
fetchOptimistic(defaultedOptions, observer, errorResetBoundary)
|
|
79
80
|
) : (
|
|
80
81
|
// subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
|
|
81
|
-
|
|
82
|
+
query?.promise
|
|
82
83
|
);
|
|
83
84
|
promise?.catch(noop).finally(() => {
|
|
84
85
|
observer.updateResult();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBaseQuery.js","sources":["../../../../../../node_modules/@tanstack/react-query/build/modern/useBaseQuery.js"],"sourcesContent":["\"use client\";\n\n// src/useBaseQuery.ts\nimport * as React from \"react\";\nimport { isServer, noop, notifyManager } from \"@tanstack/query-core\";\nimport { useQueryClient } from \"./QueryClientProvider.js\";\nimport { useQueryErrorResetBoundary } from \"./QueryErrorResetBoundary.js\";\nimport {\n ensurePreventErrorBoundaryRetry,\n getHasError,\n useClearResetErrorBoundary\n} from \"./errorBoundaryUtils.js\";\nimport { useIsRestoring } from \"./IsRestoringProvider.js\";\nimport {\n ensureSuspenseTimers,\n fetchOptimistic,\n shouldSuspend,\n willFetch\n} from \"./suspense.js\";\nfunction useBaseQuery(options, Observer, queryClient) {\n if (process.env.NODE_ENV !== \"production\") {\n if (typeof options !== \"object\" || Array.isArray(options)) {\n throw new Error(\n 'Bad argument type. Starting with v5, only the \"Object\" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object'\n );\n }\n }\n const isRestoring = useIsRestoring();\n const errorResetBoundary = useQueryErrorResetBoundary();\n const client = useQueryClient(queryClient);\n const defaultedOptions = client.defaultQueryOptions(options);\n client.getDefaultOptions().queries?._experimental_beforeQuery?.(\n defaultedOptions\n );\n if (process.env.NODE_ENV !== \"production\") {\n if (!defaultedOptions.queryFn) {\n console.error(\n `[${defaultedOptions.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`\n );\n }\n }\n defaultedOptions._optimisticResults = isRestoring ? \"isRestoring\" : \"optimistic\";\n ensureSuspenseTimers(defaultedOptions);\n ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);\n useClearResetErrorBoundary(errorResetBoundary);\n const isNewCacheEntry = !client.getQueryCache().get(defaultedOptions.queryHash);\n const [observer] = React.useState(\n () => new Observer(\n client,\n defaultedOptions\n )\n );\n const result = observer.getOptimisticResult(defaultedOptions);\n const shouldSubscribe = !isRestoring && options.subscribed !== false;\n React.useSyncExternalStore(\n React.useCallback(\n (onStoreChange) => {\n const unsubscribe = shouldSubscribe ? observer.subscribe(notifyManager.batchCalls(onStoreChange)) : noop;\n observer.updateResult();\n return unsubscribe;\n },\n [observer, shouldSubscribe]\n ),\n () => observer.getCurrentResult(),\n () => observer.getCurrentResult()\n );\n React.useEffect(() => {\n observer.setOptions(defaultedOptions);\n }, [defaultedOptions, observer]);\n if (shouldSuspend(defaultedOptions, result)) {\n throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);\n }\n if (getHasError({\n result,\n errorResetBoundary,\n throwOnError: defaultedOptions.throwOnError,\n query
|
|
1
|
+
{"version":3,"file":"useBaseQuery.js","sources":["../../../../../../node_modules/@tanstack/react-query/build/modern/useBaseQuery.js"],"sourcesContent":["\"use client\";\n\n// src/useBaseQuery.ts\nimport * as React from \"react\";\nimport { isServer, noop, notifyManager } from \"@tanstack/query-core\";\nimport { useQueryClient } from \"./QueryClientProvider.js\";\nimport { useQueryErrorResetBoundary } from \"./QueryErrorResetBoundary.js\";\nimport {\n ensurePreventErrorBoundaryRetry,\n getHasError,\n useClearResetErrorBoundary\n} from \"./errorBoundaryUtils.js\";\nimport { useIsRestoring } from \"./IsRestoringProvider.js\";\nimport {\n ensureSuspenseTimers,\n fetchOptimistic,\n shouldSuspend,\n willFetch\n} from \"./suspense.js\";\nfunction useBaseQuery(options, Observer, queryClient) {\n if (process.env.NODE_ENV !== \"production\") {\n if (typeof options !== \"object\" || Array.isArray(options)) {\n throw new Error(\n 'Bad argument type. Starting with v5, only the \"Object\" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object'\n );\n }\n }\n const isRestoring = useIsRestoring();\n const errorResetBoundary = useQueryErrorResetBoundary();\n const client = useQueryClient(queryClient);\n const defaultedOptions = client.defaultQueryOptions(options);\n client.getDefaultOptions().queries?._experimental_beforeQuery?.(\n defaultedOptions\n );\n const query = client.getQueryCache().get(defaultedOptions.queryHash);\n if (process.env.NODE_ENV !== \"production\") {\n if (!defaultedOptions.queryFn) {\n console.error(\n `[${defaultedOptions.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`\n );\n }\n }\n defaultedOptions._optimisticResults = isRestoring ? \"isRestoring\" : \"optimistic\";\n ensureSuspenseTimers(defaultedOptions);\n ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary, query);\n useClearResetErrorBoundary(errorResetBoundary);\n const isNewCacheEntry = !client.getQueryCache().get(defaultedOptions.queryHash);\n const [observer] = React.useState(\n () => new Observer(\n client,\n defaultedOptions\n )\n );\n const result = observer.getOptimisticResult(defaultedOptions);\n const shouldSubscribe = !isRestoring && options.subscribed !== false;\n React.useSyncExternalStore(\n React.useCallback(\n (onStoreChange) => {\n const unsubscribe = shouldSubscribe ? observer.subscribe(notifyManager.batchCalls(onStoreChange)) : noop;\n observer.updateResult();\n return unsubscribe;\n },\n [observer, shouldSubscribe]\n ),\n () => observer.getCurrentResult(),\n () => observer.getCurrentResult()\n );\n React.useEffect(() => {\n observer.setOptions(defaultedOptions);\n }, [defaultedOptions, observer]);\n if (shouldSuspend(defaultedOptions, result)) {\n throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);\n }\n if (getHasError({\n result,\n errorResetBoundary,\n throwOnError: defaultedOptions.throwOnError,\n query,\n suspense: defaultedOptions.suspense\n })) {\n throw result.error;\n }\n ;\n client.getDefaultOptions().queries?._experimental_afterQuery?.(\n defaultedOptions,\n result\n );\n if (defaultedOptions.experimental_prefetchInRender && !isServer && willFetch(result, isRestoring)) {\n const promise = isNewCacheEntry ? (\n // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted\n fetchOptimistic(defaultedOptions, observer, errorResetBoundary)\n ) : (\n // subscribe to the \"cache promise\" so that we can finalize the currentThenable once data comes in\n query?.promise\n );\n promise?.catch(noop).finally(() => {\n observer.updateResult();\n });\n }\n return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;\n}\nexport {\n useBaseQuery\n};\n//# sourceMappingURL=useBaseQuery.js.map"],"names":[],"mappings":";;;;;;;AAGA,MAAA,QAAA,OAAA,OAAA;AAgBA,SAAS,aAAa,SAAS,UAAU,aAAa;AACpD,MAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,QAAI,OAAO,YAAY,YAAY,MAAM,QAAQ,OAAO,GAAG;AACzD,YAAM,IAAI;AAAA,QACR;AAAA,MACR;AAAA,IACI;AAAA,EACF;AACA,QAAM,cAAc,eAAc;AAClC,QAAM,qBAAqB,2BAA0B;AACrD,QAAM,SAAS,eAAe,WAAW;AACzC,QAAM,mBAAmB,OAAO,oBAAoB,OAAO;AAC3D,SAAO,oBAAoB,SAAS;AAAA,IAClC;AAAA,EACJ;AACE,QAAM,QAAQ,OAAO,cAAa,EAAG,IAAI,iBAAiB,SAAS;AACnE,MAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,QAAI,CAAC,iBAAiB,SAAS;AAC7B,cAAQ;AAAA,QACN,IAAI,iBAAiB,SAAS;AAAA,MACtC;AAAA,IACI;AAAA,EACF;AACA,mBAAiB,qBAAqB,cAAc,gBAAgB;AACpE,uBAAqB,gBAAgB;AACrC,kCAAgC,kBAAkB,oBAAoB,KAAK;AAC3E,6BAA2B,kBAAkB;AAC7C,QAAM,kBAAkB,CAAC,OAAO,cAAa,EAAG,IAAI,iBAAiB,SAAS;AAC9E,QAAM,CAAC,QAAQ,IAAI,MAAM;AAAA,IACvB,MAAM,IAAI;AAAA,MACR;AAAA,MACA;AAAA,IACN;AAAA,EACA;AACE,QAAM,SAAS,SAAS,oBAAoB,gBAAgB;AAC5D,QAAM,kBAAkB,CAAC,eAAe,QAAQ,eAAe;AAC/D,QAAM;AAAA,IACJ,MAAM;AAAA,MACJ,CAAC,kBAAkB;AACjB,cAAM,cAAc,kBAAkB,SAAS,UAAU,cAAc,WAAW,aAAa,CAAC,IAAI;AACpG,iBAAS,aAAY;AACrB,eAAO;AAAA,MACT;AAAA,MACA,CAAC,UAAU,eAAe;AAAA,IAChC;AAAA,IACI,MAAM,SAAS,iBAAgB;AAAA,IAC/B,MAAM,SAAS,iBAAgB;AAAA,EACnC;AACE,QAAM,UAAU,MAAM;AACpB,aAAS,WAAW,gBAAgB;AAAA,EACtC,GAAG,CAAC,kBAAkB,QAAQ,CAAC;AAC/B,MAAI,cAAc,kBAAkB,MAAM,GAAG;AAC3C,UAAM,gBAAgB,kBAAkB,UAAU,kBAAkB;AAAA,EACtE;AACA,MAAI,YAAY;AAAA,IACd;AAAA,IACA;AAAA,IACA,cAAc,iBAAiB;AAAA,IAC/B;AAAA,IACA,UAAU,iBAAiB;AAAA,EAC/B,CAAG,GAAG;AACF,UAAM,OAAO;AAAA,EACf;AAEA,SAAO,oBAAoB,SAAS;AAAA,IAClC;AAAA,IACA;AAAA,EACJ;AACE,MAAI,iBAAiB,iCAAiC,CAAC,YAAY,UAAU,QAAQ,WAAW,GAAG;AACjG,UAAM,UAAU;AAAA;AAAA,MAEd,gBAAgB,kBAAkB,UAAU,kBAAkB;AAAA;AAAA;AAAA,MAG9D,OAAO;AAAA;AAET,aAAS,MAAM,IAAI,EAAE,QAAQ,MAAM;AACjC,eAAS,aAAY;AAAA,IACvB,CAAC;AAAA,EACH;AACA,SAAO,CAAC,iBAAiB,sBAAsB,SAAS,YAAY,MAAM,IAAI;AAChF;","x_google_ignoreList":[0]}
|
package/dist/types/Plugins.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const INVENTREE_PLUGIN_VERSION = "0.
|
|
2
|
-
const INVENTREE_REACT_VERSION = "19.
|
|
1
|
+
const INVENTREE_PLUGIN_VERSION = "0.9.0";
|
|
2
|
+
const INVENTREE_REACT_VERSION = "19.2.4";
|
|
3
3
|
const INVENTREE_REACT_DOM_VERSION = (
|
|
4
4
|
// @ts-ignore
|
|
5
|
-
"19.
|
|
5
|
+
"19.2.4"
|
|
6
6
|
);
|
|
7
7
|
const INVENTREE_MANTINE_VERSION = "8.2.7";
|
|
8
8
|
export {
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { useDocumentVisibility } from '@mantine/hooks';
|
|
2
|
+
import { notifications, showNotification } from '@mantine/notifications';
|
|
3
|
+
import {
|
|
4
|
+
IconCircleCheck,
|
|
5
|
+
IconCircleX,
|
|
6
|
+
IconExclamationCircle
|
|
7
|
+
} from '@tabler/icons-react';
|
|
8
|
+
import { type QueryClient, useQuery } from '@tanstack/react-query';
|
|
9
|
+
import type { AxiosInstance } from 'axios';
|
|
10
|
+
import { useEffect, useState } from 'react';
|
|
11
|
+
import { ApiEndpoints } from '../enums/ApiEndpoints';
|
|
12
|
+
import { apiUrl } from '../functions/Api';
|
|
13
|
+
|
|
14
|
+
export type MonitorBackgroundTaskProps = {
|
|
15
|
+
api: AxiosInstance;
|
|
16
|
+
queryClient?: QueryClient;
|
|
17
|
+
title?: string;
|
|
18
|
+
message: string;
|
|
19
|
+
errorMessage?: string;
|
|
20
|
+
successMessage?: string;
|
|
21
|
+
failureMessage?: string;
|
|
22
|
+
taskId?: string;
|
|
23
|
+
onSuccess?: () => void;
|
|
24
|
+
onFailure?: () => void;
|
|
25
|
+
onComplete?: () => void;
|
|
26
|
+
onError?: (error: Error) => void;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Hook for monitoring a background task running on the server
|
|
31
|
+
*/
|
|
32
|
+
export default function useMonitorBackgroundTask(
|
|
33
|
+
props: MonitorBackgroundTaskProps
|
|
34
|
+
) {
|
|
35
|
+
const visibility = useDocumentVisibility();
|
|
36
|
+
|
|
37
|
+
const [tracking, setTracking] = useState<boolean>(false);
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!!props.taskId) {
|
|
41
|
+
setTracking(true);
|
|
42
|
+
showNotification({
|
|
43
|
+
id: `background-task-${props.taskId}`,
|
|
44
|
+
title: props.title,
|
|
45
|
+
message: props.message,
|
|
46
|
+
loading: true,
|
|
47
|
+
autoClose: false,
|
|
48
|
+
withCloseButton: false
|
|
49
|
+
});
|
|
50
|
+
} else {
|
|
51
|
+
setTracking(false);
|
|
52
|
+
}
|
|
53
|
+
}, [props.taskId]);
|
|
54
|
+
|
|
55
|
+
useQuery(
|
|
56
|
+
{
|
|
57
|
+
enabled: !!props.taskId && tracking && visibility === 'visible',
|
|
58
|
+
refetchInterval: 500,
|
|
59
|
+
queryKey: ['background-task', props.taskId],
|
|
60
|
+
queryFn: () =>
|
|
61
|
+
props.api
|
|
62
|
+
.get(apiUrl(ApiEndpoints.task_overview, props.taskId))
|
|
63
|
+
.then((response) => {
|
|
64
|
+
const data = response?.data ?? {};
|
|
65
|
+
|
|
66
|
+
if (data.complete) {
|
|
67
|
+
setTracking(false);
|
|
68
|
+
props.onComplete?.();
|
|
69
|
+
|
|
70
|
+
notifications.update({
|
|
71
|
+
id: `background-task-${props.taskId}`,
|
|
72
|
+
title: props.title,
|
|
73
|
+
loading: false,
|
|
74
|
+
color: data.success ? 'green' : 'red',
|
|
75
|
+
message: response.data?.success
|
|
76
|
+
? (props.successMessage ?? props.message)
|
|
77
|
+
: (props.failureMessage ?? props.message),
|
|
78
|
+
icon: response.data?.success ? (
|
|
79
|
+
<IconCircleCheck />
|
|
80
|
+
) : (
|
|
81
|
+
<IconCircleX />
|
|
82
|
+
),
|
|
83
|
+
autoClose: 1000,
|
|
84
|
+
withCloseButton: true
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
if (data.success) {
|
|
88
|
+
props.onSuccess?.();
|
|
89
|
+
} else {
|
|
90
|
+
props.onFailure?.();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return response;
|
|
95
|
+
})
|
|
96
|
+
.catch((error) => {
|
|
97
|
+
console.error(
|
|
98
|
+
`Error fetching background task status for task ${props.taskId}:`,
|
|
99
|
+
error
|
|
100
|
+
);
|
|
101
|
+
setTracking(false);
|
|
102
|
+
props.onError?.(error);
|
|
103
|
+
|
|
104
|
+
notifications.update({
|
|
105
|
+
id: `background-task-${props.taskId}`,
|
|
106
|
+
title: props.title,
|
|
107
|
+
loading: false,
|
|
108
|
+
color: 'red',
|
|
109
|
+
message: props.errorMessage ?? props.message,
|
|
110
|
+
icon: <IconExclamationCircle color='red' />,
|
|
111
|
+
autoClose: 5000,
|
|
112
|
+
withCloseButton: true
|
|
113
|
+
});
|
|
114
|
+
})
|
|
115
|
+
},
|
|
116
|
+
props.queryClient
|
|
117
|
+
);
|
|
118
|
+
}
|
|
@@ -9,48 +9,44 @@ import { ProgressBar } from '../components/ProgressBar';
|
|
|
9
9
|
import { ApiEndpoints } from '../enums/ApiEndpoints';
|
|
10
10
|
import { apiUrl } from '../functions/Api';
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
* Hook for monitoring a data output process running on the server
|
|
14
|
-
*/
|
|
15
|
-
export default function monitorDataOutput({
|
|
16
|
-
api,
|
|
17
|
-
queryClient,
|
|
18
|
-
title,
|
|
19
|
-
hostname,
|
|
20
|
-
id
|
|
21
|
-
}: {
|
|
12
|
+
export type MonitorDataOutputProps = {
|
|
22
13
|
api: AxiosInstance;
|
|
23
14
|
queryClient?: QueryClient;
|
|
24
15
|
title: string;
|
|
25
16
|
hostname?: string;
|
|
26
17
|
id?: number;
|
|
27
|
-
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Hook for monitoring a data output process running on the server
|
|
22
|
+
*/
|
|
23
|
+
export default function useMonitorDataOutput(props: MonitorDataOutputProps) {
|
|
28
24
|
const visibility = useDocumentVisibility();
|
|
29
25
|
|
|
30
26
|
const [loading, setLoading] = useState<boolean>(false);
|
|
31
27
|
|
|
32
28
|
useEffect(() => {
|
|
33
|
-
if (!!id) {
|
|
29
|
+
if (!!props.id) {
|
|
34
30
|
setLoading(true);
|
|
35
31
|
showNotification({
|
|
36
|
-
id: `data-output-${id}`,
|
|
37
|
-
title: title,
|
|
32
|
+
id: `data-output-${props.id}`,
|
|
33
|
+
title: props.title,
|
|
38
34
|
loading: true,
|
|
39
35
|
autoClose: false,
|
|
40
36
|
withCloseButton: false,
|
|
41
37
|
message: <ProgressBar size='lg' value={0} progressLabel />
|
|
42
38
|
});
|
|
43
39
|
} else setLoading(false);
|
|
44
|
-
}, [id, title]);
|
|
40
|
+
}, [props.id, props.title]);
|
|
45
41
|
|
|
46
42
|
useQuery(
|
|
47
43
|
{
|
|
48
|
-
enabled: !!id && loading && visibility === 'visible',
|
|
44
|
+
enabled: !!props.id && loading && visibility === 'visible',
|
|
49
45
|
refetchInterval: 500,
|
|
50
|
-
queryKey: ['data-output', id, title],
|
|
46
|
+
queryKey: ['data-output', props.id, props.title],
|
|
51
47
|
queryFn: () =>
|
|
52
|
-
api
|
|
53
|
-
.get(apiUrl(ApiEndpoints.data_output, id))
|
|
48
|
+
props.api
|
|
49
|
+
.get(apiUrl(ApiEndpoints.data_output, props.id))
|
|
54
50
|
.then((response) => {
|
|
55
51
|
const data = response?.data ?? {};
|
|
56
52
|
|
|
@@ -61,21 +57,21 @@ export default function monitorDataOutput({
|
|
|
61
57
|
data?.error ?? data?.errors?.error ?? t`Process failed`;
|
|
62
58
|
|
|
63
59
|
notifications.update({
|
|
64
|
-
id: `data-output-${id}`,
|
|
60
|
+
id: `data-output-${props.id}`,
|
|
65
61
|
loading: false,
|
|
66
62
|
icon: <IconExclamationCircle />,
|
|
67
63
|
autoClose: 2500,
|
|
68
|
-
title: title,
|
|
64
|
+
title: props.title,
|
|
69
65
|
message: error,
|
|
70
66
|
color: 'red'
|
|
71
67
|
});
|
|
72
68
|
} else if (data.complete) {
|
|
73
69
|
setLoading(false);
|
|
74
70
|
notifications.update({
|
|
75
|
-
id: `data-output-${id}`,
|
|
71
|
+
id: `data-output-${props.id}`,
|
|
76
72
|
loading: false,
|
|
77
73
|
autoClose: 2500,
|
|
78
|
-
title: title,
|
|
74
|
+
title: props.title,
|
|
79
75
|
message: t`Process completed successfully`,
|
|
80
76
|
color: 'green',
|
|
81
77
|
icon: <IconCircleCheck />
|
|
@@ -83,7 +79,7 @@ export default function monitorDataOutput({
|
|
|
83
79
|
|
|
84
80
|
if (data.output) {
|
|
85
81
|
const url = data.output;
|
|
86
|
-
const base = hostname ?? window.location.origin;
|
|
82
|
+
const base = props.hostname ?? window.location.origin;
|
|
87
83
|
|
|
88
84
|
const downloadUrl = new URL(url, base);
|
|
89
85
|
|
|
@@ -91,7 +87,7 @@ export default function monitorDataOutput({
|
|
|
91
87
|
}
|
|
92
88
|
} else {
|
|
93
89
|
notifications.update({
|
|
94
|
-
id: `data-output-${id}`,
|
|
90
|
+
id: `data-output-${props.id}`,
|
|
95
91
|
loading: true,
|
|
96
92
|
autoClose: false,
|
|
97
93
|
withCloseButton: false,
|
|
@@ -110,19 +106,19 @@ export default function monitorDataOutput({
|
|
|
110
106
|
return data;
|
|
111
107
|
})
|
|
112
108
|
.catch((error: Error) => {
|
|
113
|
-
console.error('Error in
|
|
109
|
+
console.error('Error in useMonitorDataOutput:', error);
|
|
114
110
|
setLoading(false);
|
|
115
111
|
notifications.update({
|
|
116
|
-
id: `data-output-${id}`,
|
|
112
|
+
id: `data-output-${props.id}`,
|
|
117
113
|
loading: false,
|
|
118
114
|
autoClose: 2500,
|
|
119
|
-
title: title,
|
|
115
|
+
title: props.title,
|
|
120
116
|
message: error.message || t`Process failed`,
|
|
121
117
|
color: 'red'
|
|
122
118
|
});
|
|
123
119
|
return {};
|
|
124
120
|
})
|
|
125
121
|
},
|
|
126
|
-
queryClient
|
|
122
|
+
props.queryClient
|
|
127
123
|
);
|
|
128
124
|
}
|
package/lib/index.ts
CHANGED
|
@@ -73,4 +73,11 @@ export {
|
|
|
73
73
|
} from './components/RowActions';
|
|
74
74
|
|
|
75
75
|
// Shared hooks
|
|
76
|
-
export {
|
|
76
|
+
export {
|
|
77
|
+
default as useMonitorDataOutput,
|
|
78
|
+
type MonitorDataOutputProps
|
|
79
|
+
} from './hooks/MonitorDataOutput';
|
|
80
|
+
export {
|
|
81
|
+
default as useMonitorBackgroundTask,
|
|
82
|
+
type MonitorBackgroundTaskProps
|
|
83
|
+
} from './hooks/MonitorBackgroundTask';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inventreedb/ui",
|
|
3
3
|
"description": "UI components for the InvenTree project",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.9.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"compile": "lingui compile --typescript"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
+
"@codecov/vite-plugin": "^1.9.1",
|
|
43
44
|
"@codemirror/autocomplete": "^6.20.1",
|
|
44
45
|
"@codemirror/lang-liquid": "^6.3.2",
|
|
45
46
|
"@codemirror/language": "^6.12.2",
|
|
@@ -47,7 +48,7 @@
|
|
|
47
48
|
"@codemirror/search": "^6.6.0",
|
|
48
49
|
"@codemirror/state": "^6.5.4",
|
|
49
50
|
"@codemirror/theme-one-dark": "^6.1.3",
|
|
50
|
-
"@codemirror/view": "6.
|
|
51
|
+
"@codemirror/view": "6.39.16",
|
|
51
52
|
"@emotion/react": "^11.13.3",
|
|
52
53
|
"@fortawesome/fontawesome-svg-core": "^7.0.0",
|
|
53
54
|
"@fortawesome/free-regular-svg-icons": "^7.0.0",
|
|
@@ -72,14 +73,14 @@
|
|
|
72
73
|
"@mantine/spotlight": "^8.2.7",
|
|
73
74
|
"@mantine/vanilla-extract": "^8.2.7",
|
|
74
75
|
"@messageformat/date-skeleton": "^1.1.0",
|
|
75
|
-
"@sentry/react": "^10.
|
|
76
|
+
"@sentry/react": "^10.43.0",
|
|
76
77
|
"@tabler/icons-react": "^3.17.0",
|
|
77
78
|
"@tanstack/react-query": "^5.56.2",
|
|
78
|
-
"@uiw/codemirror-theme-vscode": "4.25.
|
|
79
|
+
"@uiw/codemirror-theme-vscode": "4.25.7",
|
|
79
80
|
"@uiw/react-codemirror": "^4.25.7",
|
|
80
81
|
"@uiw/react-split": "^5.9.3",
|
|
81
|
-
"@vanilla-extract/css": "^1.
|
|
82
|
-
"axios": "^1.
|
|
82
|
+
"@vanilla-extract/css": "^1.18.0",
|
|
83
|
+
"axios": "^1.13.6",
|
|
83
84
|
"clsx": "^2.1.1",
|
|
84
85
|
"codemirror": "6.0.2",
|
|
85
86
|
"dayjs": "^1.11.13",
|
|
@@ -91,11 +92,11 @@
|
|
|
91
92
|
"mantine-contextmenu": "^8.2.0",
|
|
92
93
|
"mantine-datatable": "^8.2.0",
|
|
93
94
|
"qrcode": "^1.5.4",
|
|
94
|
-
"react": "^19.
|
|
95
|
-
"react-dom": "^19.
|
|
95
|
+
"react": "^19.2.4",
|
|
96
|
+
"react-dom": "^19.2.4",
|
|
96
97
|
"react-grid-layout": "1.4.4",
|
|
97
98
|
"react-hook-form": "^7.62.0",
|
|
98
|
-
"react-is": "^19.
|
|
99
|
+
"react-is": "^19.2.4",
|
|
99
100
|
"react-router-dom": "^6.26.2",
|
|
100
101
|
"react-select": "^5.9.0",
|
|
101
102
|
"react-simplemde-editor": "^5.2.0",
|
|
@@ -105,35 +106,37 @@
|
|
|
105
106
|
"zustand": "^5.0.8"
|
|
106
107
|
},
|
|
107
108
|
"devDependencies": {
|
|
108
|
-
"@babel/core": "^7.
|
|
109
|
-
"@babel/preset-react": "^7.
|
|
110
|
-
"@babel/preset-typescript": "^7.
|
|
111
|
-
"@babel/runtime": "^7.
|
|
112
|
-
"@codecov/vite-plugin": "^1.9.1",
|
|
109
|
+
"@babel/core": "^7.29.0",
|
|
110
|
+
"@babel/preset-react": "^7.28.5",
|
|
111
|
+
"@babel/preset-typescript": "^7.28.5",
|
|
112
|
+
"@babel/runtime": "^7.28.6",
|
|
113
113
|
"@lingui/babel-plugin-lingui-macro": "^5.9.2",
|
|
114
114
|
"@lingui/cli": "^5.9.2",
|
|
115
115
|
"@lingui/macro": "^5.9.2",
|
|
116
|
-
"@playwright/test": "1.
|
|
117
|
-
"@types/node": "^
|
|
116
|
+
"@playwright/test": "^1.58.2",
|
|
117
|
+
"@types/node": "^25.5.0",
|
|
118
118
|
"@types/qrcode": "^1.5.5",
|
|
119
|
-
"@types/react": "^19.
|
|
120
|
-
"@types/react-dom": "^19.
|
|
119
|
+
"@types/react": "^19.2.14",
|
|
120
|
+
"@types/react-dom": "^19.2.3",
|
|
121
121
|
"@types/react-grid-layout": "^1.3.5",
|
|
122
122
|
"@types/react-router-dom": "^5.3.3",
|
|
123
123
|
"@types/react-window": "^1.8.8",
|
|
124
|
-
"@vanilla-extract/vite-plugin": "^5.1.
|
|
125
|
-
"@vitejs/plugin-react": "^5.0
|
|
124
|
+
"@vanilla-extract/vite-plugin": "^5.1.4",
|
|
125
|
+
"@vitejs/plugin-react": "^5.2.0",
|
|
126
126
|
"babel-plugin-macros": "^3.1.0",
|
|
127
127
|
"nyc": "^18.0.0",
|
|
128
128
|
"otpauth": "^9.4.1",
|
|
129
129
|
"path": "^0.12.7",
|
|
130
|
-
"rollup": "^4.
|
|
131
|
-
"rollup-plugin-license": "^3.
|
|
132
|
-
"typescript": "^5.
|
|
130
|
+
"rollup": "^4.59.0",
|
|
131
|
+
"rollup-plugin-license": "^3.7.0",
|
|
132
|
+
"typescript": "^5.9.3",
|
|
133
133
|
"vite": "7.1.11",
|
|
134
134
|
"vite-plugin-babel-macros": "^1.0.6",
|
|
135
|
-
"vite-plugin-dts": "^4.5.
|
|
135
|
+
"vite-plugin-dts": "^4.5.4",
|
|
136
136
|
"vite-plugin-externals": "^0.6.2",
|
|
137
|
-
"vite-plugin-istanbul": "^
|
|
137
|
+
"vite-plugin-istanbul": "^8.0.0"
|
|
138
|
+
},
|
|
139
|
+
"resolutions": {
|
|
140
|
+
"undici": "^6.24.0"
|
|
138
141
|
}
|
|
139
142
|
}
|