@inventreedb/ui 0.8.0 → 0.8.2
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 +4 -0
- package/dist/hooks/MonitorDataOutput.d.ts +3 -1
- package/dist/hooks/MonitorDataOutput.js +6 -4
- package/dist/hooks/MonitorDataOutput.js.map +1 -1
- package/dist/node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js +3 -0
- package/dist/node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js.map +1 -1
- package/dist/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js +1 -1
- package/dist/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js.map +1 -1
- package/dist/node_modules/@tanstack/react-query/build/modern/useQuery.js +1 -1
- package/dist/node_modules/@tanstack/react-query/build/modern/useQuery.js.map +1 -1
- package/dist/types/Icons.d.ts +2 -2
- package/dist/types/Plugins.js +1 -1
- package/lib/hooks/MonitorDataOutput.tsx +75 -69
- package/lib/types/Icons.tsx +2 -4
- package/package.json +17 -17
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This file contains historical changelog information for the InvenTree UI components library.
|
|
4
4
|
|
|
5
|
+
### 0.8.2 - March 2026
|
|
6
|
+
|
|
7
|
+
Bug fixes for the `monitorDataOutput` hook - https://github.com/inventree/InvenTree/pull/11458
|
|
8
|
+
|
|
5
9
|
### 0.8.0 - March 2026
|
|
6
10
|
|
|
7
11
|
Exposes the `monitorDataOutput` hook, which allows plugins to monitor the output of a long-running task and display notifications when the task is complete. This is useful for plugins that need to perform long-running tasks and want to provide feedback to the user when the task is complete.
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
1
2
|
import { AxiosInstance } from 'axios';
|
|
2
3
|
/**
|
|
3
4
|
* Hook for monitoring a data output process running on the server
|
|
4
5
|
*/
|
|
5
|
-
export default function monitorDataOutput({ api, title, hostname, id }: {
|
|
6
|
+
export default function monitorDataOutput({ api, queryClient, title, hostname, id }: {
|
|
6
7
|
api: AxiosInstance;
|
|
8
|
+
queryClient?: QueryClient;
|
|
7
9
|
title: string;
|
|
8
10
|
hostname?: string;
|
|
9
11
|
id?: number;
|
|
@@ -13,6 +13,7 @@ const useEffect = window["React"].useEffect;
|
|
|
13
13
|
const useState = window["React"].useState;
|
|
14
14
|
function monitorDataOutput({
|
|
15
15
|
api,
|
|
16
|
+
queryClient,
|
|
16
17
|
title,
|
|
17
18
|
hostname,
|
|
18
19
|
id
|
|
@@ -73,7 +74,7 @@ function monitorDataOutput({
|
|
|
73
74
|
});
|
|
74
75
|
if (data.output) {
|
|
75
76
|
const url = data.output;
|
|
76
|
-
const base = hostname ?? window.location.
|
|
77
|
+
const base = hostname ?? window.location.origin;
|
|
77
78
|
const downloadUrl = new URL(url, base);
|
|
78
79
|
window.open(downloadUrl.toString(), "_blank");
|
|
79
80
|
}
|
|
@@ -87,14 +88,15 @@ function monitorDataOutput({
|
|
|
87
88
|
});
|
|
88
89
|
}
|
|
89
90
|
return data;
|
|
90
|
-
}).catch(() => {
|
|
91
|
+
}).catch((error) => {
|
|
92
|
+
console.error("Error in monitorDataOutput:", error);
|
|
91
93
|
setLoading(false);
|
|
92
94
|
notifications.update({
|
|
93
95
|
id: `data-output-${id}`,
|
|
94
96
|
loading: false,
|
|
95
97
|
autoClose: 2500,
|
|
96
98
|
title,
|
|
97
|
-
message: _i18n._(
|
|
99
|
+
message: error.message || _i18n._(
|
|
98
100
|
/*i18n*/
|
|
99
101
|
{
|
|
100
102
|
id: "gzjOvt"
|
|
@@ -104,7 +106,7 @@ function monitorDataOutput({
|
|
|
104
106
|
});
|
|
105
107
|
return {};
|
|
106
108
|
})
|
|
107
|
-
});
|
|
109
|
+
}, queryClient);
|
|
108
110
|
}
|
|
109
111
|
export {
|
|
110
112
|
monitorDataOutput as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MonitorDataOutput.js","sources":["../../lib/hooks/MonitorDataOutput.tsx"],"sourcesContent":["import { t } from '@lingui/core/macro';\nimport { useDocumentVisibility } from '@mantine/hooks';\nimport { notifications, showNotification } from '@mantine/notifications';\nimport { IconCircleCheck, IconExclamationCircle } from '@tabler/icons-react';\nimport { useQuery } from '@tanstack/react-query';\nimport type { AxiosInstance } from 'axios';\nimport { useEffect, useState } from 'react';\nimport { ProgressBar } from '../components/ProgressBar';\nimport { ApiEndpoints } from '../enums/ApiEndpoints';\nimport { apiUrl } from '../functions/Api';\n\n/**\n * Hook for monitoring a data output process running on the server\n */\nexport default function monitorDataOutput({\n api,\n title,\n hostname,\n id\n}: {\n api: AxiosInstance;\n title: string;\n hostname?: string;\n id?: number;\n}) {\n const visibility = useDocumentVisibility();\n\n const [loading, setLoading] = useState<boolean>(false);\n\n useEffect(() => {\n if (!!id) {\n setLoading(true);\n showNotification({\n id: `data-output-${id}`,\n title: title,\n loading: true,\n autoClose: false,\n withCloseButton: false,\n message: <ProgressBar size='lg' value={0} progressLabel />\n });\n } else setLoading(false);\n }, [id, title]);\n\n useQuery({\n
|
|
1
|
+
{"version":3,"file":"MonitorDataOutput.js","sources":["../../lib/hooks/MonitorDataOutput.tsx"],"sourcesContent":["import { t } from '@lingui/core/macro';\nimport { useDocumentVisibility } from '@mantine/hooks';\nimport { notifications, showNotification } from '@mantine/notifications';\nimport { IconCircleCheck, IconExclamationCircle } from '@tabler/icons-react';\nimport { type QueryClient, useQuery } from '@tanstack/react-query';\nimport type { AxiosInstance } from 'axios';\nimport { useEffect, useState } from 'react';\nimport { ProgressBar } from '../components/ProgressBar';\nimport { ApiEndpoints } from '../enums/ApiEndpoints';\nimport { apiUrl } from '../functions/Api';\n\n/**\n * Hook for monitoring a data output process running on the server\n */\nexport default function monitorDataOutput({\n api,\n queryClient,\n title,\n hostname,\n id\n}: {\n api: AxiosInstance;\n queryClient?: QueryClient;\n title: string;\n hostname?: string;\n id?: number;\n}) {\n const visibility = useDocumentVisibility();\n\n const [loading, setLoading] = useState<boolean>(false);\n\n useEffect(() => {\n if (!!id) {\n setLoading(true);\n showNotification({\n id: `data-output-${id}`,\n title: title,\n loading: true,\n autoClose: false,\n withCloseButton: false,\n message: <ProgressBar size='lg' value={0} progressLabel />\n });\n } else setLoading(false);\n }, [id, title]);\n\n useQuery(\n {\n enabled: !!id && loading && visibility === 'visible',\n refetchInterval: 500,\n queryKey: ['data-output', id, title],\n queryFn: () =>\n api\n .get(apiUrl(ApiEndpoints.data_output, id))\n .then((response) => {\n const data = response?.data ?? {};\n\n if (!!data.errors || !!data.error) {\n setLoading(false);\n\n const error: string =\n data?.error ?? data?.errors?.error ?? t`Process failed`;\n\n notifications.update({\n id: `data-output-${id}`,\n loading: false,\n icon: <IconExclamationCircle />,\n autoClose: 2500,\n title: title,\n message: error,\n color: 'red'\n });\n } else if (data.complete) {\n setLoading(false);\n notifications.update({\n id: `data-output-${id}`,\n loading: false,\n autoClose: 2500,\n title: title,\n message: t`Process completed successfully`,\n color: 'green',\n icon: <IconCircleCheck />\n });\n\n if (data.output) {\n const url = data.output;\n const base = hostname ?? window.location.origin;\n\n const downloadUrl = new URL(url, base);\n\n window.open(downloadUrl.toString(), '_blank');\n }\n } else {\n notifications.update({\n id: `data-output-${id}`,\n loading: true,\n autoClose: false,\n withCloseButton: false,\n message: (\n <ProgressBar\n size='lg'\n maximum={data.total}\n value={data.progress}\n progressLabel={data.total > 0}\n animated\n />\n )\n });\n }\n\n return data;\n })\n .catch((error: Error) => {\n console.error('Error in monitorDataOutput:', error);\n setLoading(false);\n notifications.update({\n id: `data-output-${id}`,\n loading: false,\n autoClose: 2500,\n title: title,\n message: error.message || t`Process failed`,\n color: 'red'\n });\n return {};\n })\n },\n queryClient\n );\n}\n"],"names":["monitorDataOutput","api","queryClient","title","hostname","id","visibility","useDocumentVisibility","loading","setLoading","useState","useEffect","showNotification","autoClose","withCloseButton","message","useQuery","enabled","refetchInterval","queryKey","queryFn","get","apiUrl","ApiEndpoints","data_output","then","response","data","errors","error","_i18n","_","notifications","update","icon","color","complete","output","url","base","window","location","origin","downloadUrl","URL","open","toString","jsx","total","progress","catch","console"],"mappings":";;;;;;;;AAAA,MAAA,QAAA,OAAA,YAAA,EAAA;AAEA,MAAA,gBAAA,OAAA,sBAAA,EAAA;;AAIA,MAAA,YAAA,OAAA,OAAA,EAAA;;AAQA,SAAwBA,kBAAkB;AAAA,EACxCC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAOF,GAAG;AACD,QAAMC,aAAaC,sBAAAA;AAEnB,QAAM,CAACC,SAASC,UAAU,IAAIC,SAAkB,KAAK;AAErDC,YAAU,MAAM;AACd,QAAI,CAAC,CAACN,IAAI;AACRI,iBAAW,IAAI;AACfG,uBAAiB;AAAA,QACfP,IAAI,eAAeA,EAAE;AAAA,QACrBF;AAAAA,QACAK,SAAS;AAAA,QACTK,WAAW;AAAA,QACXC,iBAAiB;AAAA,QACjBC,+CAAU,aAAA,EAAY,MAAK,MAAK,OAAO,GAAG,eAAa,KAAA,CAAA;AAAA,MAAA,CACxD;AAAA,IACH,kBAAkB,KAAK;AAAA,EACzB,GAAG,CAACV,IAAIF,KAAK,CAAC;AAEda,WACE;AAAA,IACEC,SAAS,CAAC,CAACZ,MAAMG,WAAWF,eAAe;AAAA,IAC3CY,iBAAiB;AAAA,IACjBC,UAAU,CAAC,eAAed,IAAIF,KAAK;AAAA,IACnCiB,SAASA,MACPnB,IACGoB,IAAIC,OAAOC,aAAaC,aAAanB,EAAE,CAAC,EACxCoB,KAAMC,CAAAA,aAAa;AAClB,YAAMC,OAAOD,UAAUC,QAAQ,CAAA;AAE/B,UAAI,CAAC,CAACA,KAAKC,UAAU,CAAC,CAACD,KAAKE,OAAO;AACjCpB,mBAAW,KAAK;AAEhB,cAAMoB,QACJF,MAAME,SAASF,MAAMC,QAAQC,SAAKC,MAAAC;AAAAA;AAAAA,UAAI;AAAA,YAAA1B,IAAA;AAAA,UA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A,EAAE;AAAA,QACrBG,SAAS;AAAA,QACTK,WAAW;AAAA,QACXV;AAAAA,QACAY,SAASc,MAAMd,WAAOe,MAAAC;AAAAA;AAAAA,UAAI;AAAA,YAAA1B,IAAA;AAAA,UAAA;AAAA,QAAgB;AAAA,QAC1C8B,OAAO;AAAA,MAAA,CACR;AACD,aAAO,CAAA;AAAA,IACT,CAAC;AAAA,EAAA,GAEPjC,WACF;AACF;"}
|
|
@@ -5,6 +5,9 @@ var QueryClientContext = React.createContext(
|
|
|
5
5
|
);
|
|
6
6
|
var useQueryClient = (queryClient) => {
|
|
7
7
|
const client = React.useContext(QueryClientContext);
|
|
8
|
+
if (queryClient) {
|
|
9
|
+
return queryClient;
|
|
10
|
+
}
|
|
8
11
|
if (!client) {
|
|
9
12
|
throw new Error("No QueryClient set, use QueryClientProvider to set one");
|
|
10
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryClientProvider.js","sources":["../../../../../../node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js"],"sourcesContent":["\"use client\";\n\n// src/QueryClientProvider.tsx\nimport * as React from \"react\";\nimport { jsx } from \"react/jsx-runtime\";\nvar QueryClientContext = React.createContext(\n void 0\n);\nvar useQueryClient = (queryClient) => {\n const client = React.useContext(QueryClientContext);\n if (queryClient) {\n return queryClient;\n }\n if (!client) {\n throw new Error(\"No QueryClient set, use QueryClientProvider to set one\");\n }\n return client;\n};\nvar QueryClientProvider = ({\n client,\n children\n}) => {\n React.useEffect(() => {\n client.mount();\n return () => {\n client.unmount();\n };\n }, [client]);\n return /* @__PURE__ */ jsx(QueryClientContext.Provider, { value: client, children });\n};\nexport {\n QueryClientContext,\n QueryClientProvider,\n useQueryClient\n};\n//# sourceMappingURL=QueryClientProvider.js.map"],"names":[],"mappings":";AAGA,MAAA,QAAA,OAAA,OAAA;AAEG,IAAC,qBAAqB,MAAM;AAAA,EAC7B;AACF;AACG,IAAC,iBAAiB,CAAC,gBAAgB;AACpC,QAAM,SAAS,MAAM,WAAW,kBAAkB;
|
|
1
|
+
{"version":3,"file":"QueryClientProvider.js","sources":["../../../../../../node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js"],"sourcesContent":["\"use client\";\n\n// src/QueryClientProvider.tsx\nimport * as React from \"react\";\nimport { jsx } from \"react/jsx-runtime\";\nvar QueryClientContext = React.createContext(\n void 0\n);\nvar useQueryClient = (queryClient) => {\n const client = React.useContext(QueryClientContext);\n if (queryClient) {\n return queryClient;\n }\n if (!client) {\n throw new Error(\"No QueryClient set, use QueryClientProvider to set one\");\n }\n return client;\n};\nvar QueryClientProvider = ({\n client,\n children\n}) => {\n React.useEffect(() => {\n client.mount();\n return () => {\n client.unmount();\n };\n }, [client]);\n return /* @__PURE__ */ jsx(QueryClientContext.Provider, { value: client, children });\n};\nexport {\n QueryClientContext,\n QueryClientProvider,\n useQueryClient\n};\n//# sourceMappingURL=QueryClientProvider.js.map"],"names":[],"mappings":";AAGA,MAAA,QAAA,OAAA,OAAA;AAEG,IAAC,qBAAqB,MAAM;AAAA,EAC7B;AACF;AACG,IAAC,iBAAiB,CAAC,gBAAgB;AACpC,QAAM,SAAS,MAAM,WAAW,kBAAkB;AAClD,MAAI,aAAa;AACf,WAAO;AAAA,EACT;AACA,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,wDAAwD;AAAA,EAC1E;AACA,SAAO;AACT;","x_google_ignoreList":[0]}
|
|
@@ -16,7 +16,7 @@ function useBaseQuery(options, Observer, queryClient) {
|
|
|
16
16
|
}
|
|
17
17
|
const isRestoring = useIsRestoring();
|
|
18
18
|
const errorResetBoundary = useQueryErrorResetBoundary();
|
|
19
|
-
const client = useQueryClient();
|
|
19
|
+
const client = useQueryClient(queryClient);
|
|
20
20
|
const defaultedOptions = client.defaultQueryOptions(options);
|
|
21
21
|
client.getDefaultOptions().queries?._experimental_beforeQuery?.(
|
|
22
22
|
defaultedOptions
|
|
@@ -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: client.getQueryCache().get(defaultedOptions.queryHash),\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 client.getQueryCache().get(defaultedOptions.queryHash)?.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,
|
|
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: client.getQueryCache().get(defaultedOptions.queryHash),\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 client.getQueryCache().get(defaultedOptions.queryHash)?.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,G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EACtE;AACA,MAAI,YAAY;AAAA,IACd;AAAA,IACA;AAAA,IACA,cAAc,iBAAiB;AAAA,IAC/B,OAAO,OAAO,cAAa,EAAG,IAAI,iBAAiB,SAAS;AAAA,IAC5D,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,cAAa,EAAG,IAAI,iBAAiB,SAAS,GAAG;AAAA;AAE1D,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]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { QueryObserver } from "../../../query-core/build/modern/queryObserver.js";
|
|
2
2
|
import { useBaseQuery } from "./useBaseQuery.js";
|
|
3
3
|
function useQuery(options, queryClient) {
|
|
4
|
-
return useBaseQuery(options, QueryObserver);
|
|
4
|
+
return useBaseQuery(options, QueryObserver, queryClient);
|
|
5
5
|
}
|
|
6
6
|
export {
|
|
7
7
|
useQuery
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQuery.js","sources":["../../../../../../node_modules/@tanstack/react-query/build/modern/useQuery.js"],"sourcesContent":["\"use client\";\n\n// src/useQuery.ts\nimport { QueryObserver } from \"@tanstack/query-core\";\nimport { useBaseQuery } from \"./useBaseQuery.js\";\nfunction useQuery(options, queryClient) {\n return useBaseQuery(options, QueryObserver, queryClient);\n}\nexport {\n useQuery\n};\n//# sourceMappingURL=useQuery.js.map"],"names":[],"mappings":";;AAKA,SAAS,SAAS,SAAS,aAAa;AACtC,SAAO,aAAa,SAAS,
|
|
1
|
+
{"version":3,"file":"useQuery.js","sources":["../../../../../../node_modules/@tanstack/react-query/build/modern/useQuery.js"],"sourcesContent":["\"use client\";\n\n// src/useQuery.ts\nimport { QueryObserver } from \"@tanstack/query-core\";\nimport { useBaseQuery } from \"./useBaseQuery.js\";\nfunction useQuery(options, queryClient) {\n return useBaseQuery(options, QueryObserver, queryClient);\n}\nexport {\n useQuery\n};\n//# sourceMappingURL=useQuery.js.map"],"names":[],"mappings":";;AAKA,SAAS,SAAS,SAAS,aAAa;AACtC,SAAO,aAAa,SAAS,eAAe,WAAW;AACzD;","x_google_ignoreList":[0]}
|
package/dist/types/Icons.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type TablerIconType =
|
|
1
|
+
import { IconCircle } from '@tabler/icons-react';
|
|
2
|
+
export type TablerIconType = typeof IconCircle;
|
|
3
3
|
export type InvenTreeIconType = {
|
|
4
4
|
[key: string]: TablerIconType;
|
|
5
5
|
};
|
package/dist/types/Plugins.js
CHANGED
|
@@ -2,7 +2,7 @@ import { t } from '@lingui/core/macro';
|
|
|
2
2
|
import { useDocumentVisibility } from '@mantine/hooks';
|
|
3
3
|
import { notifications, showNotification } from '@mantine/notifications';
|
|
4
4
|
import { IconCircleCheck, IconExclamationCircle } from '@tabler/icons-react';
|
|
5
|
-
import { useQuery } from '@tanstack/react-query';
|
|
5
|
+
import { type QueryClient, useQuery } from '@tanstack/react-query';
|
|
6
6
|
import type { AxiosInstance } from 'axios';
|
|
7
7
|
import { useEffect, useState } from 'react';
|
|
8
8
|
import { ProgressBar } from '../components/ProgressBar';
|
|
@@ -14,11 +14,13 @@ import { apiUrl } from '../functions/Api';
|
|
|
14
14
|
*/
|
|
15
15
|
export default function monitorDataOutput({
|
|
16
16
|
api,
|
|
17
|
+
queryClient,
|
|
17
18
|
title,
|
|
18
19
|
hostname,
|
|
19
20
|
id
|
|
20
21
|
}: {
|
|
21
22
|
api: AxiosInstance;
|
|
23
|
+
queryClient?: QueryClient;
|
|
22
24
|
title: string;
|
|
23
25
|
hostname?: string;
|
|
24
26
|
id?: number;
|
|
@@ -41,82 +43,86 @@ export default function monitorDataOutput({
|
|
|
41
43
|
} else setLoading(false);
|
|
42
44
|
}, [id, title]);
|
|
43
45
|
|
|
44
|
-
useQuery(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
useQuery(
|
|
47
|
+
{
|
|
48
|
+
enabled: !!id && loading && visibility === 'visible',
|
|
49
|
+
refetchInterval: 500,
|
|
50
|
+
queryKey: ['data-output', id, title],
|
|
51
|
+
queryFn: () =>
|
|
52
|
+
api
|
|
53
|
+
.get(apiUrl(ApiEndpoints.data_output, id))
|
|
54
|
+
.then((response) => {
|
|
55
|
+
const data = response?.data ?? {};
|
|
53
56
|
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
if (!!data.errors || !!data.error) {
|
|
58
|
+
setLoading(false);
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
const error: string =
|
|
61
|
+
data?.error ?? data?.errors?.error ?? t`Process failed`;
|
|
59
62
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
63
|
+
notifications.update({
|
|
64
|
+
id: `data-output-${id}`,
|
|
65
|
+
loading: false,
|
|
66
|
+
icon: <IconExclamationCircle />,
|
|
67
|
+
autoClose: 2500,
|
|
68
|
+
title: title,
|
|
69
|
+
message: error,
|
|
70
|
+
color: 'red'
|
|
71
|
+
});
|
|
72
|
+
} else if (data.complete) {
|
|
73
|
+
setLoading(false);
|
|
74
|
+
notifications.update({
|
|
75
|
+
id: `data-output-${id}`,
|
|
76
|
+
loading: false,
|
|
77
|
+
autoClose: 2500,
|
|
78
|
+
title: title,
|
|
79
|
+
message: t`Process completed successfully`,
|
|
80
|
+
color: 'green',
|
|
81
|
+
icon: <IconCircleCheck />
|
|
82
|
+
});
|
|
80
83
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
if (data.output) {
|
|
85
|
+
const url = data.output;
|
|
86
|
+
const base = hostname ?? window.location.origin;
|
|
84
87
|
|
|
85
|
-
|
|
88
|
+
const downloadUrl = new URL(url, base);
|
|
86
89
|
|
|
87
|
-
|
|
90
|
+
window.open(downloadUrl.toString(), '_blank');
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
notifications.update({
|
|
94
|
+
id: `data-output-${id}`,
|
|
95
|
+
loading: true,
|
|
96
|
+
autoClose: false,
|
|
97
|
+
withCloseButton: false,
|
|
98
|
+
message: (
|
|
99
|
+
<ProgressBar
|
|
100
|
+
size='lg'
|
|
101
|
+
maximum={data.total}
|
|
102
|
+
value={data.progress}
|
|
103
|
+
progressLabel={data.total > 0}
|
|
104
|
+
animated
|
|
105
|
+
/>
|
|
106
|
+
)
|
|
107
|
+
});
|
|
88
108
|
}
|
|
89
|
-
|
|
109
|
+
|
|
110
|
+
return data;
|
|
111
|
+
})
|
|
112
|
+
.catch((error: Error) => {
|
|
113
|
+
console.error('Error in monitorDataOutput:', error);
|
|
114
|
+
setLoading(false);
|
|
90
115
|
notifications.update({
|
|
91
116
|
id: `data-output-${id}`,
|
|
92
|
-
loading:
|
|
93
|
-
autoClose:
|
|
94
|
-
|
|
95
|
-
message:
|
|
96
|
-
|
|
97
|
-
size='lg'
|
|
98
|
-
maximum={data.total}
|
|
99
|
-
value={data.progress}
|
|
100
|
-
progressLabel={data.total > 0}
|
|
101
|
-
animated
|
|
102
|
-
/>
|
|
103
|
-
)
|
|
117
|
+
loading: false,
|
|
118
|
+
autoClose: 2500,
|
|
119
|
+
title: title,
|
|
120
|
+
message: error.message || t`Process failed`,
|
|
121
|
+
color: 'red'
|
|
104
122
|
});
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
setLoading(false);
|
|
111
|
-
notifications.update({
|
|
112
|
-
id: `data-output-${id}`,
|
|
113
|
-
loading: false,
|
|
114
|
-
autoClose: 2500,
|
|
115
|
-
title: title,
|
|
116
|
-
message: t`Process failed`,
|
|
117
|
-
color: 'red'
|
|
118
|
-
});
|
|
119
|
-
return {};
|
|
120
|
-
})
|
|
121
|
-
});
|
|
123
|
+
return {};
|
|
124
|
+
})
|
|
125
|
+
},
|
|
126
|
+
queryClient
|
|
127
|
+
);
|
|
122
128
|
}
|
package/lib/types/Icons.tsx
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IconCircle } from '@tabler/icons-react';
|
|
2
2
|
|
|
3
|
-
export type TablerIconType =
|
|
4
|
-
Omit<IconProps, 'ref'> & React.RefAttributes<Icon>
|
|
5
|
-
>;
|
|
3
|
+
export type TablerIconType = typeof IconCircle;
|
|
6
4
|
|
|
7
5
|
export type InvenTreeIconType = {
|
|
8
6
|
[key: string]: TablerIconType;
|
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.8.
|
|
4
|
+
"version": "0.8.2",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
"compile": "lingui compile --typescript"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@codemirror/autocomplete": "6.
|
|
44
|
-
"@codemirror/lang-liquid": "6.3.
|
|
45
|
-
"@codemirror/language": "6.
|
|
46
|
-
"@codemirror/lint": "6.
|
|
47
|
-
"@codemirror/search": "6.
|
|
48
|
-
"@codemirror/state": "6.5.
|
|
49
|
-
"@codemirror/theme-one-dark": "6.1.3",
|
|
43
|
+
"@codemirror/autocomplete": "^6.20.1",
|
|
44
|
+
"@codemirror/lang-liquid": "^6.3.2",
|
|
45
|
+
"@codemirror/language": "^6.12.2",
|
|
46
|
+
"@codemirror/lint": "^6.9.5",
|
|
47
|
+
"@codemirror/search": "^6.6.0",
|
|
48
|
+
"@codemirror/state": "^6.5.4",
|
|
49
|
+
"@codemirror/theme-one-dark": "^6.1.3",
|
|
50
50
|
"@codemirror/view": "6.38.2",
|
|
51
51
|
"@emotion/react": "^11.13.3",
|
|
52
52
|
"@fortawesome/fontawesome-svg-core": "^7.0.0",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"@fullcalendar/interaction": "^6.1.15",
|
|
59
59
|
"@fullcalendar/react": "^6.1.15",
|
|
60
60
|
"@github/webauthn-json": "^2.1.1",
|
|
61
|
-
"@lingui/core": "^5.
|
|
62
|
-
"@lingui/react": "^5.
|
|
61
|
+
"@lingui/core": "^5.9.2",
|
|
62
|
+
"@lingui/react": "^5.9.2",
|
|
63
63
|
"@mantine/carousel": "^8.2.7",
|
|
64
64
|
"@mantine/charts": "^8.2.7",
|
|
65
65
|
"@mantine/core": "^8.2.7",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"@tabler/icons-react": "^3.17.0",
|
|
77
77
|
"@tanstack/react-query": "^5.56.2",
|
|
78
78
|
"@uiw/codemirror-theme-vscode": "4.25.1",
|
|
79
|
-
"@uiw/react-codemirror": "4.25.
|
|
79
|
+
"@uiw/react-codemirror": "^4.25.7",
|
|
80
80
|
"@uiw/react-split": "^5.9.3",
|
|
81
81
|
"@vanilla-extract/css": "^1.17.1",
|
|
82
82
|
"axios": "^1.8.4",
|
|
@@ -109,10 +109,10 @@
|
|
|
109
109
|
"@babel/preset-react": "^7.26.3",
|
|
110
110
|
"@babel/preset-typescript": "^7.27.0",
|
|
111
111
|
"@babel/runtime": "^7.27.0",
|
|
112
|
-
"@codecov/vite-plugin": "^1.9.
|
|
113
|
-
"@lingui/babel-plugin-lingui-macro": "^5.
|
|
114
|
-
"@lingui/cli": "^5.
|
|
115
|
-
"@lingui/macro": "^5.
|
|
112
|
+
"@codecov/vite-plugin": "^1.9.1",
|
|
113
|
+
"@lingui/babel-plugin-lingui-macro": "^5.9.2",
|
|
114
|
+
"@lingui/cli": "^5.9.2",
|
|
115
|
+
"@lingui/macro": "^5.9.2",
|
|
116
116
|
"@playwright/test": "1.56.0",
|
|
117
117
|
"@types/node": "^24.3.0",
|
|
118
118
|
"@types/qrcode": "^1.5.5",
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
"@vanilla-extract/vite-plugin": "^5.1.1",
|
|
125
125
|
"@vitejs/plugin-react": "^5.0.2",
|
|
126
126
|
"babel-plugin-macros": "^3.1.0",
|
|
127
|
-
"nyc": "^
|
|
127
|
+
"nyc": "^18.0.0",
|
|
128
128
|
"otpauth": "^9.4.1",
|
|
129
129
|
"path": "^0.12.7",
|
|
130
130
|
"rollup": "^4.0.0",
|
|
@@ -134,6 +134,6 @@
|
|
|
134
134
|
"vite-plugin-babel-macros": "^1.0.6",
|
|
135
135
|
"vite-plugin-dts": "^4.5.3",
|
|
136
136
|
"vite-plugin-externals": "^0.6.2",
|
|
137
|
-
"vite-plugin-istanbul": "^
|
|
137
|
+
"vite-plugin-istanbul": "^7.2.1"
|
|
138
138
|
}
|
|
139
139
|
}
|