From 84402b97227789c9c5f28c317324cfecb338d436 Mon Sep 17 00:00:00 2001 From: Konstantin Schaper Date: Thu, 23 Jun 2022 11:52:21 +0200 Subject: [PATCH] allow card columns to omit the link (#2076) The landing-page-plugin is using the CardColumnSmall component from ui-components to display event as tiles. Most events have a link, but some, like the RepositoryDeletedEvent do not. For a better UX it is therefore necessary, to have a CardColumnSmall that is not internally wrapped in a link. --- gradle/changelog/linkless_card_column.yaml | 2 + .../src/CardColumnSmall.stories.tsx | 8 ++++ scm-ui/ui-components/src/CardColumnSmall.tsx | 45 ++++++++++--------- .../src/__snapshots__/storyshots.test.ts.snap | 43 ++++++++++++++++++ 4 files changed, 76 insertions(+), 22 deletions(-) create mode 100644 gradle/changelog/linkless_card_column.yaml diff --git a/gradle/changelog/linkless_card_column.yaml b/gradle/changelog/linkless_card_column.yaml new file mode 100644 index 0000000000..734c340da7 --- /dev/null +++ b/gradle/changelog/linkless_card_column.yaml @@ -0,0 +1,2 @@ +- type: added + description: Developers can omit the link prop of the CardColumnSmall component ([#2076](https://github.com/scm-manager/scm-manager/pull/2076)) diff --git a/scm-ui/ui-components/src/CardColumnSmall.stories.tsx b/scm-ui/ui-components/src/CardColumnSmall.stories.tsx index 7154376eb0..080a879883 100644 --- a/scm-ui/ui-components/src/CardColumnSmall.stories.tsx +++ b/scm-ui/ui-components/src/CardColumnSmall.stories.tsx @@ -53,4 +53,12 @@ storiesOf("CardColumnSmall", module) contentRight={over 42 years ago} footer="New: scmadmin/spaceship" /> + )) + .add("Linkless", () => ( + } + contentLeft={Repository deleted} + contentRight={over 1337 minutes ago} + footer="Deleted: scmadmin/spaceship" + /> )); diff --git a/scm-ui/ui-components/src/CardColumnSmall.tsx b/scm-ui/ui-components/src/CardColumnSmall.tsx index 7f220890c0..c990bdd5d8 100644 --- a/scm-ui/ui-components/src/CardColumnSmall.tsx +++ b/scm-ui/ui-components/src/CardColumnSmall.tsx @@ -28,7 +28,7 @@ import styled from "styled-components"; import { Link } from "react-router-dom"; type Props = { - link: string; + link?: string; avatar?: ReactNode; contentLeft: ReactNode; contentRight: ReactNode; @@ -42,30 +42,31 @@ const StyledLink = styled(Link)` const CardColumnSmall: FC = ({ link, avatar, contentLeft, contentRight, footer }) => { const renderAvatar = avatar ?
{avatar}
: null; const renderFooter = footer ? {footer} : null; - - return ( - -
- {renderAvatar} -
-
-
{contentLeft}
-
{contentRight}
-
- {renderFooter} + const content = ( +
+ {renderAvatar} +
+
+
{contentLeft}
+
{contentRight}
+ {renderFooter}
- +
); + if (!link) { + return content; + } + return {content}; }; export default CardColumnSmall; diff --git a/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap b/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap index 56ae2b057c..583f2c39c6 100644 --- a/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap +++ b/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap @@ -1282,6 +1282,49 @@ exports[`Storyshots CardColumnSmall Default 1`] = `
`; +exports[`Storyshots CardColumnSmall Linkless 1`] = ` +
+
+
+ +
+
+
+
+ + Repository deleted + +
+
+ + over 1337 minutes ago + +
+
+ + Deleted: scmadmin/spaceship + +
+
+
+`; + exports[`Storyshots CardColumnSmall Minimal 1`] = `