@inventreedb/ui 0.8.1 → 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.js +4 -3
- package/dist/hooks/MonitorDataOutput.js.map +1 -1
- package/dist/types/Icons.d.ts +2 -2
- package/dist/types/Plugins.js +1 -1
- package/lib/hooks/MonitorDataOutput.tsx +4 -3
- 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.
|
|
@@ -74,7 +74,7 @@ function monitorDataOutput({
|
|
|
74
74
|
});
|
|
75
75
|
if (data.output) {
|
|
76
76
|
const url = data.output;
|
|
77
|
-
const base = hostname ?? window.location.
|
|
77
|
+
const base = hostname ?? window.location.origin;
|
|
78
78
|
const downloadUrl = new URL(url, base);
|
|
79
79
|
window.open(downloadUrl.toString(), "_blank");
|
|
80
80
|
}
|
|
@@ -88,14 +88,15 @@ function monitorDataOutput({
|
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
return data;
|
|
91
|
-
}).catch(() => {
|
|
91
|
+
}).catch((error) => {
|
|
92
|
+
console.error("Error in monitorDataOutput:", error);
|
|
92
93
|
setLoading(false);
|
|
93
94
|
notifications.update({
|
|
94
95
|
id: `data-output-${id}`,
|
|
95
96
|
loading: false,
|
|
96
97
|
autoClose: 2500,
|
|
97
98
|
title,
|
|
98
|
-
message: _i18n._(
|
|
99
|
+
message: error.message || _i18n._(
|
|
99
100
|
/*i18n*/
|
|
100
101
|
{
|
|
101
102
|
id: "gzjOvt"
|
|
@@ -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 { 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.
|
|
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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,CACvB;AAED,YAAIP,KAAKU,QAAQ;AACf,gBAAMC,MAAMX,KAAKU;AACjB,gBAAME,OAAOnC,YAAYoC,OAAOC,SAASC;AAEzC,gBAAMC,cAAc,IAAIC,IAAIN,KAAKC,IAAI;AAErCC,iBAAOK,KAAKF,YAAYG,SAAAA,GAAY,QAAQ;AAAA,QAC9C;AAAA,MACF,OAAO;AACLd,sBAAcC,OAAO;AAAA,UACnB5B,IAAI,eAAeA,EAAE;AAAA,UACrBG,SAAS;AAAA,UACTK,WAAW;AAAA,UACXC,iBAAiB;AAAA,UACjBC,SACEgC,kCAAAA,IAAC,aAAA,EACC,MAAK,MACL,SAASpB,KAAKqB,OACd,OAAOrB,KAAKsB,UACZ,eAAetB,KAAKqB,QAAQ,GAC5B,UAAQ,KAAA,CAAA;AAAA,QAAA,CAGb;AAAA,MACH;AAEA,aAAOrB;AAAAA,IACT,CAAC,EACAuB,MAAM,CAACrB,UAAiB;AACvBsB,cAAQtB,MAAM,+BAA+BA,KAAK;AAClDpB,iBAAW,KAAK;AAChBuB,oBAAcC,OAAO;AAAA,QACnB5B,IAAI,eAAeA,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;"}
|
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
|
@@ -83,7 +83,7 @@ export default function monitorDataOutput({
|
|
|
83
83
|
|
|
84
84
|
if (data.output) {
|
|
85
85
|
const url = data.output;
|
|
86
|
-
const base = hostname ?? window.location.
|
|
86
|
+
const base = hostname ?? window.location.origin;
|
|
87
87
|
|
|
88
88
|
const downloadUrl = new URL(url, base);
|
|
89
89
|
|
|
@@ -109,14 +109,15 @@ export default function monitorDataOutput({
|
|
|
109
109
|
|
|
110
110
|
return data;
|
|
111
111
|
})
|
|
112
|
-
.catch(() => {
|
|
112
|
+
.catch((error: Error) => {
|
|
113
|
+
console.error('Error in monitorDataOutput:', error);
|
|
113
114
|
setLoading(false);
|
|
114
115
|
notifications.update({
|
|
115
116
|
id: `data-output-${id}`,
|
|
116
117
|
loading: false,
|
|
117
118
|
autoClose: 2500,
|
|
118
119
|
title: title,
|
|
119
|
-
message: t`Process failed`,
|
|
120
|
+
message: error.message || t`Process failed`,
|
|
120
121
|
color: 'red'
|
|
121
122
|
});
|
|
122
123
|
return {};
|
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
|
}
|