Skip to content

Commit

Permalink
journeycard canShowcase condition (keybase#22287)
Browse files Browse the repository at this point in the history
* journeycard canShowcase condition

* sort-keys disagrees with vscode ordering

* canShowcase

* imperative
  • Loading branch information
mlsteele authored Jan 30, 2020
1 parent 98a881e commit e608c6d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
29 changes: 18 additions & 11 deletions shared/chat/conversation/messages/cards/team-journey/container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type OwnProps = {
}

type Props = {
canShowcase: boolean
cannotWrite: boolean
channelname: string
conversationIDKey: ChatTypes.ConversationIDKey
Expand Down Expand Up @@ -47,18 +48,22 @@ const TeamJourneyContainer = (props: Props) => {

switch (props.message.cardType) {
case RPCChatTypes.JourneycardType.welcome:
actions =
props.teamType === 'big'
? [
{label: 'Browse channels', onClick: props.onBrowseChannels},
{label: 'Publish team on your profile', onClick: props.onPublishTeam},
]
: [{label: 'Publish team on your profile', onClick: props.onPublishTeam}]
image = 'icon-illustration-welcome-96'
if (!props.cannotWrite) {
actions.unshift('wave')
actions.push('wave')
}
image = 'icon-illustration-welcome-96'
textComponent = (
if (props.teamType === 'big') {
actions.push({label: 'Browse channels', onClick: props.onBrowseChannels})
}
if (props.canShowcase) {
actions.push({label: 'Publish team on your profile', onClick: props.onPublishTeam})
}
textComponent = props.cannotWrite ? (
<Kb.Text type="BodySmall">
<Kb.Emoji allowFontScaling={true} size={Styles.globalMargins.small} emojiName=":wave:" /> Welcome to
the team!
</Kb.Text>
) : (
<Kb.Text type="BodySmall">
<Kb.Emoji allowFontScaling={true} size={Styles.globalMargins.small} emojiName=":wave:" /> Welcome to
the team! Say hi to everyone and introduce yourself.
Expand Down Expand Up @@ -164,6 +169,7 @@ const TeamJourneyConnected = Container.connect(
return {
_channelInfos: TeamConstants.getTeamChannelInfos(state, teamID),
_teamID: teamID,
canShowcase: TeamConstants.canShowcase(state, teamID),
cannotWrite: cannotWrite,
channelname,
conversationIDKey,
Expand Down Expand Up @@ -197,7 +203,7 @@ const TeamJourneyConnected = Container.connect(
dispatch(RouteTreeGen.createNavigateAppend({path: [teamsTab, {props: {teamID}, selected: 'team'}]})),
}),
(stateProps, dispatchProps, ownProps) => {
const {cannotWrite, channelname, conversationIDKey, teamname, teamType} = stateProps
const {canShowcase, cannotWrite, channelname, conversationIDKey, teamname, teamType} = stateProps
// Take the top three channels with most recent activity.
const joinableStatuses = new Set([
// keep in sync with journey_card_manager.go
Expand All @@ -218,6 +224,7 @@ const TeamJourneyConnected = Container.connect(
.map(info => info.channelname)

return {
canShowcase,
cannotWrite,
channelname,
conversationIDKey,
Expand Down
5 changes: 5 additions & 0 deletions shared/constants/teams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,11 @@ export const annotatedInvitesToInviteInfo = (
export const getTeamDetails = (state: TypedState, teamID: Types.TeamID) =>
state.teams.teamDetails.get(teamID) || emptyTeamDetails

export const canShowcase = (state: TypedState, teamID: Types.TeamID) => {
const role = getRole(state, teamID)
return getTeamDetails(state, teamID).allowPromote || role === 'admin' || role === 'owner'
}

const _canUserPerformCache: {[key: string]: Types.TeamOperations} = {}
const _canUserPerformCacheKey = (t: Types.TeamRoleAndDetails) => t.role + t.implicitAdmin
const deriveCanPerform = (roleAndDetails?: Types.TeamRoleAndDetails): Types.TeamOperations => {
Expand Down

0 comments on commit e608c6d

Please sign in to comment.