// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import * as Utils from './utils.jsx'; import ChannelInviteModal from 'components/channel_invite_modal.jsx'; import EditChannelHeaderModal from 'components/edit_channel_header_modal.jsx'; import ToggleModalButton from 'components/toggle_modal_button.jsx'; import UserProfile from 'components/user_profile.jsx'; import ChannelStore from 'stores/channel_store.jsx'; import UserStore from 'stores/user_store.jsx'; import TeamStore from 'stores/team_store.jsx'; import Constants from 'utils/constants.jsx'; import * as GlobalActions from 'actions/global_actions.jsx'; import Client from 'client/web_client.jsx'; import ProfilePicture from 'components/profile_picture.jsx'; import React from 'react'; import {FormattedMessage, FormattedHTMLMessage, FormattedDate} from 'react-intl'; export function createChannelIntroMessage(channel, fullWidthIntro) { let centeredIntro = ''; if (!fullWidthIntro) { centeredIntro = 'channel-intro--centered'; } if (channel.type === Constants.DM_CHANNEL) { return createDMIntroMessage(channel, centeredIntro); } else if (channel.type === Constants.GM_CHANNEL) { return createGMIntroMessage(channel, centeredIntro); } else if (ChannelStore.isDefault(channel)) { return createDefaultIntroMessage(channel, centeredIntro); } else if (channel.name === Constants.OFFTOPIC_CHANNEL) { return createOffTopicIntroMessage(channel, centeredIntro); } else if (channel.type === 'O' || channel.type === 'P') { return createStandardIntroMessage(channel, centeredIntro); } return null; } export function createGMIntroMessage(channel, centeredIntro) { const profiles = UserStore.getProfileListInChannel(channel.id, true); if (profiles.length > 0) { const pictures = []; let names = ''; for (let i = 0; i < profiles.length; i++) { const profile = profiles[i]; pictures.push( ); if (i === profiles.length - 1) { names += Utils.displayUsernameForUser(profile); } else if (i === profiles.length - 2) { names += Utils.displayUsernameForUser(profile) + ' and '; } else { names += Utils.displayUsernameForUser(profile) + ', '; } } return (
{pictures}

{createSetHeaderButton(channel)}
); } return (

); } export function createDMIntroMessage(channel, centeredIntro) { var teammate = Utils.getDirectTeammate(channel.id); if (teammate) { var teammateName = teammate.username; if (teammate.nickname.length > 0) { teammateName = teammate.nickname; } return (

{createSetHeaderButton(channel)}
); } return (

); } export function createOffTopicIntroMessage(channel, centeredIntro) { return (
{createInviteChannelMemberButton(channel, 'channel')} {createSetHeaderButton(channel)}
); } export function createDefaultIntroMessage(channel, centeredIntro) { let inviteModalLink = ( ); const isAdmin = TeamStore.isTeamAdminForCurrentTeam() || UserStore.isSystemAdminForCurrentUser(); const isSystemAdmin = UserStore.isSystemAdminForCurrentUser(); if (global.window.mm_license.IsLicensed === 'true') { if (global.window.mm_config.RestrictTeamInvite === Constants.PERMISSIONS_SYSTEM_ADMIN && !isSystemAdmin) { inviteModalLink = null; } else if (global.window.mm_config.RestrictTeamInvite === Constants.PERMISSIONS_TEAM_ADMIN && !isAdmin) { inviteModalLink = null; } } return (
{inviteModalLink} {createSetHeaderButton(channel)}
); } export function createStandardIntroMessage(channel, centeredIntro) { var uiName = channel.display_name; var creatorName = Utils.displayUsername(channel.creator_id); var uiType; var memberMessage; if (channel.type === 'P') { uiType = ( ); memberMessage = ( ); } else { uiType = ( ); memberMessage = ( ); } const date = ( ); var createMessage; if (creatorName === '') { createMessage = ( ); } else { createMessage = ( ); } var purposeMessage = ''; if (channel.purpose && channel.purpose !== '') { purposeMessage = ( ); } return (

{createMessage} {memberMessage} {purposeMessage}

{createInviteChannelMemberButton(channel, uiType)} {createSetHeaderButton(channel)}
); } function createInviteChannelMemberButton(channel, uiType) { return ( ); } function createSetHeaderButton(channel) { return ( ); }