@scm-manager/ui-components 2.28.0 → 2.28.1-20220005-140541

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": "2.28.0",
3
+ "version": "2.28.1-20220005-140541",
4
4
  "description": "UI Components for SCM-Manager and its plugins",
5
5
  "main": "src/index.ts",
6
6
  "files": [
@@ -25,7 +25,7 @@
25
25
  "@scm-manager/jest-preset": "^2.13.0",
26
26
  "@scm-manager/prettier-config": "^2.10.1",
27
27
  "@scm-manager/tsconfig": "^2.12.0",
28
- "@scm-manager/ui-tests": "^2.28.0",
28
+ "@scm-manager/ui-tests": "^2.28.1-20220005-140541",
29
29
  "@storybook/addon-actions": "^6.3.12",
30
30
  "@storybook/addon-storyshots": "^6.3.12",
31
31
  "@storybook/builder-webpack5": "^6.3.12",
@@ -65,9 +65,9 @@
65
65
  "worker-plugin": "^3.2.0"
66
66
  },
67
67
  "dependencies": {
68
- "@scm-manager/ui-api": "^2.28.0",
69
- "@scm-manager/ui-extensions": "^2.28.0",
70
- "@scm-manager/ui-types": "^2.28.0",
68
+ "@scm-manager/ui-api": "^2.28.1-20220005-140541",
69
+ "@scm-manager/ui-extensions": "^2.28.1-20220005-140541",
70
+ "@scm-manager/ui-types": "^2.28.1-20220005-140541",
71
71
  "classnames": "^2.2.6",
72
72
  "date-fns": "^2.4.1",
73
73
  "deepmerge": "^4.2.2",
@@ -49,8 +49,8 @@ const prefix = (
49
49
  );
50
50
 
51
51
  storiesOf("BreadCrumb", module)
52
- .addDecorator((story) => <MemoryRouter initialEntries={["/"]}>{story()}</MemoryRouter>)
53
- .addDecorator((storyFn) => <Wrapper>{storyFn()}</Wrapper>)
52
+ .addDecorator(story => <MemoryRouter initialEntries={["/"]}>{story()}</MemoryRouter>)
53
+ .addDecorator(storyFn => <Wrapper>{storyFn()}</Wrapper>)
54
54
  .add("Default", () => (
55
55
  <Breadcrumb
56
56
  repository={repository}
@@ -87,4 +87,17 @@ storiesOf("BreadCrumb", module)
87
87
  permalink={"/" + path}
88
88
  preButtons={prefix}
89
89
  />
90
+ ))
91
+ .add("Not clickable", () => (
92
+ <Breadcrumb
93
+ repository={repository}
94
+ defaultBranch={master}
95
+ branch={master}
96
+ path={path}
97
+ baseUrl={baseUrl}
98
+ sources={sources}
99
+ revision={"1"}
100
+ permalink={"/" + path}
101
+ clickable={false}
102
+ />
90
103
  ));
@@ -37,6 +37,7 @@ type Props = {
37
37
  repository: Repository;
38
38
  branch?: Branch;
39
39
  defaultBranch?: Branch;
40
+ clickable?: boolean;
40
41
  revision: string;
41
42
  path: string;
42
43
  baseUrl: string;
@@ -115,6 +116,27 @@ const PrefixButton = styled.div`
115
116
  border-right: 1px solid lightgray;
116
117
  `;
117
118
 
119
+ const BreadcrumbNode: FC<{ clickable: boolean; text: string; url: string; current?: boolean }> = ({
120
+ clickable,
121
+ text,
122
+ url,
123
+ current
124
+ }) => {
125
+ if (clickable) {
126
+ return (
127
+ <Link className="is-ellipsis-overflow" title={text} to={url} aria-current={current ? "page" : undefined}>
128
+ {text}
129
+ </Link>
130
+ );
131
+ } else {
132
+ return (
133
+ <span className="is-ellipsis-overflow has-text-inherit px-3" title={text}>
134
+ {text}
135
+ </span>
136
+ );
137
+ }
138
+ };
139
+
118
140
  const Breadcrumb: FC<Props> = ({
119
141
  repository,
120
142
  branch,
@@ -124,7 +146,8 @@ const Breadcrumb: FC<Props> = ({
124
146
  baseUrl,
125
147
  sources,
126
148
  permalink,
127
- preButtons
149
+ preButtons,
150
+ clickable = true
128
151
  }) => {
129
152
  const location = useLocation();
130
153
  const history = useHistory();
@@ -135,6 +158,7 @@ const Breadcrumb: FC<Props> = ({
135
158
  if (path) {
136
159
  const paths = path.split("/");
137
160
  return paths.map((pathFragment, index) => {
161
+ const decodedPathFragment = decodeURIComponent(pathFragment);
138
162
  let currPath = paths
139
163
  .slice(0, index + 1)
140
164
  .map(encodeURIComponent)
@@ -145,21 +169,17 @@ const Breadcrumb: FC<Props> = ({
145
169
  if (paths.length - 1 === index) {
146
170
  return (
147
171
  <li className="is-active" key={index}>
148
- <Link className="is-ellipsis-overflow" to="#" aria-current="page">
149
- {decodeURIComponent(pathFragment)}
150
- </Link>
172
+ <BreadcrumbNode clickable={clickable} text={decodedPathFragment} url="#" current={true} />
151
173
  </li>
152
174
  );
153
175
  }
154
176
  return (
155
177
  <li key={index}>
156
- <Link
157
- className="is-ellipsis-overflow"
158
- title={pathFragment}
159
- to={baseUrl + "/" + encodeURIComponent(revision) + "/" + currPath}
160
- >
161
- {decodeURIComponent(pathFragment)}
162
- </Link>
178
+ <BreadcrumbNode
179
+ clickable={clickable}
180
+ text={decodedPathFragment}
181
+ url={baseUrl + "/" + encodeURIComponent(revision) + "/" + currPath}
182
+ />
163
183
  </li>
164
184
  );
165
185
  });
@@ -196,9 +216,13 @@ const Breadcrumb: FC<Props> = ({
196
216
  {prefixButtons}
197
217
  <ul>
198
218
  <li>
199
- <Link to={homeUrl} aria-label={t("breadcrumb.home")}>
200
- <HomeIcon title={t("breadcrumb.home")} name="home" color="inherit" />
201
- </Link>
219
+ {clickable ? (
220
+ <Link to={homeUrl} aria-label={t("breadcrumb.home")}>
221
+ <HomeIcon title={t("breadcrumb.home")} name="home" color="inherit" />
222
+ </Link>
223
+ ) : (
224
+ <Icon name="home" color="inherit" className="mr-3" />
225
+ )}
202
226
  </li>
203
227
  {pathSection()}
204
228
  </ul>
@@ -41,6 +41,9 @@ const RoutingDecorator = (story: () => ReactNode) => <MemoryRouter initialEntrie
41
41
 
42
42
  storiesOf("SyntaxHighlighter", module)
43
43
  .addDecorator(RoutingDecorator)
44
+ // Add async parameter, because the tests needs to render async before snapshot is taken so that
45
+ // code fragments get highlighted properly
46
+ .addParameters({ storyshots: { async: true } })
44
47
  .add("Java", () => (
45
48
  <Spacing>
46
49
  <SyntaxHighlighter language="java" value={JavaHttpServer} />