@scm-manager/ui-components 3.10.2-20250802-135601 → 3.10.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scm-manager/ui-components",
3
- "version": "3.10.2-20250802-135601",
3
+ "version": "3.10.2",
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.10.2-20250802-135601",
36
- "@scm-manager/ui-types": "3.10.2-20250802-135601",
35
+ "@scm-manager/ui-tests": "3.10.2",
36
+ "@scm-manager/ui-types": "3.10.2",
37
37
  "@types/fetch-mock": "^7.3.1",
38
38
  "@types/react-select": "^2.0.19",
39
39
  "@types/unist": "^2.0.3",
@@ -68,17 +68,17 @@
68
68
  "@scm-manager/jest-preset": "^2.14.1",
69
69
  "@scm-manager/prettier-config": "^2.12.0",
70
70
  "@scm-manager/tsconfig": "^2.13.0",
71
- "@scm-manager/ui-syntaxhighlighting": "3.10.2-20250802-135601",
72
- "@scm-manager/ui-shortcuts": "3.10.2-20250802-135601",
73
- "@scm-manager/ui-text": "3.10.2-20250802-135601"
71
+ "@scm-manager/ui-syntaxhighlighting": "3.10.2",
72
+ "@scm-manager/ui-shortcuts": "3.10.2",
73
+ "@scm-manager/ui-text": "3.10.2"
74
74
  },
75
75
  "dependencies": {
76
- "@scm-manager/ui-core": "3.10.2-20250802-135601",
77
- "@scm-manager/ui-overlays": "3.10.2-20250802-135601",
78
- "@scm-manager/ui-layout": "3.10.2-20250802-135601",
79
- "@scm-manager/ui-buttons": "3.10.2-20250802-135601",
80
- "@scm-manager/ui-api": "3.10.2-20250802-135601",
81
- "@scm-manager/ui-extensions": "3.10.2-20250802-135601",
76
+ "@scm-manager/ui-core": "3.10.2",
77
+ "@scm-manager/ui-overlays": "3.10.2",
78
+ "@scm-manager/ui-layout": "3.10.2",
79
+ "@scm-manager/ui-buttons": "3.10.2",
80
+ "@scm-manager/ui-api": "3.10.2",
81
+ "@scm-manager/ui-extensions": "3.10.2",
82
82
  "deepmerge": "^4.2.2",
83
83
  "hast-util-sanitize": "^3.0.2",
84
84
  "react-diff-view": "^2.4.10",
@@ -14,9 +14,9 @@
14
14
  * along with this program. If not, see https://www.gnu.org/licenses/.
15
15
  */
16
16
 
17
- import { FC, ReactNode } from "react";
17
+ import { ReactNode } from "react";
18
18
  import { DefaultCollapsed } from "./defaultCollapsed";
19
- import { Change, Hunk, FileDiff as File, FileChangeType } from "@scm-manager/ui-types";
19
+ import { Change, Hunk, FileDiff as File } from "@scm-manager/ui-types";
20
20
 
21
21
  export type ChangeEvent = {
22
22
  change: Change;
@@ -31,18 +31,6 @@ export type AnnotationFactoryContext = BaseContext;
31
31
 
32
32
  export type FileAnnotationFactory = (file: File) => ReactNode[];
33
33
 
34
- export type FileTreeNodeWrapper = FC<{
35
- name: string;
36
- path: string;
37
- changeType?: FileChangeType;
38
- iconName: string;
39
- iconColor: string;
40
- isFile: boolean;
41
- originalIcon: ReactNode;
42
- originalLabel: ReactNode;
43
- isCurrentFile: boolean;
44
- }>;
45
-
46
34
  // key = change id, value = react component
47
35
  export type AnnotationFactory = (context: AnnotationFactoryContext) => {
48
36
  [key: string]: any;
@@ -18,19 +18,12 @@ import React, { FC } from "react";
18
18
  import { Link } from "react-router-dom";
19
19
  import { useTranslation } from "react-i18next";
20
20
  import classNames from "classnames";
21
- import { FileChangeType, FileTree } from "@scm-manager/ui-types";
21
+ import { FileTree } from "@scm-manager/ui-types";
22
22
  import { FileDiffContent, StackedSpan, StyledIcon } from "./styledElements";
23
- import { FileTreeNodeWrapper } from "../DiffTypes";
24
23
 
25
- type Props = {
26
- tree: FileTree;
27
- currentFile: string;
28
- setCurrentFile: (path: string) => void;
29
- gap?: number;
30
- FileTreeNodeWrapper?: FileTreeNodeWrapper;
31
- };
24
+ type Props = { tree: FileTree; currentFile: string; setCurrentFile: (path: string) => void; gap?: number };
32
25
 
33
- const DiffFileTree: FC<Props> = ({ tree, currentFile, setCurrentFile, gap = 15, FileTreeNodeWrapper }) => {
26
+ const DiffFileTree: FC<Props> = ({ tree, currentFile, setCurrentFile, gap = 15 }) => {
34
27
  return (
35
28
  <FileDiffContent gap={gap}>
36
29
  {Object.keys(tree.children).map((key) => (
@@ -40,7 +33,6 @@ const DiffFileTree: FC<Props> = ({ tree, currentFile, setCurrentFile, gap = 15,
40
33
  parentPath=""
41
34
  currentFile={currentFile}
42
35
  setCurrentFile={setCurrentFile}
43
- FileTreeNodeWrapper={FileTreeNodeWrapper}
44
36
  />
45
37
  ))}
46
38
  </FileDiffContent>
@@ -49,13 +41,9 @@ const DiffFileTree: FC<Props> = ({ tree, currentFile, setCurrentFile, gap = 15,
49
41
 
50
42
  export default DiffFileTree;
51
43
 
52
- type NodeProps = {
53
- node: FileTree;
54
- parentPath: string;
55
- currentFile: string;
56
- setCurrentFile: (path: string) => void;
57
- FileTreeNodeWrapper?: FileTreeNodeWrapper;
58
- };
44
+ type ChangeType = "add" | "modify" | "delete" | "rename" | "copy";
45
+
46
+ type NodeProps = { node: FileTree; parentPath: string; currentFile: string; setCurrentFile: (path: string) => void };
59
47
 
60
48
  const addPath = (parentPath: string, path: string) => {
61
49
  if ("" === parentPath) {
@@ -64,31 +52,16 @@ const addPath = (parentPath: string, path: string) => {
64
52
  return parentPath + "/" + path;
65
53
  };
66
54
 
67
- const TreeNode: FC<NodeProps> = ({ node, parentPath, currentFile, setCurrentFile, FileTreeNodeWrapper }) => {
55
+ const TreeNode: FC<NodeProps> = ({ node, parentPath, currentFile, setCurrentFile }) => {
68
56
  const [t] = useTranslation("repos");
69
57
 
70
- FileTreeNodeWrapper = FileTreeNodeWrapper || (({ children }) => <>{children}</>);
71
-
72
- const label = <div className="ml-1">{node.nodeName}</div>;
73
- const icon = <StyledIcon alt={t("diff.showContent")}>folder</StyledIcon>;
74
58
  return (
75
59
  <li>
76
60
  {Object.keys(node.children).length > 0 ? (
77
61
  <ul className="py-1 pl-3">
78
62
  <li className="is-flex has-text-grey">
79
- <FileTreeNodeWrapper
80
- path={addPath(parentPath, node.nodeName)}
81
- isFile={false}
82
- isCurrentFile={false}
83
- name={node.nodeName}
84
- iconName={"folder"}
85
- iconColor={"grey"}
86
- originalIcon={icon}
87
- originalLabel={label}
88
- >
89
- {icon}
90
- {label}
91
- </FileTreeNodeWrapper>
63
+ <StyledIcon alt={t("diff.showContent")}>folder</StyledIcon>
64
+ <div className="ml-1">{node.nodeName}</div>
92
65
  </li>
93
66
  {Object.keys(node.children).map((key) => (
94
67
  <TreeNode
@@ -97,25 +70,23 @@ const TreeNode: FC<NodeProps> = ({ node, parentPath, currentFile, setCurrentFile
97
70
  parentPath={addPath(parentPath, node.nodeName)}
98
71
  currentFile={currentFile}
99
72
  setCurrentFile={setCurrentFile}
100
- FileTreeNodeWrapper={FileTreeNodeWrapper}
101
73
  />
102
74
  ))}
103
75
  </ul>
104
76
  ) : (
105
77
  <TreeFile
106
- changeType={node.changeType.toLowerCase() as FileChangeType}
78
+ changeType={node.changeType.toLowerCase() as ChangeType}
107
79
  path={node.nodeName}
108
80
  parentPath={parentPath}
109
81
  currentFile={currentFile}
110
82
  setCurrentFile={setCurrentFile}
111
- FileTreeNodeWrapper={FileTreeNodeWrapper}
112
83
  />
113
84
  )}
114
85
  </li>
115
86
  );
116
87
  };
117
88
 
118
- const getColor = (changeType: FileChangeType) => {
89
+ const getColor = (changeType: ChangeType) => {
119
90
  switch (changeType) {
120
91
  case "add":
121
92
  return "success";
@@ -128,7 +99,7 @@ const getColor = (changeType: FileChangeType) => {
128
99
  }
129
100
  };
130
101
 
131
- const getIcon = (changeType: FileChangeType) => {
102
+ const getIcon = (changeType: ChangeType) => {
132
103
  switch (changeType) {
133
104
  case "add":
134
105
  case "copy":
@@ -142,22 +113,14 @@ const getIcon = (changeType: FileChangeType) => {
142
113
  };
143
114
 
144
115
  type FileProps = {
145
- changeType: FileChangeType;
116
+ changeType: ChangeType;
146
117
  path: string;
147
118
  parentPath: string;
148
119
  currentFile: string;
149
120
  setCurrentFile: (path: string) => void;
150
- FileTreeNodeWrapper: FileTreeNodeWrapper;
151
121
  };
152
122
 
153
- const TreeFile: FC<FileProps> = ({
154
- changeType,
155
- path,
156
- parentPath,
157
- currentFile,
158
- setCurrentFile,
159
- FileTreeNodeWrapper,
160
- }) => {
123
+ const TreeFile: FC<FileProps> = ({ changeType, path, parentPath, currentFile, setCurrentFile }) => {
161
124
  const [t] = useTranslation("repos");
162
125
  const completePath = addPath(parentPath, path);
163
126
 
@@ -165,50 +128,35 @@ const TreeFile: FC<FileProps> = ({
165
128
  return currentFile === completePath;
166
129
  };
167
130
 
168
- const iconName = getIcon(changeType);
169
-
170
- const icon = (
171
- <StackedSpan className="fa-stack">
172
- <StyledIcon
173
- className={classNames("fa-stack-2x", `has-text-${getColor(changeType)}`)}
174
- key={completePath + "file"}
175
- type="fas"
176
- alt={t("diff.showContent")}
177
- >
178
- file
179
- </StyledIcon>
180
- <StyledIcon
181
- className={classNames("fa-stack-1x", "is-relative", "has-text-secondary-least")}
182
- isSmaller={iconName === "circle"}
183
- key={changeType}
184
- alt={t(`diff.changes.${changeType}`)}
185
- >
186
- {iconName}
187
- </StyledIcon>
188
- </StackedSpan>
189
- );
190
- const label = <div className={classNames("ml-1", isCurrentFile() ? "has-text-weight-bold" : "")}>{path}</div>;
191
-
192
131
  return (
193
132
  <Link
194
133
  className="is-flex py-1 pl-3 has-cursor-pointer"
195
134
  onClick={() => setCurrentFile(completePath)}
196
135
  to={`#diff-${encodeURIComponent(completePath)}`}
197
136
  >
198
- <FileTreeNodeWrapper
199
- name={path}
200
- path={completePath}
201
- changeType={changeType}
202
- isFile={true}
203
- iconName={iconName}
204
- iconColor={getColor(changeType)}
205
- originalIcon={icon}
206
- originalLabel={label}
207
- isCurrentFile={isCurrentFile()}
208
- >
209
- {icon}
210
- {label}
211
- </FileTreeNodeWrapper>
137
+ <StackedSpan className="fa-stack">
138
+ <StyledIcon
139
+ className={classNames("fa-stack-2x", `has-text-${getColor(changeType)}`)}
140
+ key={completePath + "file"}
141
+ type={isCurrentFile() ? "fas" : "far"}
142
+ alt={t("diff.showContent")}
143
+ >
144
+ file
145
+ </StyledIcon>
146
+ <StyledIcon
147
+ className={classNames(
148
+ "fa-stack-1x",
149
+ "is-relative",
150
+ isCurrentFile() ? "has-text-secondary-least" : `has-text-${getColor(changeType)}`
151
+ )}
152
+ isSmaller={getIcon(changeType) === "circle"}
153
+ key={changeType}
154
+ alt={t(`diff.changes.${changeType}`)}
155
+ >
156
+ {getIcon(changeType)}
157
+ </StyledIcon>
158
+ </StackedSpan>
159
+ <div className="ml-1">{path}</div>
212
160
  </Link>
213
161
  );
214
162
  };