@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 +12 -12
- package/src/ErrorBoundary.tsx +4 -2
- package/src/ErrorPage.tsx +19 -19
- package/src/Tag.tsx +40 -22
- package/src/__snapshots__/storyshots.test.ts.snap +1247 -819
- package/src/forms/Select.tsx +1 -1
- package/src/layout/Page.tsx +29 -63
- package/src/layout/Title.tsx +2 -12
- package/src/repos/DiffDropDown.tsx +1 -1
- package/src/repos/HunkExpandDivider.tsx +3 -0
- package/src/repos/HunkExpandLink.tsx +8 -4
- package/src/repos/changesets/ContributorRow.tsx +1 -1
- package/src/repos/diff/HunkFooter.tsx +3 -3
- package/src/repos/diff/HunkHeader.tsx +4 -5
- package/src/repos/diff/LastHunkFooter.tsx +2 -2
package/src/forms/Select.tsx
CHANGED
|
@@ -95,7 +95,7 @@ const InnerSelect: FC<FieldProps<BaseProps, HTMLSelectElement, string>> = ({
|
|
|
95
95
|
if (!value && field.current?.value) {
|
|
96
96
|
if (props.onChange) {
|
|
97
97
|
if (isUsingRef<BaseProps, HTMLSelectElement, string>(props)) {
|
|
98
|
-
const event = new
|
|
98
|
+
const event: Event = new CustomEvent("change", { bubbles: true, detail: { target: field } });
|
|
99
99
|
field.current?.dispatchEvent(event);
|
|
100
100
|
} else if (isLegacy(props)) {
|
|
101
101
|
props.onChange(field.current?.value, name);
|
package/src/layout/Page.tsx
CHANGED
|
@@ -14,20 +14,19 @@
|
|
|
14
14
|
* along with this program. If not, see https://www.gnu.org/licenses/.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React, { ReactNode } from "react";
|
|
17
|
+
import React, { FC, ReactNode } from "react";
|
|
18
18
|
import classNames from "classnames";
|
|
19
19
|
import styled from "styled-components";
|
|
20
20
|
import Loading from "./../Loading";
|
|
21
21
|
import ErrorNotification from "./../ErrorNotification";
|
|
22
|
+
import ErrorBoundary from "../ErrorBoundary";
|
|
22
23
|
import Title from "./Title";
|
|
23
24
|
import Subtitle from "./Subtitle";
|
|
24
25
|
import PageActions from "./PageActions";
|
|
25
|
-
import ErrorBoundary from "../ErrorBoundary";
|
|
26
26
|
|
|
27
27
|
type Props = {
|
|
28
28
|
title?: ReactNode;
|
|
29
|
-
// Use
|
|
30
|
-
// and use something different than a string for the title property.
|
|
29
|
+
// [DEPRECATED] Use useDocumentTitle hook inside the component instead.
|
|
31
30
|
documentTitle?: string;
|
|
32
31
|
afterTitle?: ReactNode;
|
|
33
32
|
subtitle?: ReactNode;
|
|
@@ -44,43 +43,19 @@ const PageActionContainer = styled.div`
|
|
|
44
43
|
}
|
|
45
44
|
`;
|
|
46
45
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const textualTitle = this.getTextualTitle();
|
|
50
|
-
if (textualTitle && textualTitle !== document.title) {
|
|
51
|
-
document.title = textualTitle;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
render() {
|
|
56
|
-
const { error } = this.props;
|
|
57
|
-
return (
|
|
58
|
-
<section className="section">
|
|
59
|
-
<div className="container">
|
|
60
|
-
{this.renderPageHeader()}
|
|
61
|
-
<ErrorBoundary>
|
|
62
|
-
<ErrorNotification error={error} />
|
|
63
|
-
{this.renderContent()}
|
|
64
|
-
</ErrorBoundary>
|
|
65
|
-
</div>
|
|
66
|
-
</section>
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
isPageAction(node: any) {
|
|
46
|
+
const Page: FC<Props> = ({ title, afterTitle, subtitle, loading, error, showContentOnError, children }) => {
|
|
47
|
+
const isPageAction = (node: any) => {
|
|
71
48
|
return (
|
|
72
49
|
node.displayName === PageActions.displayName || (node.type && node.type.displayName === PageActions.displayName)
|
|
73
50
|
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
renderPageHeader() {
|
|
77
|
-
const { error, afterTitle, title, subtitle, children } = this.props;
|
|
51
|
+
};
|
|
78
52
|
|
|
53
|
+
const renderPageHeader = () => {
|
|
79
54
|
let pageActions = null;
|
|
80
55
|
let pageActionsExists = false;
|
|
81
|
-
React.Children.forEach(children, child => {
|
|
56
|
+
React.Children.forEach(children, (child) => {
|
|
82
57
|
if (child && !error) {
|
|
83
|
-
if (
|
|
58
|
+
if (isPageAction(child)) {
|
|
84
59
|
pageActions = (
|
|
85
60
|
<PageActionContainer
|
|
86
61
|
className={classNames(
|
|
@@ -99,6 +74,7 @@ export default class Page extends React.Component<Props> {
|
|
|
99
74
|
}
|
|
100
75
|
}
|
|
101
76
|
});
|
|
77
|
+
|
|
102
78
|
const underline = pageActionsExists ? <hr className="header-with-actions" /> : null;
|
|
103
79
|
|
|
104
80
|
if (title || subtitle) {
|
|
@@ -107,9 +83,7 @@ export default class Page extends React.Component<Props> {
|
|
|
107
83
|
<div className="columns">
|
|
108
84
|
<div className="column">
|
|
109
85
|
<div className="is-flex is-flex-wrap-wrap is-align-items-center">
|
|
110
|
-
<Title className="mb-0 mr-2"
|
|
111
|
-
{this.getTitleComponent()}
|
|
112
|
-
</Title>
|
|
86
|
+
<Title className="mb-0 mr-2">{title}</Title>
|
|
113
87
|
{afterTitle}
|
|
114
88
|
</div>
|
|
115
89
|
{subtitle ? <Subtitle>{subtitle}</Subtitle> : null}
|
|
@@ -121,11 +95,9 @@ export default class Page extends React.Component<Props> {
|
|
|
121
95
|
);
|
|
122
96
|
}
|
|
123
97
|
return null;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
renderContent() {
|
|
127
|
-
const { loading, children, showContentOnError, error } = this.props;
|
|
98
|
+
};
|
|
128
99
|
|
|
100
|
+
const renderContent = () => {
|
|
129
101
|
if (error && !showContentOnError) {
|
|
130
102
|
return null;
|
|
131
103
|
}
|
|
@@ -134,33 +106,27 @@ export default class Page extends React.Component<Props> {
|
|
|
134
106
|
}
|
|
135
107
|
|
|
136
108
|
const content: ReactNode[] = [];
|
|
137
|
-
React.Children.forEach(children, child => {
|
|
109
|
+
React.Children.forEach(children, (child) => {
|
|
138
110
|
if (child) {
|
|
139
|
-
if (!
|
|
111
|
+
if (!isPageAction(child)) {
|
|
140
112
|
content.push(child);
|
|
141
113
|
}
|
|
142
114
|
}
|
|
143
115
|
});
|
|
144
116
|
return content;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
getTextualTitle: () => string | undefined = () => {
|
|
148
|
-
const { title, documentTitle } = this.props;
|
|
149
|
-
if (documentTitle) {
|
|
150
|
-
return documentTitle;
|
|
151
|
-
} else if (typeof title === "string") {
|
|
152
|
-
return title;
|
|
153
|
-
} else {
|
|
154
|
-
return undefined;
|
|
155
|
-
}
|
|
156
117
|
};
|
|
157
118
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
119
|
+
return (
|
|
120
|
+
<section className="section">
|
|
121
|
+
<div className="container">
|
|
122
|
+
{renderPageHeader()}
|
|
123
|
+
<ErrorBoundary>
|
|
124
|
+
<ErrorNotification error={error} />
|
|
125
|
+
{renderContent()}
|
|
126
|
+
</ErrorBoundary>
|
|
127
|
+
</div>
|
|
128
|
+
</section>
|
|
129
|
+
);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export default Page;
|
package/src/layout/Title.tsx
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* along with this program. If not, see https://www.gnu.org/licenses/.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import React, { FC
|
|
17
|
+
import React, { FC } from "react";
|
|
18
18
|
import classNames from "classnames";
|
|
19
19
|
|
|
20
20
|
type Props = {
|
|
@@ -28,17 +28,7 @@ type Props = {
|
|
|
28
28
|
* @deprecated Please import the identical module from "@scm-manager/ui-core"
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
|
-
const Title: FC<Props> = ({ title,
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
if (!preventRefreshingPageTitle) {
|
|
34
|
-
if (customPageTitle) {
|
|
35
|
-
document.title = customPageTitle;
|
|
36
|
-
} else if (title) {
|
|
37
|
-
document.title = title;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}, [title, preventRefreshingPageTitle, customPageTitle]);
|
|
41
|
-
|
|
31
|
+
const Title: FC<Props> = ({ title, className, children }) => {
|
|
42
32
|
if (children) {
|
|
43
33
|
return <h1 className={classNames("title", className)}>{children}</h1>;
|
|
44
34
|
} else if (title) {
|
|
@@ -65,7 +65,7 @@ const DiffDropDown: FC<DiffDropDownProps> = ({
|
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
return (
|
|
68
|
-
<div className={"dropdown" + (isOpen ? " is-active" : "")}>
|
|
68
|
+
<div className={"dropdown is-right " + (isOpen ? " is-active" : "")}>
|
|
69
69
|
<div className="dropdown-trigger">
|
|
70
70
|
<button onClick={handleOpen} className="button" aria-haspopup="true" aria-controls="dropdown-menu2">
|
|
71
71
|
<span className="icon is-small">
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import React, { FC, useState } from "react";
|
|
18
18
|
import { useTranslation } from "react-i18next";
|
|
19
|
-
import
|
|
19
|
+
import { Icon } from "@scm-manager/ui-core";
|
|
20
20
|
|
|
21
21
|
type Props = {
|
|
22
22
|
icon: string;
|
|
@@ -37,9 +37,13 @@ const HunkExpandLink: FC<Props> = ({ icon, text, onClick }) => {
|
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
return (
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
<button
|
|
41
|
+
className="hunk-expander is-clickable diff-decoration-content has-background-transparent is-borderless pr-2"
|
|
42
|
+
onClick={onClickWithLoadingMarker}
|
|
43
|
+
>
|
|
44
|
+
<Icon>{icon}</Icon>
|
|
45
|
+
{loading ? t("diff.expanding") : text}
|
|
46
|
+
</button>
|
|
43
47
|
);
|
|
44
48
|
};
|
|
45
49
|
|
|
@@ -25,7 +25,7 @@ const ContributorRow: FC<{ label: string }> = ({ label, children }) => {
|
|
|
25
25
|
return (
|
|
26
26
|
<tr key={label}>
|
|
27
27
|
<SizedTd>{label}:</SizedTd>
|
|
28
|
-
<td className="is-
|
|
28
|
+
<td className="is-word-break m-0">{children}</td>
|
|
29
29
|
</tr>
|
|
30
30
|
);
|
|
31
31
|
};
|
|
@@ -37,7 +37,7 @@ const HunkFooter: FC<Props> = ({ expandableHunk, diffExpanded, diffExpansionFail
|
|
|
37
37
|
return (
|
|
38
38
|
<HunkExpandDivider>
|
|
39
39
|
<HunkExpandLink
|
|
40
|
-
icon={"
|
|
40
|
+
icon={"angle-double-down"}
|
|
41
41
|
onClick={expandBottom(expandableHunk, expandableHunk.maxExpandBottomRange)}
|
|
42
42
|
text={t("diff.expandComplete", { count: expandableHunk.maxExpandBottomRange })}
|
|
43
43
|
/>
|
|
@@ -47,12 +47,12 @@ const HunkFooter: FC<Props> = ({ expandableHunk, diffExpanded, diffExpansionFail
|
|
|
47
47
|
return (
|
|
48
48
|
<HunkExpandDivider>
|
|
49
49
|
<HunkExpandLink
|
|
50
|
-
icon={"
|
|
50
|
+
icon={"angle-down"}
|
|
51
51
|
onClick={expandBottom(expandableHunk, 10)}
|
|
52
52
|
text={t("diff.expandByLines", { count: 10 })}
|
|
53
53
|
/>{" "}
|
|
54
54
|
<HunkExpandLink
|
|
55
|
-
icon={"
|
|
55
|
+
icon={"angle-double-down"}
|
|
56
56
|
onClick={expandBottom(expandableHunk, expandableHunk.maxExpandBottomRange)}
|
|
57
57
|
text={t("diff.expandComplete", { count: expandableHunk.maxExpandBottomRange })}
|
|
58
58
|
/>
|
|
@@ -37,10 +37,9 @@ const HunkHeader: FC<Props> = ({ expandableHunk, diffExpanded, diffExpansionFail
|
|
|
37
37
|
return (
|
|
38
38
|
<HunkExpandDivider>
|
|
39
39
|
<HunkExpandLink
|
|
40
|
-
icon={"
|
|
40
|
+
icon={"angle-double-up"}
|
|
41
41
|
onClick={expandHead(expandableHunk, expandableHunk.maxExpandHeadRange)}
|
|
42
|
-
text={t("diff.expandComplete", { count: expandableHunk.maxExpandHeadRange })
|
|
43
|
-
}
|
|
42
|
+
text={t("diff.expandComplete", { count: expandableHunk.maxExpandHeadRange })}
|
|
44
43
|
/>
|
|
45
44
|
</HunkExpandDivider>
|
|
46
45
|
);
|
|
@@ -48,12 +47,12 @@ const HunkHeader: FC<Props> = ({ expandableHunk, diffExpanded, diffExpansionFail
|
|
|
48
47
|
return (
|
|
49
48
|
<HunkExpandDivider>
|
|
50
49
|
<HunkExpandLink
|
|
51
|
-
icon={"
|
|
50
|
+
icon={"angle-up"}
|
|
52
51
|
onClick={expandHead(expandableHunk, 10)}
|
|
53
52
|
text={t("diff.expandByLines", { count: 10 })}
|
|
54
53
|
/>{" "}
|
|
55
54
|
<HunkExpandLink
|
|
56
|
-
icon={"
|
|
55
|
+
icon={"angle-double-up"}
|
|
57
56
|
onClick={expandHead(expandableHunk, expandableHunk.maxExpandHeadRange)}
|
|
58
57
|
text={t("diff.expandComplete", { count: expandableHunk.maxExpandHeadRange })}
|
|
59
58
|
/>
|
|
@@ -36,12 +36,12 @@ const LastHunkFooter: FC<Props> = ({ expandableHunk, diffExpanded, diffExpansion
|
|
|
36
36
|
return (
|
|
37
37
|
<HunkExpandDivider>
|
|
38
38
|
<HunkExpandLink
|
|
39
|
-
icon={"
|
|
39
|
+
icon={"angle-down"}
|
|
40
40
|
onClick={expandBottom(expandableHunk, 10)}
|
|
41
41
|
text={t("diff.expandLastBottomByLines", { count: 10 })}
|
|
42
42
|
/>{" "}
|
|
43
43
|
<HunkExpandLink
|
|
44
|
-
icon={"
|
|
44
|
+
icon={"angle-double-down"}
|
|
45
45
|
onClick={expandBottom(expandableHunk, expandableHunk.maxExpandBottomRange)}
|
|
46
46
|
text={t("diff.expandLastBottomComplete")}
|
|
47
47
|
/>
|