Skip to content

Commit da72a91

Browse files
committed
Tweak release card details, show description at the bottom with avatar
1 parent 5eebea8 commit da72a91

1 file changed

Lines changed: 57 additions & 20 deletions

File tree

packages/components/src/components/cards/BaseCard.shared.ts

Lines changed: 57 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ import { smallLabelHeight } from '../common/Label'
6969
import { cardActionsHeight } from './partials/CardActions'
7070
import { cardItemSeparatorSize } from './partials/CardItemSeparator'
7171

72+
// since we moved plans to the server we cant get this statically anymore
73+
// only via the usePlans hook
74+
const cheapestPlanWithNotifications: Plan | undefined = undefined
75+
7276
const _iconSize = smallAvatarSize - 4
7377
const _iconContainerSize = smallAvatarSize
7478
const _actionFontSize = smallerTextSize
@@ -179,14 +183,16 @@ function getRepoText({
179183
const repoNameOrFullName =
180184
(ownerIsKnown && getOwnerAndRepo(repoFullName).repo) || repoFullName
181185

182-
if (repoIsKnown && issueOrPullRequestNumber)
183-
return `#${issueOrPullRequestNumber || ''}`
184-
185-
if (repoNameOrFullName && issueOrPullRequestNumber)
186-
return `${repoNameOrFullName}#${issueOrPullRequestNumber}`
186+
if (issueOrPullRequestNumber) {
187+
if (repoIsKnown) return `#${issueOrPullRequestNumber}`
188+
if (repoNameOrFullName)
189+
return `${repoNameOrFullName}#${issueOrPullRequestNumber}`
190+
}
187191

188-
if (repoNameOrFullName && branchOrTagName)
189-
return `${repoNameOrFullName}#${branchOrTagName}`
192+
if (branchOrTagName) {
193+
if (repoIsKnown) return `${branchOrTagName}`
194+
if (repoNameOrFullName) return `${repoNameOrFullName}#${branchOrTagName}`
195+
}
190196

191197
return repoNameOrFullName
192198
}
@@ -216,13 +222,12 @@ function getPrivateBannerCardProps(
216222
subitems: undefined,
217223
subtitle: undefined,
218224
text: {
219-
text: 'Tap to unlock private repos',
220-
// text:
221-
// cheapestPlanWithNotifications && cheapestPlanWithNotifications.amount
222-
// ? `Unlock private repos for ${formatPriceAndInterval(
223-
// cheapestPlanWithNotifications,
224-
// )}`
225-
// : 'Tap to unlock private repos',
225+
text:
226+
cheapestPlanWithNotifications && cheapestPlanWithNotifications.amount
227+
? `Unlock private repos for ${formatPriceAndInterval(
228+
cheapestPlanWithNotifications,
229+
)}`
230+
: 'Tap to unlock private repos',
226231
},
227232
title:
228233
type === 'activity'
@@ -721,8 +726,20 @@ function _getCardPropsForItem(
721726
fixURL(release.url, { tagName: branchOrTagName })!,
722727
nodeIdOrId: getItemNodeIdOrId(item)!,
723728
showPrivateLock: isPrivate,
724-
subitems: [],
725-
subtitle: trimNewLinesAndSpaces(stripMarkdown(release.body), 120),
729+
subitems: [
730+
{
731+
avatar: {
732+
imageURL: getUserAvatarFromObject(
733+
release.author,
734+
{},
735+
PixelRatio.getPixelSizeForLayoutSize,
736+
)!,
737+
linkURL: getUserURLFromObject(release.author)!,
738+
},
739+
text: trimNewLinesAndSpaces(stripMarkdown(release.body), 120),
740+
},
741+
],
742+
subtitle: undefined,
726743
text: {
727744
text: getRepoText({
728745
branchOrTagName:
@@ -1003,6 +1020,7 @@ function _getCardPropsForItem(
10031020
repoIsKnown,
10041021
issueOrPullRequestNumber:
10051022
(issueOrPullRequest && issueOrPullRequest.number) || undefined,
1023+
branchOrTagName: release && release.tag_name,
10061024
})!,
10071025
repo: { owner: repoOwnerName!, name: repoName!, url: repoURL! },
10081026
},
@@ -1100,10 +1118,29 @@ function _getCardPropsForItem(
11001118
...defaultProps,
11011119
...(release &&
11021120
release.body && {
1103-
subtitle: trimNewLinesAndSpaces(
1104-
stripMarkdown(release.body),
1105-
120,
1106-
),
1121+
...(defaultProps.text &&
1122+
release.tag_name === defaultProps.text.text && {
1123+
text: {
1124+
text: ' ',
1125+
},
1126+
}),
1127+
subitems: [
1128+
...(defaultProps.subitems || []),
1129+
{
1130+
avatar: {
1131+
imageURL: getUserAvatarFromObject(
1132+
release.author,
1133+
{},
1134+
PixelRatio.getPixelSizeForLayoutSize,
1135+
)!,
1136+
linkURL: getUserURLFromObject(release.author)!,
1137+
},
1138+
text: trimNewLinesAndSpaces(
1139+
stripMarkdown(release.body),
1140+
120,
1141+
),
1142+
},
1143+
],
11071144
}),
11081145
}
11091146
}

0 commit comments

Comments
 (0)