From 2010f74a21bdc0a4838aed0268bf07dc131e410b Mon Sep 17 00:00:00 2001 From: George Goldberg Date: Sun, 15 Jan 2017 13:56:10 +0000 Subject: PLT-5221: Correct error when team description unchanged. (#5055) Also replace all legacy i18n code in the changed file. --- webapp/components/team_general_tab.jsx | 108 ++++++++++----------------------- webapp/i18n/en.json | 7 +-- 2 files changed, 34 insertions(+), 81 deletions(-) diff --git a/webapp/components/team_general_tab.jsx b/webapp/components/team_general_tab.jsx index 955a71ac5..0100cad64 100644 --- a/webapp/components/team_general_tab.jsx +++ b/webapp/components/team_general_tab.jsx @@ -8,60 +8,9 @@ import SettingItemMax from './setting_item_max.jsx'; import * as Utils from 'utils/utils.jsx'; import Constants from 'utils/constants.jsx'; -import {intlShape, injectIntl, defineMessages, FormattedMessage, FormattedHTMLMessage} from 'react-intl'; +import {FormattedMessage} from 'react-intl'; import {updateTeam} from 'actions/team_actions.jsx'; -const holders = defineMessages({ - dirDisabled: { - id: 'general_tab.dirDisabled', - defaultMessage: 'Team Directory has been disabled. Please ask a System Admin to enable the Team Directory in the System Console team settings.' - }, - required: { - id: 'general_tab.required', - defaultMessage: 'This field is required' - }, - chooseName: { - id: 'general_tab.chooseName', - defaultMessage: 'Please choose a new name for your team' - }, - includeDirTitle: { - id: 'general_tab.includeDirTitle', - defaultMessage: 'Include this team in the Team Directory' - }, - yes: { - id: 'general_tab.yes', - defaultMessage: 'Yes' - }, - no: { - id: 'general_tab.no', - defaultMessage: 'No' - }, - dirOff: { - id: 'general_tab.dirOff', - defaultMessage: 'Team directory is turned off for this system.' - }, - openInviteTitle: { - id: 'general_tab.openInviteTitle', - defaultMessage: 'Allow any user with an account on this server to join this team' - }, - codeTitle: { - id: 'general_tab.codeTitle', - defaultMessage: 'Invite Code' - }, - codeDesc: { - id: 'general_tab.codeDesc', - defaultMessage: "Click 'Edit' to regenerate Invite Code." - }, - teamNameInfo: { - id: 'general_tab.teamNameInfo', - defaultMessage: 'Set the name of the team as it appears on your sign-in screen and at the top of the left-hand sidebar.' - }, - teamDescriptionInfo: { - id: 'general_tab.teamDescriptionInfo', - defaultMessage: 'Team description provides additional information to help users select the right team. Maximum of 50 characters.' - } -}); - import React from 'react'; class GeneralTab extends React.Component { @@ -156,13 +105,12 @@ class GeneralTab extends React.Component { var state = {serverError: '', clientError: ''}; let valid = true; - const {formatMessage} = this.props.intl; const name = this.state.name.trim(); if (!name) { - state.clientError = formatMessage(holders.required); + state.clientError = Utils.localizeMessage('general_tab.required', 'This field is required'); valid = false; } else if (name === this.props.team.display_name) { - state.clientError = formatMessage(holders.chooseName); + state.clientError = Utils.localizeMessage('general_tab.chooseName', 'Please choose a new name for your team'); valid = false; } else { state.clientError = ''; @@ -197,7 +145,7 @@ class GeneralTab extends React.Component { if (inviteId) { state.clientError = ''; } else { - state.clientError = this.props.intl.fromatMessage(holders.required); + state.clientError = Utils.localizeMessage('general_tab.required', 'This field is required'); valid = false; } @@ -230,10 +178,9 @@ class GeneralTab extends React.Component { var state = {serverError: '', clientError: ''}; let valid = true; - const {formatMessage} = this.props.intl; const description = this.state.description.trim(); if (description === this.props.team.description) { - state.clientError = formatMessage(holders.chooseName); + state.clientError = Utils.localizeMessage('general_tab.chooseDescription', 'Please choose a new description for your team'); valid = false; } else { state.clientError = ''; @@ -324,8 +271,6 @@ class GeneralTab extends React.Component { serverError = this.state.serverError; } - const {formatMessage} = this.props.intl; - let openInviteSection; if (this.props.activeSection === 'open_invite') { const inputs = [ @@ -372,7 +317,7 @@ class GeneralTab extends React.Component { openInviteSection = ( @@ -427,9 +372,19 @@ class GeneralTab extends React.Component {
- + + + ) + }} />
@@ -437,7 +392,7 @@ class GeneralTab extends React.Component { inviteSection = ( ); @@ -488,11 +443,11 @@ class GeneralTab extends React.Component { ); - const nameExtraInfo = {formatMessage(holders.teamNameInfo)}; + const nameExtraInfo = {Utils.localizeMessage('general_tab.teamNameInfo', 'Set the name of the team as it appears on your sign-in screen and at the top of the left-hand sidebar.')}; nameSection = ( @@ -546,11 +501,11 @@ class GeneralTab extends React.Component { ); - const descriptionExtraInfo = {formatMessage(holders.teamDescriptionInfo)}; + const descriptionExtraInfo = {Utils.localizeMessage('general_tab.teamDescriptionInfo', 'Team description provides additional information to help users select the right team. Maximum of 50 characters.')}; descriptionSection = ( @@ -633,10 +588,9 @@ class GeneralTab extends React.Component { } GeneralTab.propTypes = { - intl: intlShape.isRequired, updateSection: React.PropTypes.func.isRequired, team: React.PropTypes.object.isRequired, activeSection: React.PropTypes.string.isRequired }; -export default injectIntl(GeneralTab); +export default GeneralTab; diff --git a/webapp/i18n/en.json b/webapp/i18n/en.json index 355720fe0..6584c634a 100644 --- a/webapp/i18n/en.json +++ b/webapp/i18n/en.json @@ -1291,14 +1291,13 @@ "flag_post.flag": "Flag for follow up", "flag_post.unflag": "Unflag", "general_tab.chooseName": "Please choose a new name for your team", + "general_tab.chooseDescription": "Please choose a new description for your team", "general_tab.codeDesc": "Click 'Edit' to regenerate Invite Code.", - "general_tab.codeLongDesc": "The Invite Code is used as part of the URL in the team invitation link created by Get Team Invite Link in the main menu. Regenerating creates a new team invitation link and invalidates the previous link.", + "general_tab.codeLongDesc": "The Invite Code is used as part of the URL in the team invitation link created by {getTeamInviteLink} in the main menu. Regenerating creates a new team invitation link and invalidates the previous link.", "general_tab.codeTitle": "Invite Code", - "general_tab.dirDisabled": "Team Directory has been disabled. Please ask a System Admin to enable the Team Directory in the System Console team settings.", - "general_tab.dirOff": "Team directory is turned off for this system.", "general_tab.emptyDescription": "Click 'Edit' to add a team description.", + "general_tab.getTeamInviteLink": "Get Team Invite Link", "general_tab.includeDirDesc": "Including this team will display the team name from the Team Directory section of the Home Page, and provide a link to the sign-in page.", - "general_tab.includeDirTitle": "Include this team in the Team Directory", "general_tab.no": "No", "general_tab.openInviteDesc": "When allowed, a link to this team will be included on the landing page allowing anyone with an account to join this team.", "general_tab.openInviteTitle": "Allow any user with an account on this server to join this team", -- cgit v1.2.3-1-g7c22