@scm-manager/ui-components 4.0.0-REACT19-20251104-141645 → 4.0.0-REACT19-20251104-145242
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/package.json +6 -6
- package/src/ErrorBoundary.tsx +40 -39
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scm-manager/ui-components",
|
|
3
|
-
"version": "4.0.0-REACT19-20251104-
|
|
3
|
+
"version": "4.0.0-REACT19-20251104-145242",
|
|
4
4
|
"description": "UI Components for SCM-Manager and its plugins",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"files": [
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"@scm-manager/eslint-config": "^2.18.2",
|
|
35
35
|
"@scm-manager/prettier-config": "^2.12.0",
|
|
36
36
|
"@scm-manager/tsconfig": "^2.13.0",
|
|
37
|
-
"@scm-manager/ui-syntaxhighlighting": "4.0.0-REACT19-20251104-
|
|
38
|
-
"@scm-manager/ui-types": "4.0.0-REACT19-20251104-
|
|
37
|
+
"@scm-manager/ui-syntaxhighlighting": "4.0.0-REACT19-20251104-145242",
|
|
38
|
+
"@scm-manager/ui-types": "4.0.0-REACT19-20251104-145242",
|
|
39
39
|
"@storybook/addon-actions": "^9.0.8",
|
|
40
40
|
"@storybook/addon-docs": "^9.1.5",
|
|
41
41
|
"@storybook/addon-essentials": "^9.0.0-alpha.12",
|
|
@@ -66,9 +66,9 @@
|
|
|
66
66
|
"vitest": "^3.2.4"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@scm-manager/ui-api": "4.0.0-REACT19-20251104-
|
|
70
|
-
"@scm-manager/ui-core": "4.0.0-REACT19-20251104-
|
|
71
|
-
"@scm-manager/ui-extensions": "4.0.0-REACT19-20251104-
|
|
69
|
+
"@scm-manager/ui-api": "4.0.0-REACT19-20251104-145242",
|
|
70
|
+
"@scm-manager/ui-core": "4.0.0-REACT19-20251104-145242",
|
|
71
|
+
"@scm-manager/ui-extensions": "4.0.0-REACT19-20251104-145242",
|
|
72
72
|
"deepmerge": "^4.2.2",
|
|
73
73
|
"hast-util-sanitize": "^3.0.2",
|
|
74
74
|
"react-diff-view": "2.6.0",
|
package/src/ErrorBoundary.tsx
CHANGED
|
@@ -15,26 +15,34 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import React, { FC, ReactNode, useEffect } from "react";
|
|
18
|
-
import {
|
|
18
|
+
import { useLocation } from "react-router-dom";
|
|
19
19
|
import { useTranslation } from "react-i18next";
|
|
20
20
|
import classNames from "classnames";
|
|
21
21
|
import styled from "styled-components";
|
|
22
22
|
import { MissingLinkError, urls, useIndexLink } from "@scm-manager/ui-api";
|
|
23
|
-
import { ErrorBoundary as ReactErrorBoundary } from "react-error-boundary";
|
|
23
|
+
import { ErrorBoundary as ReactErrorBoundary, FallbackProps } from "react-error-boundary";
|
|
24
24
|
import { useDocumentTitle } from "@scm-manager/ui-core";
|
|
25
25
|
import ErrorNotification from "./ErrorNotification";
|
|
26
26
|
import ErrorPage from "./ErrorPage";
|
|
27
27
|
import { Subtitle, Title } from "./layout";
|
|
28
28
|
import Icon from "./Icon";
|
|
29
29
|
|
|
30
|
-
type
|
|
30
|
+
type ErrorState = {
|
|
31
31
|
error: Error;
|
|
32
|
-
errorInfo?: { componentStack?: string }; // Optional gemacht
|
|
33
|
-
fallback?: React.ComponentType<{ error: Error }>;
|
|
34
32
|
};
|
|
35
33
|
|
|
36
|
-
type
|
|
37
|
-
fallback?: React.ComponentType<
|
|
34
|
+
type ExportedProps = {
|
|
35
|
+
fallback?: React.ComponentType<ErrorState>;
|
|
36
|
+
children?: ReactNode;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
type ErrorDisplayProps = {
|
|
40
|
+
error: Error;
|
|
41
|
+
// react-error-boundary does not pass errorInfo to the fallback component by default
|
|
42
|
+
// for performance reasons, but it can be logged via the `onError` prop.
|
|
43
|
+
// We keep it in the signature for compatibility with the custom fallback prop.
|
|
44
|
+
errorInfo?: { componentStack: string };
|
|
45
|
+
fallback?: React.ComponentType<ErrorState>;
|
|
38
46
|
};
|
|
39
47
|
|
|
40
48
|
const RedirectIconContainer = styled.div`
|
|
@@ -44,7 +52,6 @@ const RedirectIconContainer = styled.div`
|
|
|
44
52
|
const RedirectPage: FC = () => {
|
|
45
53
|
const [t] = useTranslation("commons");
|
|
46
54
|
useDocumentTitle(t("errorNotification.prefix"));
|
|
47
|
-
|
|
48
55
|
return (
|
|
49
56
|
<section className="section">
|
|
50
57
|
<div className="container">
|
|
@@ -65,7 +72,7 @@ const RedirectPage: FC = () => {
|
|
|
65
72
|
);
|
|
66
73
|
};
|
|
67
74
|
|
|
68
|
-
const ErrorDisplay: FC<ErrorDisplayProps> = ({ error, fallback: FallbackComponent }) => {
|
|
75
|
+
const ErrorDisplay: FC<ErrorDisplayProps> = ({ error, errorInfo, fallback: FallbackComponent }) => {
|
|
69
76
|
const loginLink = useIndexLink("login");
|
|
70
77
|
const [t] = useTranslation("commons");
|
|
71
78
|
const location = useLocation();
|
|
@@ -80,47 +87,41 @@ const ErrorDisplay: FC<ErrorDisplayProps> = ({ error, fallback: FallbackComponen
|
|
|
80
87
|
if (isMissingLink) {
|
|
81
88
|
if (loginLink) {
|
|
82
89
|
return <RedirectPage />;
|
|
83
|
-
} else {
|
|
84
|
-
return (
|
|
85
|
-
<ErrorPage error={error} title={t("errorNotification.prefix")} subtitle={t("errorNotification.forbidden")} />
|
|
86
|
-
);
|
|
87
90
|
}
|
|
91
|
+
return (
|
|
92
|
+
<ErrorPage error={error} title={t("errorNotification.prefix")} subtitle={t("errorNotification.forbidden")} />
|
|
93
|
+
);
|
|
88
94
|
}
|
|
89
95
|
|
|
96
|
+
const fallbackProps = {
|
|
97
|
+
error,
|
|
98
|
+
errorInfo,
|
|
99
|
+
};
|
|
100
|
+
|
|
90
101
|
if (FallbackComponent) {
|
|
91
|
-
return <FallbackComponent
|
|
102
|
+
return <FallbackComponent {...fallbackProps} />;
|
|
92
103
|
}
|
|
93
|
-
|
|
94
104
|
return <ErrorNotification error={error} />;
|
|
95
105
|
};
|
|
96
106
|
|
|
97
|
-
const ErrorBoundary: FC<
|
|
98
|
-
const rawError = useRouteError();
|
|
107
|
+
const ErrorBoundary: FC<ExportedProps> = ({ children, fallback }) => {
|
|
99
108
|
const location = useLocation();
|
|
100
109
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
let error: Error;
|
|
114
|
-
|
|
115
|
-
if (isRouteErrorResponse(rawError)) {
|
|
116
|
-
error = new Error(`${rawError.status} ${rawError.statusText}`);
|
|
117
|
-
} else if (rawError instanceof Error) {
|
|
118
|
-
error = rawError;
|
|
119
|
-
} else {
|
|
120
|
-
error = new Error(rawError ? String(rawError) : "Unknown Error");
|
|
121
|
-
}
|
|
110
|
+
const ErrorBoundaryFallback = ({ error }: FallbackProps) => (
|
|
111
|
+
<ErrorDisplay
|
|
112
|
+
error={error}
|
|
113
|
+
// For compatibility with potential custom fallbacks that expect errorInfo.
|
|
114
|
+
// The actual component stack is available in the `onError` callback below.
|
|
115
|
+
errorInfo={{ componentStack: "" }}
|
|
116
|
+
fallback={fallback}
|
|
117
|
+
/>
|
|
118
|
+
);
|
|
122
119
|
|
|
123
|
-
return
|
|
120
|
+
return (
|
|
121
|
+
<ReactErrorBoundary resetKeys={[location.pathname]} FallbackComponent={ErrorBoundaryFallback}>
|
|
122
|
+
{children}
|
|
123
|
+
</ReactErrorBoundary>
|
|
124
|
+
);
|
|
124
125
|
};
|
|
125
126
|
|
|
126
127
|
export default ErrorBoundary;
|