@scm-manager/ui-components 2.20.1-20210616-114029 → 2.20.1

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.20.1-20210616-114029",
3
+ "version": "2.20.1",
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.12.7",
26
26
  "@scm-manager/prettier-config": "^2.10.1",
27
27
  "@scm-manager/tsconfig": "^2.11.2",
28
- "@scm-manager/ui-tests": "^2.20.1-20210616-114029",
28
+ "@scm-manager/ui-tests": "^2.20.1",
29
29
  "@storybook/addon-actions": "^6.1.17",
30
30
  "@storybook/addon-storyshots": "^6.1.17",
31
31
  "@storybook/react": "^6.1.17",
@@ -59,9 +59,9 @@
59
59
  "worker-plugin": "^3.2.0"
60
60
  },
61
61
  "dependencies": {
62
- "@scm-manager/ui-api": "^2.20.1-20210616-114029",
63
- "@scm-manager/ui-extensions": "^2.20.1-20210616-114029",
64
- "@scm-manager/ui-types": "^2.20.1-20210616-114029",
62
+ "@scm-manager/ui-api": "^2.20.1",
63
+ "@scm-manager/ui-extensions": "^2.20.1",
64
+ "@scm-manager/ui-types": "^2.20.1",
65
65
  "classnames": "^2.2.6",
66
66
  "date-fns": "^2.4.1",
67
67
  "deepmerge": "^4.2.2",
@@ -26,12 +26,12 @@ import { useTranslation } from "react-i18next";
26
26
  import { useHistory, useLocation, Link } from "react-router-dom";
27
27
  import classNames from "classnames";
28
28
  import styled from "styled-components";
29
- import { urls } from "@scm-manager/ui-api";
29
+ import { binder, ExtensionPoint } from "@scm-manager/ui-extensions";
30
30
  import { Branch, Repository, File } from "@scm-manager/ui-types";
31
- import { binder, ExtensionPoint, extensionPoints } from "@scm-manager/ui-extensions";
32
31
  import Icon from "./Icon";
33
32
  import Tooltip from "./Tooltip";
34
33
  import copyToClipboard from "./CopyToClipboard";
34
+ import { urls } from "@scm-manager/ui-api";
35
35
 
36
36
  type Props = {
37
37
  repository: Repository;
@@ -65,6 +65,8 @@ const BreadcrumbNav = styled.nav`
65
65
  flex: 1;
66
66
  display: flex;
67
67
  align-items: center;
68
+ margin: 1rem 1rem !important;
69
+
68
70
  width: 100%;
69
71
 
70
72
  /* move slash to end */
@@ -125,7 +127,7 @@ const Breadcrumb: FC<Props> = ({
125
127
  baseUrl,
126
128
  sources,
127
129
  permalink,
128
- preButtons,
130
+ preButtons
129
131
  }) => {
130
132
  const location = useLocation();
131
133
  const history = useHistory();
@@ -136,10 +138,7 @@ const Breadcrumb: FC<Props> = ({
136
138
  if (path) {
137
139
  const paths = path.split("/");
138
140
  return paths.map((pathFragment, index) => {
139
- let currPath = paths.slice(0, index + 1).join("/");
140
- if (!currPath.endsWith("/")) {
141
- currPath = currPath + "/";
142
- }
141
+ const currPath = paths.slice(0, index + 1).join("/");
143
142
  if (paths.length - 1 === index) {
144
143
  return (
145
144
  <li className="is-active" key={index}>
@@ -173,45 +172,15 @@ const Breadcrumb: FC<Props> = ({
173
172
  ).finally(() => setCopying(false));
174
173
  };
175
174
 
176
- const renderBreadcrumbNav = () => {
177
- let prefixButtons = null;
178
- if (preButtons) {
179
- prefixButtons = <PrefixButton>{preButtons}</PrefixButton>;
180
- }
181
-
182
- let homeUrl = baseUrl + "/";
183
- if (revision) {
184
- homeUrl += encodeURIComponent(revision) + "/";
185
- } else {
186
- homeUrl = `/repo/${repository.namespace}/${repository.name}/code/sources/`;
187
- }
175
+ let homeUrl = baseUrl + "/";
176
+ if (revision) {
177
+ homeUrl += encodeURIComponent(revision) + "/";
178
+ }
188
179
 
189
- return (
190
- <BreadcrumbNav
191
- className={classNames("breadcrumb", "sources-breadcrumb", "mx-2", "my-4")}
192
- aria-label="breadcrumbs"
193
- >
194
- {prefixButtons}
195
- <ul>
196
- <li>
197
- <Link to={homeUrl}>
198
- <HomeIcon title={t("breadcrumb.home")} name="home" color="inherit" />
199
- </Link>
200
- </li>
201
- {pathSection()}
202
- </ul>
203
- <PermaLinkWrapper className="ml-1">
204
- {copying ? (
205
- <Icon name="spinner fa-spin" />
206
- ) : (
207
- <Tooltip message={t("breadcrumb.copyPermalink")}>
208
- <Icon name="link" color="inherit" onClick={() => copySource()} />
209
- </Tooltip>
210
- )}
211
- </PermaLinkWrapper>
212
- </BreadcrumbNav>
213
- );
214
- };
180
+ let prefixButtons = null;
181
+ if (preButtons) {
182
+ prefixButtons = <PrefixButton>{preButtons}</PrefixButton>;
183
+ }
215
184
 
216
185
  const extProps = {
217
186
  baseUrl,
@@ -219,33 +188,40 @@ const Breadcrumb: FC<Props> = ({
219
188
  branch: branch ? branch : defaultBranch,
220
189
  path,
221
190
  sources,
222
- repository,
223
- };
224
-
225
- const renderExtensionPoints = () => {
226
- if (
227
- binder.hasExtension<extensionPoints.ReposSourcesEmptyActionbar>("repos.sources.empty.actionbar") &&
228
- sources?._embedded?.children?.length === 0
229
- ) {
230
- return (
231
- <ExtensionPoint
232
- name="repos.sources.empty.actionbar"
233
- props={{ repository, sources }}
234
- renderAll={true}
235
- />
236
- );
237
- }
238
- if (binder.hasExtension<extensionPoints.ReposSourcesActionbar>("repos.sources.actionbar")) {
239
- return <ExtensionPoint name="repos.sources.actionbar" props={extProps} renderAll={true} />;
240
- }
241
- return null;
191
+ repository
242
192
  };
243
193
 
244
194
  return (
245
195
  <>
246
- <div className="is-flex is-align-items-center is-justify-content-flex-end">
247
- {renderBreadcrumbNav()}
248
- {<ActionBar className="my-2">{renderExtensionPoints()}</ActionBar>}
196
+ <div className="is-flex is-align-items-center">
197
+ <BreadcrumbNav
198
+ className={classNames("breadcrumb", "sources-breadcrumb", "ml-1", "mb-0")}
199
+ aria-label="breadcrumbs"
200
+ >
201
+ {prefixButtons}
202
+ <ul>
203
+ <li>
204
+ <Link to={homeUrl}>
205
+ <HomeIcon title={t("breadcrumb.home")} name="home" color="inherit" />
206
+ </Link>
207
+ </li>
208
+ {pathSection()}
209
+ </ul>
210
+ <PermaLinkWrapper className="ml-1">
211
+ {copying ? (
212
+ <Icon name="spinner fa-spin" />
213
+ ) : (
214
+ <Tooltip message={t("breadcrumb.copyPermalink")}>
215
+ <Icon name="link" color="inherit" onClick={() => copySource()} />
216
+ </Tooltip>
217
+ )}
218
+ </PermaLinkWrapper>
219
+ </BreadcrumbNav>
220
+ {binder.hasExtension("repos.sources.actionbar") && (
221
+ <ActionBar>
222
+ <ExtensionPoint name="repos.sources.actionbar" props={extProps} renderAll={true} />
223
+ </ActionBar>
224
+ )}
249
225
  </div>
250
226
  <hr className="is-marginless" />
251
227
  </>
@@ -32,14 +32,8 @@ const Wrapper = styled.div`
32
32
  height: 100%;
33
33
  `;
34
34
 
35
- storiesOf("Logo", module)
36
- .add("Default", () => (
37
- <Wrapper>
38
- <Logo />
39
- </Wrapper>
40
- ))
41
- .add("WithoutText", () => (
42
- <Wrapper>
43
- <Logo withText={false} />
44
- </Wrapper>
45
- ));
35
+ storiesOf("Logo", module).add("Default", () => (
36
+ <Wrapper>
37
+ <Logo />
38
+ </Wrapper>
39
+ ));
package/src/Logo.tsx CHANGED
@@ -21,22 +21,15 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
- import React, { FC } from "react";
25
- import { useTranslation } from "react-i18next";
24
+ import React from "react";
25
+ import { WithTranslation, withTranslation } from "react-i18next";
26
26
  import Image from "./Image";
27
27
 
28
- type Props = {
29
- withText?: boolean;
30
- className?: string;
31
- };
32
-
33
- const Logo: FC<Props> = ({ withText = true, className }) => {
34
- const [t] = useTranslation("commons");
35
-
36
- if (withText) {
37
- return <Image src="/images/logo.png" alt={t("logo.alt")} className={className} />;
28
+ class Logo extends React.Component<WithTranslation> {
29
+ render() {
30
+ const { t } = this.props;
31
+ return <Image src="/images/logo.png" alt={t("logo.alt")} />;
38
32
  }
39
- return <Image src="/images/scmLogo.svg" alt={t("logo.alt")} className={className} />;
40
- };
33
+ }
41
34
 
42
- export default Logo;
35
+ export default withTranslation("commons")(Logo);