@scm-manager/ui-components 2.46.1 → 2.46.2-20230801-113910
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 +8 -8
- package/src/__snapshots__/storyshots.test.ts.snap +876 -1159
- package/src/layout/GroupEntries.tsx +8 -24
- package/src/layout/NamespaceEntries.tsx +66 -0
- package/src/layout/index.ts +1 -0
- package/src/repos/RepositoryEntry.tsx +83 -110
- package/src/repos/RepositoryFlag.tsx +6 -5
- package/src/repos/RepositoryFlags.tsx +11 -15
- package/src/layout/GroupEntry.stories.tsx +0 -75
- package/src/layout/GroupEntry.tsx +0 -122
|
@@ -22,35 +22,19 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
import React, { FC, ReactNode } from "react";
|
|
25
|
-
import
|
|
26
|
-
import styled from "styled-components";
|
|
27
|
-
|
|
28
|
-
const Separator = styled.div`
|
|
29
|
-
border-bottom: 1px solid rgb(219, 219, 219, 0.5);
|
|
30
|
-
`;
|
|
25
|
+
import { CardList, Collapsible } from "@scm-manager/ui-layout";
|
|
31
26
|
|
|
32
27
|
type Props = {
|
|
33
28
|
namespaceHeader: ReactNode;
|
|
34
29
|
elements: ReactNode[];
|
|
30
|
+
collapsed?: boolean;
|
|
31
|
+
onCollapsedChange?: (collapsed: boolean) => void;
|
|
35
32
|
};
|
|
36
33
|
|
|
37
|
-
const GroupEntries: FC<Props> = ({ namespaceHeader, elements }) =>
|
|
38
|
-
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
</React.Fragment>
|
|
43
|
-
));
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<>
|
|
47
|
-
<div className={classNames("is-flex", "is-align-items-center", "is-size-6", "has-text-weight-bold", "p-3")}>
|
|
48
|
-
{namespaceHeader}
|
|
49
|
-
</div>
|
|
50
|
-
<div className={classNames("box", "p-2")}>{content}</div>
|
|
51
|
-
<div className="is-clearfix" />
|
|
52
|
-
</>
|
|
53
|
-
);
|
|
54
|
-
};
|
|
34
|
+
const GroupEntries: FC<Props> = ({ namespaceHeader, elements, collapsed, onCollapsedChange }) => (
|
|
35
|
+
<Collapsible className="mb-5" header={namespaceHeader} collapsed={collapsed} onCollapsedChange={onCollapsedChange}>
|
|
36
|
+
<CardList>{elements}</CardList>
|
|
37
|
+
</Collapsible>
|
|
38
|
+
);
|
|
55
39
|
|
|
56
40
|
export default GroupEntries;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import React, { FC, ReactNode } from "react";
|
|
25
|
+
import { useTranslation } from "react-i18next";
|
|
26
|
+
import { useLocalStorage } from "@scm-manager/ui-api";
|
|
27
|
+
import { CardList, Collapsible } from "@scm-manager/ui-layout";
|
|
28
|
+
import { RepositoryGroup } from "@scm-manager/ui-types";
|
|
29
|
+
import { Link } from "react-router-dom";
|
|
30
|
+
import { Icon } from "../index";
|
|
31
|
+
|
|
32
|
+
type Props = {
|
|
33
|
+
elements: ReactNode[];
|
|
34
|
+
group: RepositoryGroup;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const DefaultGroupHeader: FC<{ group: RepositoryGroup }> = ({ group }) => {
|
|
38
|
+
const [t] = useTranslation("namespaces");
|
|
39
|
+
return (
|
|
40
|
+
<>
|
|
41
|
+
<Link to={`/repos/${group.name}/`} className="has-text-inherit">
|
|
42
|
+
<h3 className="has-text-weight-bold">{group.name}</h3>
|
|
43
|
+
</Link>{" "}
|
|
44
|
+
<Link to={`/namespace/${group.name}/settings`} aria-label={t("repositoryOverview.settings.tooltip")}>
|
|
45
|
+
<Icon color="inherit" name="cog" title={t("repositoryOverview.settings.tooltip")} className="is-size-6 ml-2" />
|
|
46
|
+
</Link>
|
|
47
|
+
</>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const NamespaceEntries: FC<Props> = ({ elements, group }) => {
|
|
52
|
+
const [collapsed, setCollapsed] = useLocalStorage<boolean | null>(`repoNamespace.${group.name}.collapsed`, null);
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<Collapsible
|
|
56
|
+
collapsed={collapsed ?? false}
|
|
57
|
+
onCollapsedChange={setCollapsed}
|
|
58
|
+
className="mb-5"
|
|
59
|
+
header={<DefaultGroupHeader group={group} />}
|
|
60
|
+
>
|
|
61
|
+
<CardList>{elements}</CardList>
|
|
62
|
+
</Collapsible>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default NamespaceEntries;
|
package/src/layout/index.ts
CHANGED
|
@@ -36,3 +36,4 @@ export { default as CustomQueryFlexWrappedColumns } from "./CustomQueryFlexWrapp
|
|
|
36
36
|
export { default as PrimaryContentColumn } from "./PrimaryContentColumn";
|
|
37
37
|
export { default as SecondaryNavigationColumn } from "./SecondaryNavigationColumn";
|
|
38
38
|
export { default as GroupEntries } from "./GroupEntries";
|
|
39
|
+
export { default as NamespaceEntries } from "./NamespaceEntries";
|
|
@@ -21,18 +21,19 @@
|
|
|
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
|
|
24
|
+
import React, { FC } from "react";
|
|
25
25
|
import { Repository } from "@scm-manager/ui-types";
|
|
26
|
-
import { DateFromNow
|
|
26
|
+
import { DateFromNow } from "@scm-manager/ui-components";
|
|
27
27
|
import RepositoryAvatar from "./RepositoryAvatar";
|
|
28
|
-
import {
|
|
29
|
-
import GroupEntry from "../layout/GroupEntry";
|
|
28
|
+
import { ExtensionPoint, extensionPoints } from "@scm-manager/ui-extensions";
|
|
30
29
|
import RepositoryFlags from "./RepositoryFlags";
|
|
31
30
|
import styled from "styled-components";
|
|
32
|
-
import Icon from "../Icon";
|
|
33
31
|
import { useTranslation } from "react-i18next";
|
|
34
|
-
import
|
|
35
|
-
import {
|
|
32
|
+
import { useKeyboardIteratorTarget } from "@scm-manager/ui-shortcuts";
|
|
33
|
+
import { Card } from "@scm-manager/ui-layout";
|
|
34
|
+
import { Link } from "react-router-dom";
|
|
35
|
+
import { Menu } from "@scm-manager/ui-overlays";
|
|
36
|
+
import { Icon } from "@scm-manager/ui-buttons";
|
|
36
37
|
|
|
37
38
|
type DateProp = Date | string;
|
|
38
39
|
|
|
@@ -43,125 +44,97 @@ type Props = {
|
|
|
43
44
|
baseDate?: DateProp;
|
|
44
45
|
};
|
|
45
46
|
|
|
46
|
-
const
|
|
47
|
-
|
|
47
|
+
const Avatar = styled.div`
|
|
48
|
+
.predefined-avatar {
|
|
49
|
+
height: 48px;
|
|
50
|
+
width: 48px;
|
|
51
|
+
font-size: 1.75rem;
|
|
52
|
+
}
|
|
48
53
|
`;
|
|
49
54
|
|
|
50
|
-
const
|
|
51
|
-
|
|
55
|
+
const StyledLink = styled(Link)`
|
|
56
|
+
overflow-wrap: anywhere;
|
|
52
57
|
`;
|
|
53
58
|
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const ContactActionWrapper = styled.a`
|
|
59
|
-
height: 20px;
|
|
60
|
-
width: 20px;
|
|
61
|
-
padding-right: 2rem;
|
|
59
|
+
const DescriptionRow = styled(Card.Row)`
|
|
60
|
+
text-wrap: nowrap;
|
|
61
|
+
overflow: hidden;
|
|
62
|
+
text-overflow: ellipsis;
|
|
62
63
|
`;
|
|
63
64
|
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
overflow-x: hidden;
|
|
67
|
-
overflow-y: visible;
|
|
68
|
-
white-space: nowrap;
|
|
65
|
+
const DetailsRow = styled(Card.Row)`
|
|
66
|
+
gap: 0.5rem;
|
|
69
67
|
`;
|
|
70
68
|
|
|
71
69
|
const RepositoryEntry: FC<Props> = ({ repository, baseDate }) => {
|
|
72
70
|
const [t] = useTranslation("repos");
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
const avatarFactory = binder.getExtension(EXTENSION_POINT);
|
|
76
|
-
|
|
77
|
-
const renderContactIcon = () => {
|
|
78
|
-
if (avatarFactory) {
|
|
79
|
-
return (
|
|
80
|
-
<ContactAvatar
|
|
81
|
-
className="has-rounded-border"
|
|
82
|
-
src={avatarFactory({ mail: repository.contact })}
|
|
83
|
-
alt={repository.contact}
|
|
84
|
-
/>
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
return <QuickAction className={classNames("is-clickable", "has-hover-visible")} name="envelope" color="info" />;
|
|
88
|
-
};
|
|
71
|
+
const ref = useKeyboardIteratorTarget();
|
|
89
72
|
|
|
90
|
-
const
|
|
91
|
-
<
|
|
92
|
-
|
|
93
|
-
"
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
<ContactActionWrapper
|
|
120
|
-
href={`mailto:${repository.contact}`}
|
|
121
|
-
target="_blank"
|
|
122
|
-
className={"is-size-5"}
|
|
123
|
-
title={t("overview.contact", { contact: repository.contact })}
|
|
124
|
-
>
|
|
125
|
-
{renderContactIcon()}
|
|
126
|
-
</ContactActionWrapper>
|
|
127
|
-
) : null}
|
|
128
|
-
<QuickAction
|
|
129
|
-
className={classNames("is-clickable", "is-size-5", "has-hover-visible")}
|
|
130
|
-
name="download"
|
|
131
|
-
color="info"
|
|
132
|
-
onClick={() => setOpenCloneModal(true)}
|
|
133
|
-
title={t("overview.clone")}
|
|
134
|
-
/>
|
|
135
|
-
</span>
|
|
136
|
-
<small className="pb-1">
|
|
137
|
-
<DateFromNow baseDate={baseDate} date={repository.lastModified || repository.creationDate} />
|
|
138
|
-
</small>
|
|
139
|
-
</ContentRightContainer>
|
|
73
|
+
const actions = () => (
|
|
74
|
+
<Menu>
|
|
75
|
+
<Menu.DialogButton
|
|
76
|
+
title={t("overview.clone")}
|
|
77
|
+
description={
|
|
78
|
+
<ExtensionPoint<extensionPoints.RepositoryDetailsInformation>
|
|
79
|
+
name="repos.repository-details.information"
|
|
80
|
+
renderAll={true}
|
|
81
|
+
props={{
|
|
82
|
+
repository,
|
|
83
|
+
}}
|
|
84
|
+
/>
|
|
85
|
+
}
|
|
86
|
+
>
|
|
87
|
+
<Icon>download</Icon>
|
|
88
|
+
{t("overview.clone")}
|
|
89
|
+
</Menu.DialogButton>
|
|
90
|
+
{repository.contact ? (
|
|
91
|
+
<Menu.ExternalLink
|
|
92
|
+
href={`mailto:${repository.contact}`}
|
|
93
|
+
target="_blank"
|
|
94
|
+
rel="noreferrer"
|
|
95
|
+
title={t("overview.contact", { contact: repository.contact })}
|
|
96
|
+
>
|
|
97
|
+
<Icon>envelope</Icon>
|
|
98
|
+
{t("overview.sendMailToContact")}
|
|
99
|
+
</Menu.ExternalLink>
|
|
100
|
+
) : null}
|
|
101
|
+
</Menu>
|
|
140
102
|
);
|
|
141
103
|
|
|
142
104
|
const repositoryLink = `/repo/${repository.namespace}/${repository.name}/`;
|
|
143
|
-
const actions = createContentRight();
|
|
144
|
-
const name = (
|
|
145
|
-
<div className="is-flex">
|
|
146
|
-
<ExtensionPoint<extensionPoints.RepositoryCardBeforeTitle>
|
|
147
|
-
name="repository.card.beforeTitle"
|
|
148
|
-
props={{ repository }}
|
|
149
|
-
/>
|
|
150
|
-
<Name>{repository.name}</Name> <RepositoryFlags repository={repository} className="is-hidden-mobile" />
|
|
151
|
-
</div>
|
|
152
|
-
);
|
|
153
105
|
|
|
154
106
|
return (
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
107
|
+
<Card
|
|
108
|
+
as="li"
|
|
109
|
+
aria-label={t("overview.ariaLabel", { name: repository.name })}
|
|
110
|
+
action={<>{actions()}</>}
|
|
111
|
+
rowGap="0.25rem"
|
|
112
|
+
avatar={
|
|
113
|
+
<Avatar className="is-align-self-flex-start">
|
|
114
|
+
<RepositoryAvatar repository={repository} size={48} />
|
|
115
|
+
</Avatar>
|
|
116
|
+
}
|
|
117
|
+
>
|
|
118
|
+
<Card.Row className="is-flex">
|
|
119
|
+
<ExtensionPoint<extensionPoints.RepositoryCardBeforeTitle>
|
|
120
|
+
name="repository.card.beforeTitle"
|
|
121
|
+
props={{ repository }}
|
|
122
|
+
/>
|
|
123
|
+
<Card.Title level={4}>
|
|
124
|
+
<StyledLink to={repositoryLink} ref={ref}>
|
|
125
|
+
{repository.name}{" "}
|
|
126
|
+
</StyledLink>
|
|
127
|
+
</Card.Title>
|
|
128
|
+
</Card.Row>
|
|
129
|
+
<DescriptionRow className="is-size-7">{repository.description}</DescriptionRow>
|
|
130
|
+
<DetailsRow className="is-flex is-align-items-center is-justify-content-space-between is-flex-wrap-wrap">
|
|
131
|
+
<span className="is-size-7 has-text-secondary is-relative">
|
|
132
|
+
{t("overview.lastModified")}{" "}
|
|
133
|
+
<DateFromNow baseDate={baseDate} date={repository.lastModified ?? repository.creationDate} />
|
|
134
|
+
</span>
|
|
135
|
+
<RepositoryFlags repository={repository} />
|
|
136
|
+
</DetailsRow>
|
|
137
|
+
</Card>
|
|
165
138
|
);
|
|
166
139
|
};
|
|
167
140
|
|
|
@@ -24,8 +24,9 @@
|
|
|
24
24
|
|
|
25
25
|
import React, { FC } from "react";
|
|
26
26
|
import { Color, Size } from "../styleConstants";
|
|
27
|
-
import
|
|
28
|
-
import
|
|
27
|
+
import { Card } from "@scm-manager/ui-layout";
|
|
28
|
+
import { Tooltip } from "@scm-manager/ui-overlays";
|
|
29
|
+
import { TooltipLocation } from "../Tooltip";
|
|
29
30
|
|
|
30
31
|
type Props = {
|
|
31
32
|
color?: Color;
|
|
@@ -36,10 +37,10 @@ type Props = {
|
|
|
36
37
|
};
|
|
37
38
|
|
|
38
39
|
const RepositoryFlag: FC<Props> = ({ children, title, size = "small", tooltipLocation = "bottom", ...props }) => (
|
|
39
|
-
<Tooltip
|
|
40
|
-
<Tag
|
|
40
|
+
<Tooltip side={tooltipLocation} message={title}>
|
|
41
|
+
<Card.Details.Detail.Tag {...props} className={`is-${size} is-relative`}>
|
|
41
42
|
{children}
|
|
42
|
-
</Tag>
|
|
43
|
+
</Card.Details.Detail.Tag>
|
|
43
44
|
</Tooltip>
|
|
44
45
|
);
|
|
45
46
|
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
import React, { FC, useState } from "react";
|
|
25
25
|
import { useTranslation } from "react-i18next";
|
|
26
26
|
import classNames from "classnames";
|
|
27
|
-
import styled from "styled-components";
|
|
28
27
|
import { Repository } from "@scm-manager/ui-types";
|
|
29
28
|
import { ExtensionPoint, extensionPoints } from "@scm-manager/ui-extensions";
|
|
30
29
|
import { TooltipLocation } from "../Tooltip";
|
|
31
30
|
import RepositoryFlag from "./RepositoryFlag";
|
|
32
31
|
import HealthCheckFailureDetail from "./HealthCheckFailureDetail";
|
|
32
|
+
import styled from "styled-components";
|
|
33
33
|
|
|
34
34
|
type Props = {
|
|
35
35
|
repository: Repository;
|
|
@@ -37,10 +37,8 @@ type Props = {
|
|
|
37
37
|
tooltipLocation?: TooltipLocation;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
const
|
|
41
|
-
.
|
|
42
|
-
margin-left: 0.25rem;
|
|
43
|
-
}
|
|
40
|
+
const GapedContainer = styled.div`
|
|
41
|
+
gap: 0.5rem;
|
|
44
42
|
`;
|
|
45
43
|
|
|
46
44
|
const RepositoryFlags: FC<Props> = ({ repository, className, tooltipLocation = "right" }) => {
|
|
@@ -86,17 +84,15 @@ const RepositoryFlags: FC<Props> = ({ repository, className, tooltipLocation = "
|
|
|
86
84
|
);
|
|
87
85
|
|
|
88
86
|
return (
|
|
89
|
-
<
|
|
87
|
+
<GapedContainer className={classNames("is-flex", "is-align-items-center", "is-flex-wrap-wrap", className)}>
|
|
90
88
|
{modal}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
</RepositoryFlagContainer>
|
|
99
|
-
</div>
|
|
89
|
+
{repositoryFlags}
|
|
90
|
+
<ExtensionPoint<extensionPoints.RepositoryFlags>
|
|
91
|
+
name="repository.flags"
|
|
92
|
+
props={{ repository, tooltipLocation }}
|
|
93
|
+
renderAll={true}
|
|
94
|
+
/>
|
|
95
|
+
</GapedContainer>
|
|
100
96
|
);
|
|
101
97
|
};
|
|
102
98
|
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import Icon from "../Icon";
|
|
26
|
-
import { storiesOf } from "@storybook/react";
|
|
27
|
-
import { MemoryRouter } from "react-router-dom";
|
|
28
|
-
import React from "react";
|
|
29
|
-
import GroupEntry from "./GroupEntry";
|
|
30
|
-
import { Button, ButtonGroup } from "../buttons";
|
|
31
|
-
import copyToClipboard from "../CopyToClipboard";
|
|
32
|
-
|
|
33
|
-
const link = "/foo/bar";
|
|
34
|
-
const avatar = <Icon name="icons fa-2x fa-fw" alt="avatar" />;
|
|
35
|
-
const name = <strong className="m-0">main content</strong>;
|
|
36
|
-
const description = <small>more text</small>;
|
|
37
|
-
const longName = (
|
|
38
|
-
<strong className="m-0">
|
|
39
|
-
Very-important-repository-with-a-particular-long-but-easily-rememberable-name-which-also-is-written-in-kebab-case
|
|
40
|
-
</strong>
|
|
41
|
-
);
|
|
42
|
-
const contentRight = (
|
|
43
|
-
<ButtonGroup>
|
|
44
|
-
<Button
|
|
45
|
-
icon={"download"}
|
|
46
|
-
title={"Copy clone command to clipboard"}
|
|
47
|
-
action={() => copyToClipboard("git clone {url}")}
|
|
48
|
-
/>
|
|
49
|
-
</ButtonGroup>
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
storiesOf("GroupEntry", module)
|
|
53
|
-
.addDecorator((story) => <MemoryRouter initialEntries={["/"]}>{story()}</MemoryRouter>)
|
|
54
|
-
.addDecorator((storyFn) => <div className="m-5">{storyFn()}</div>)
|
|
55
|
-
.add("Default", () => (
|
|
56
|
-
<GroupEntry link={link} avatar={avatar} name={name} description={description} contentRight={contentRight} />
|
|
57
|
-
))
|
|
58
|
-
.add("With long texts", () => (
|
|
59
|
-
<GroupEntry
|
|
60
|
-
link={link}
|
|
61
|
-
avatar={avatar}
|
|
62
|
-
name={longName}
|
|
63
|
-
description={
|
|
64
|
-
<small>
|
|
65
|
-
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et
|
|
66
|
-
dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
|
|
67
|
-
clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet,
|
|
68
|
-
consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
|
|
69
|
-
sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea
|
|
70
|
-
takimata sanctus est Lorem ipsum dolor sit amet.
|
|
71
|
-
</small>
|
|
72
|
-
}
|
|
73
|
-
contentRight={contentRight}
|
|
74
|
-
/>
|
|
75
|
-
));
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
import React, { FC, ReactNode } from "react";
|
|
25
|
-
import { Link } from "react-router-dom";
|
|
26
|
-
import classNames from "classnames";
|
|
27
|
-
import styled from "styled-components";
|
|
28
|
-
import { useTranslation } from "react-i18next";
|
|
29
|
-
import { useKeyboardIteratorTarget } from "@scm-manager/ui-shortcuts";
|
|
30
|
-
|
|
31
|
-
const StyledGroupEntry = styled.div`
|
|
32
|
-
max-height: calc(90px - 1.5rem);
|
|
33
|
-
width: 100%;
|
|
34
|
-
pointer-events: all;
|
|
35
|
-
`;
|
|
36
|
-
|
|
37
|
-
const OverlayLink = styled(Link)`
|
|
38
|
-
width: 100%;
|
|
39
|
-
position: absolute;
|
|
40
|
-
height: calc(90px - 1.5rem);
|
|
41
|
-
pointer-events: all;
|
|
42
|
-
border-radius: 4px;
|
|
43
|
-
:hover {
|
|
44
|
-
cursor: pointer;
|
|
45
|
-
}
|
|
46
|
-
`;
|
|
47
|
-
|
|
48
|
-
const Avatar = styled.div`
|
|
49
|
-
.predefined-avatar {
|
|
50
|
-
height: 48px;
|
|
51
|
-
width: 48px;
|
|
52
|
-
font-size: 1.75rem;
|
|
53
|
-
}
|
|
54
|
-
`;
|
|
55
|
-
|
|
56
|
-
const Description = styled.p`
|
|
57
|
-
height: 1.5rem;
|
|
58
|
-
text-overflow: ellipsis;
|
|
59
|
-
overflow-x: hidden;
|
|
60
|
-
overflow-y: visible;
|
|
61
|
-
white-space: nowrap;
|
|
62
|
-
word-break: break-all;
|
|
63
|
-
`;
|
|
64
|
-
|
|
65
|
-
const ContentLeft = styled.div`
|
|
66
|
-
min-width: 0;
|
|
67
|
-
`;
|
|
68
|
-
|
|
69
|
-
const ContentRight = styled.div`
|
|
70
|
-
pointer-events: all;
|
|
71
|
-
margin-bottom: -10px;
|
|
72
|
-
`;
|
|
73
|
-
|
|
74
|
-
type Props = {
|
|
75
|
-
title?: string;
|
|
76
|
-
avatar: string | ReactNode;
|
|
77
|
-
name: string | ReactNode;
|
|
78
|
-
description?: string | ReactNode;
|
|
79
|
-
contentRight?: ReactNode;
|
|
80
|
-
link: string;
|
|
81
|
-
ariaLabel?: string;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const GroupEntry: FC<Props> = ({ link, avatar, title, name, description, contentRight, ariaLabel }) => {
|
|
85
|
-
const [t] = useTranslation("repos");
|
|
86
|
-
const ref = useKeyboardIteratorTarget();
|
|
87
|
-
return (
|
|
88
|
-
<div className="is-relative">
|
|
89
|
-
<OverlayLink
|
|
90
|
-
ref={ref}
|
|
91
|
-
to={link}
|
|
92
|
-
className="has-hover-background-blue"
|
|
93
|
-
aria-label={t("overview.ariaLabel", { name: ariaLabel })}
|
|
94
|
-
/>
|
|
95
|
-
<StyledGroupEntry
|
|
96
|
-
className={classNames("is-flex", "is-justify-content-space-between", "is-align-items-center", "p-2")}
|
|
97
|
-
title={title}
|
|
98
|
-
>
|
|
99
|
-
<ContentLeft className={classNames("is-flex", "is-flex-grow-1", "is-align-items-center")}>
|
|
100
|
-
<Avatar className="mr-4">{avatar}</Avatar>
|
|
101
|
-
<div className={classNames("is-flex-grow-1", "is-clipped")}>
|
|
102
|
-
<div className="mx-1">{name}</div>
|
|
103
|
-
<Description className="mx-1">{description}</Description>
|
|
104
|
-
</div>
|
|
105
|
-
</ContentLeft>
|
|
106
|
-
<ContentRight
|
|
107
|
-
className={classNames(
|
|
108
|
-
"is-hidden-touch",
|
|
109
|
-
"is-flex",
|
|
110
|
-
"is-flex-shrink-0",
|
|
111
|
-
"is-justify-content-flex-end",
|
|
112
|
-
"pl-5"
|
|
113
|
-
)}
|
|
114
|
-
>
|
|
115
|
-
{contentRight}
|
|
116
|
-
</ContentRight>
|
|
117
|
-
</StyledGroupEntry>
|
|
118
|
-
</div>
|
|
119
|
-
);
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export default GroupEntry;
|