From ed68f2e9015f3ac94ef1d5f7bf2941611625c60d Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Thu, 29 Oct 2015 17:45:33 -0400 Subject: Refactoring center channel --- web/react/utils/channel_intro_mssages.jsx | 218 ++++++++++++++++++++++++++++++ 1 file changed, 218 insertions(+) create mode 100644 web/react/utils/channel_intro_mssages.jsx (limited to 'web/react/utils') diff --git a/web/react/utils/channel_intro_mssages.jsx b/web/react/utils/channel_intro_mssages.jsx new file mode 100644 index 000000000..b3f868456 --- /dev/null +++ b/web/react/utils/channel_intro_mssages.jsx @@ -0,0 +1,218 @@ + +// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +const Utils = require('./utils.jsx'); +const UserProfile = require('../components/user_profile.jsx'); +const ChannelStore = require('../stores/channel_store.jsx'); +const Constants = require('../utils/constants.jsx'); +const TeamStore = require('../stores/team_store.jsx'); + +export function createChannelIntroMessage(channel) { + if (channel.type === 'D') { + return createDMIntroMessage(channel); + } else if (ChannelStore.isDefault(channel)) { + return createDefaultIntroMessage(channel); + } else if (channel.name === Constants.OFFTOPIC_CHANNEL) { + return createOffTopicIntroMessage(channel); + } else if (channel.type === 'O' || channel.type === 'P') { + return createStandardIntroMessage(channel); + } +} + +export function createDMIntroMessage(channel) { + var teammate = Utils.getDirectTeammate(channel.id); + + if (teammate) { + var teammateName = teammate.username; + if (teammate.nickname.length > 0) { + teammateName = teammate.nickname; + } + + return ( +
+
+ +
+
+ + + +
+

+ {'This is the start of your direct message history with ' + teammateName + '.'}
+ {'Direct messages and files shared here are not shown to people outside this area.'} +

+ + {'Set a header'} + +
+ ); + } + + return ( +
+

{'This is the start of your direct message history with this teammate. Direct messages and files shared here are not shown to people outside this area.'}

+
+ ); +} + +export function createOffTopicIntroMessage(channel) { + return ( +
+

{'Beginning of ' + channel.display_name}

+

+ {'This is the start of ' + channel.display_name + ', a channel for non-work-related conversations.'} +
+

+ + {'Set a header'} + + + {'Invite others to this channel'} + +
+ ); +} + +export function createDefaultIntroMessage(channel) { + const team = TeamStore.getCurrent(); + let inviteModalLink; + if (team.type === Constants.INVITE_TEAM) { + inviteModalLink = ( + + {'Invite others to this team'} + + ); + } else { + inviteModalLink = ( + {'Invite others to this team'} + + ); + } + + return ( +
+

{'Beginning of ' + channel.display_name}

+

+ {'Welcome to ' + channel.display_name + '!'} +

+ {'This is the first channel teammates see when they sign up - use it for posting updates everyone needs to know.'} +

+ {inviteModalLink} + + {'Set a header'} + +
+
+ ); +} + +export function createStandardIntroMessage(channel) { + var uiName = channel.display_name; + var creatorName = ''; + + var uiType; + var memberMessage; + if (channel.type === 'P') { + uiType = 'private group'; + memberMessage = ' Only invited members can see this private group.'; + } else { + uiType = 'channel'; + memberMessage = ' Any member can join and read this channel.'; + } + + var createMessage; + if (creatorName === '') { + createMessage = 'This is the start of the ' + uiName + ' ' + uiType + ', created on ' + Utils.displayDate(channel.create_at) + '.'; + } else { + createMessage = ( + + {'This is the start of the '} + {uiName} + {' '} + {uiType}{', created by '} + {creatorName} + {' on '} + {Utils.displayDate(channel.create_at)} + + ); + } + + return ( +
+

{'Beginning of ' + uiName}

+

+ {createMessage} + {memberMessage} +
+

+ + {'Set a header'} + + + {'Invite others to this ' + uiType} + +
+ ); +} -- cgit v1.2.3-1-g7c22