@scm-manager/ui-components 3.6.1 → 3.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scm-manager/ui-components",
3
- "version": "3.6.1",
3
+ "version": "3.7.0",
4
4
  "description": "UI Components for SCM-Manager and its plugins",
5
5
  "main": "src/index.ts",
6
6
  "files": [
@@ -32,8 +32,8 @@
32
32
  "react-query": "^3.39.2"
33
33
  },
34
34
  "devDependencies": {
35
- "@scm-manager/ui-tests": "3.6.1",
36
- "@scm-manager/ui-types": "3.6.1",
35
+ "@scm-manager/ui-tests": "3.7.0",
36
+ "@scm-manager/ui-types": "3.7.0",
37
37
  "@types/fetch-mock": "^7.3.1",
38
38
  "@types/react-select": "^2.0.19",
39
39
  "@types/unist": "^2.0.3",
@@ -67,17 +67,17 @@
67
67
  "@scm-manager/jest-preset": "^2.14.1",
68
68
  "@scm-manager/prettier-config": "^2.12.0",
69
69
  "@scm-manager/tsconfig": "^2.13.0",
70
- "@scm-manager/ui-syntaxhighlighting": "3.6.1",
71
- "@scm-manager/ui-shortcuts": "3.6.1",
72
- "@scm-manager/ui-text": "3.6.1"
70
+ "@scm-manager/ui-syntaxhighlighting": "3.7.0",
71
+ "@scm-manager/ui-shortcuts": "3.7.0",
72
+ "@scm-manager/ui-text": "3.7.0"
73
73
  },
74
74
  "dependencies": {
75
- "@scm-manager/ui-core": "3.6.1",
76
- "@scm-manager/ui-overlays": "3.6.1",
77
- "@scm-manager/ui-layout": "3.6.1",
78
- "@scm-manager/ui-buttons": "3.6.1",
79
- "@scm-manager/ui-api": "3.6.1",
80
- "@scm-manager/ui-extensions": "3.6.1",
75
+ "@scm-manager/ui-core": "3.7.0",
76
+ "@scm-manager/ui-overlays": "3.7.0",
77
+ "@scm-manager/ui-layout": "3.7.0",
78
+ "@scm-manager/ui-buttons": "3.7.0",
79
+ "@scm-manager/ui-api": "3.7.0",
80
+ "@scm-manager/ui-extensions": "3.7.0",
81
81
  "deepmerge": "^4.2.2",
82
82
  "hast-util-sanitize": "^3.0.2",
83
83
  "react-diff-view": "^2.4.10",
@@ -20,6 +20,7 @@ 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 { useDocumentTitle } from "@scm-manager/ui-core";
23
24
  import ErrorNotification from "./ErrorNotification";
24
25
  import ErrorPage from "./ErrorPage";
25
26
  import { Subtitle, Title } from "./layout";
@@ -53,6 +54,7 @@ const RedirectIconContainer = styled.div`
53
54
 
54
55
  const RedirectPage = () => {
55
56
  const [t] = useTranslation("commons");
57
+ useDocumentTitle(t("errorNotification.prefix"));
56
58
  // we use an icon instead of loading spinner,
57
59
  // because a redirect is synchron and a spinner does not spin on a synchron action
58
60
  return (
@@ -106,7 +108,7 @@ const ErrorDisplay: FC<ErrorDisplayProps> = ({ error, errorInfo, fallback: Fallb
106
108
 
107
109
  const fallbackProps = {
108
110
  error,
109
- errorInfo
111
+ errorInfo,
110
112
  };
111
113
 
112
114
  return <FallbackComponent {...fallbackProps} />;
@@ -128,7 +130,7 @@ class ErrorBoundary extends React.Component<Props, State> {
128
130
  componentDidCatch(error: Error, errorInfo: ErrorInfo) {
129
131
  this.setState({
130
132
  error,
131
- errorInfo
133
+ errorInfo,
132
134
  });
133
135
  }
134
136
 
package/src/ErrorPage.tsx CHANGED
@@ -14,9 +14,11 @@
14
14
  * along with this program. If not, see https://www.gnu.org/licenses/.
15
15
  */
16
16
 
17
- import React from "react";
18
- import ErrorNotification from "./ErrorNotification";
17
+ import React, { FC } from "react";
18
+ import { useTranslation } from "react-i18next";
19
19
  import { BackendError, ForbiddenError } from "@scm-manager/ui-api";
20
+ import { useDocumentTitle } from "@scm-manager/ui-core";
21
+ import ErrorNotification from "./ErrorNotification";
20
22
 
21
23
  type Props = {
22
24
  error: Error;
@@ -24,28 +26,26 @@ type Props = {
24
26
  subtitle: string;
25
27
  };
26
28
 
27
- class ErrorPage extends React.Component<Props> {
28
- render() {
29
- const { title, error } = this.props;
30
-
31
- return (
32
- <section className="section">
33
- <div className="box column is-4 is-offset-4 container">
34
- <h1 className="title">{title}</h1>
35
- {this.renderSubtitle()}
36
- <ErrorNotification error={error} />
37
- </div>
38
- </section>
39
- );
40
- }
29
+ const ErrorPage: FC<Props> = ({ error, title, subtitle }) => {
30
+ const [t] = useTranslation("commons");
31
+ useDocumentTitle(t("errorNotification.prefix"));
41
32
 
42
- renderSubtitle = () => {
43
- const { error, subtitle } = this.props;
33
+ const renderSubtitle = () => {
44
34
  if (error instanceof BackendError || error instanceof ForbiddenError) {
45
35
  return null;
46
36
  }
47
37
  return <p className="subtitle">{subtitle}</p>;
48
38
  };
49
- }
39
+
40
+ return (
41
+ <section className="section">
42
+ <div className="box column is-4 is-offset-4 container">
43
+ <h1 className="title">{title}</h1>
44
+ {renderSubtitle()}
45
+ <ErrorNotification error={error} />
46
+ </div>
47
+ </section>
48
+ );
49
+ };
50
50
 
51
51
  export default ErrorPage;
package/src/Tag.tsx CHANGED
@@ -45,7 +45,7 @@ const Tag: FC<Props> = ({
45
45
  title,
46
46
  onClick,
47
47
  onRemove,
48
- children
48
+ children,
49
49
  }) => {
50
50
  const [t] = useTranslation("commons");
51
51
 
@@ -53,7 +53,7 @@ const Tag: FC<Props> = ({
53
53
  if (icon) {
54
54
  showIcon = (
55
55
  <>
56
- <i className={classNames("fas", `fa-${icon}`)} />
56
+ <i className={classNames("fas", `fa-${icon}`)} aria-hidden="true" />
57
57
  &nbsp;
58
58
  </>
59
59
  );
@@ -65,26 +65,44 @@ const Tag: FC<Props> = ({
65
65
 
66
66
  return (
67
67
  <>
68
- <span
69
- className={classNames(
70
- "tag",
71
- `is-${color}`,
72
- `is-${size}`,
73
- className,
74
- {
75
- "is-outlined": outlined,
76
- "is-rounded": rounded,
77
- "is-clickable": onClick
78
- },
79
- size === "small" && smallClassNames
80
- )}
81
- title={title}
82
- onClick={onClick}
83
- >
84
- {showIcon}
85
- {label}
86
- {children}
87
- </span>
68
+ {onClick === undefined ? (
69
+ <span
70
+ className={classNames(
71
+ "tag",
72
+ `is-${color}`,
73
+ `is-${size}`,
74
+ className,
75
+ {
76
+ "is-outlined": outlined,
77
+ "is-rounded": rounded,
78
+ },
79
+ size === "small" && smallClassNames
80
+ )}
81
+ >
82
+ {showIcon}
83
+ {label}
84
+ {children}
85
+ </span>
86
+ ) : (
87
+ <button
88
+ className={classNames(
89
+ "tag",
90
+ `is-${color}`,
91
+ `is-${size}`,
92
+ className,
93
+ {
94
+ "is-outlined": outlined,
95
+ "is-rounded": rounded,
96
+ },
97
+ size === "small" && smallClassNames
98
+ )}
99
+ onClick={onClick}
100
+ >
101
+ {showIcon}
102
+ {label}
103
+ {children}
104
+ </button>
105
+ )}
88
106
  {showDelete}
89
107
  </>
90
108
  );