From c39ba354d566e4f70f9b3825e0d62bcdef0ac05d Mon Sep 17 00:00:00 2001 From: Reed Garmsen Date: Fri, 8 Jan 2016 14:26:16 -0800 Subject: Fix issue with drag n drop overlay in ie11 --- web/react/utils/utils.jsx | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'web/react') diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index 2ddd0e5e3..8c02c2d93 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -1295,5 +1295,9 @@ export function fillArray(value, length) { // Checks if a data transfer contains files not text, folders, etc.. // Slightly modified from http://stackoverflow.com/questions/6848043/how-do-i-detect-a-file-is-being-dragged-rather-than-a-draggable-element-on-my-pa export function isFileTransfer(files) { + if (isBrowserIE()) { + return files.types != null && files.types.contains('Files'); + } + return files.types != null && (files.types.indexOf ? files.types.indexOf('Files') !== -1 : files.types.contains('application/x-moz-file')); } -- cgit v1.2.3-1-g7c22 From 632370abb5b17ff37e80608865af0c37f7b963ec Mon Sep 17 00:00:00 2001 From: Pat Lathem Date: Wed, 13 Jan 2016 13:50:05 -0600 Subject: Add channel purpose --- web/react/components/channel_info_modal.jsx | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'web/react') diff --git a/web/react/components/channel_info_modal.jsx b/web/react/components/channel_info_modal.jsx index 18e125de3..bf1c346a0 100644 --- a/web/react/components/channel_info_modal.jsx +++ b/web/react/components/channel_info_modal.jsx @@ -10,6 +10,7 @@ export default class ChannelInfoModal extends React.Component { channel = { display_name: 'No Channel Found', name: 'No Channel Found', + purpose: 'No Channel Found', id: 'No Channel Found' }; } @@ -35,6 +36,10 @@ export default class ChannelInfoModal extends React.Component {
{'Channel ID:'}
{channel.id}
+
+
{'Channel Purpose:'}
+
{channel.purpose}
+
{updateText} diff --git a/web/react/components/signup_user_complete.jsx b/web/react/components/signup_user_complete.jsx index df11fe045..ace0d28ae 100644 --- a/web/react/components/signup_user_complete.jsx +++ b/web/react/components/signup_user_complete.jsx @@ -5,6 +5,7 @@ import * as Utils from '../utils/utils.jsx'; import * as client from '../utils/client.jsx'; import UserStore from '../stores/user_store.jsx'; import BrowserStore from '../stores/browser_store.jsx'; +import Constants from '../utils/constants.jsx'; export default class SignupUserComplete extends React.Component { constructor(props) { @@ -51,7 +52,7 @@ export default class SignupUserComplete extends React.Component { return; } else if (usernameError) { this.setState({ - nameError: 'Username must begin with a letter, and contain between 3 to 15 lowercase characters made up of numbers, letters, and the symbols \'.\', \'-\' and \'_\'.', + nameError: 'Username must begin with a letter, and contain between ' + Constants.MIN_USERNAME_LENGTH + ' to ' + Constants.MAX_USERNAME_LENGTH + ' lowercase characters made up of numbers, letters, and the symbols \'.\', \'-\' and \'_\'.', emailError: '', passwordError: '', serverError: '' @@ -60,8 +61,8 @@ export default class SignupUserComplete extends React.Component { } const providedPassword = ReactDOM.findDOMNode(this.refs.password).value.trim(); - if (!providedPassword || providedPassword.length < 5) { - this.setState({nameError: '', emailError: '', passwordError: 'Please enter at least 5 characters', serverError: ''}); + if (!providedPassword || providedPassword.length < Constants.MIN_PASSWORD_LENGTH) { + this.setState({nameError: '', emailError: '', passwordError: 'Please enter at least ' + Constants.MIN_PASSWORD_LENGTH + ' characters', serverError: ''}); return; } @@ -111,7 +112,7 @@ export default class SignupUserComplete extends React.Component { client.track('signup', 'signup_user_01_welcome'); if (this.state.wizard === 'finished') { - return
You've already completed the signup process for this invitation or this invitation has expired.
; + return
{"You've already completed the signup process for this invitation or this invitation has expired."}
; } // set up error labels @@ -123,9 +124,11 @@ export default class SignupUserComplete extends React.Component { } var nameError = null; + var nameHelpText = {'Username must begin with a letter, and contain between ' + Constants.MIN_USERNAME_LENGTH + ' to ' + Constants.MAX_USERNAME_LENGTH + " lowercase characters made up of numbers, letters, and the symbols '.', '-' and '_'"}; var nameDivStyle = 'form-group'; if (this.state.nameError) { nameError = ; + nameHelpText = ''; nameDivStyle += ' has-error'; } @@ -148,7 +151,7 @@ export default class SignupUserComplete extends React.Component { // set up the email entry and hide it if an email was provided var yourEmailIs = ''; if (this.state.user.email) { - yourEmailIs = Your email address is {this.state.user.email}. You'll use this address to sign in to {global.window.mm_config.SiteName}.; + yourEmailIs = {'Your email address is '}{this.state.user.email}{". You'll use this address to sign in to " + global.window.mm_config.SiteName + '.'}; } var emailContainerStyle = 'margin--extra'; @@ -158,7 +161,7 @@ export default class SignupUserComplete extends React.Component { var email = (
-
What's your email address?
+
{"What's your email address?"}
-
Choose your username
+
{'Choose your username'}
{nameError} - Username must begin with a letter, and contain between 3 to 15 lowercase characters made up of numbers, letters, and the symbols '.', '-' and '_' + {nameHelpText}
-
Choose your password
+
{'Choose your password'}
- Create Account + {'Create Account'}

@@ -255,7 +258,7 @@ export default class SignupUserComplete extends React.Component {
{signupMessage}
- or + {'or'}
); @@ -268,10 +271,10 @@ export default class SignupUserComplete extends React.Component { className='signup-team-logo' src='/static/images/logo.png' /> -
Welcome to:
+
{'Welcome to:'}

{this.props.teamDisplayName}

-

on {global.window.mm_config.SiteName}

-

Let's create your account

+

{'on ' + global.window.mm_config.SiteName}

+

{"Let's create your account"}

{signupMessage} {emailSignup} {serverError} diff --git a/web/react/components/team_signup_password_page.jsx b/web/react/components/team_signup_password_page.jsx index 378c7fe2c..7e11d38c3 100644 --- a/web/react/components/team_signup_password_page.jsx +++ b/web/react/components/team_signup_password_page.jsx @@ -4,6 +4,7 @@ import * as Client from '../utils/client.jsx'; import BrowserStore from '../stores/browser_store.jsx'; import UserStore from '../stores/user_store.jsx'; +import Constants from '../utils/constants.jsx'; export default class TeamSignupPasswordPage extends React.Component { constructor(props) { @@ -23,8 +24,8 @@ export default class TeamSignupPasswordPage extends React.Component { e.preventDefault(); var password = ReactDOM.findDOMNode(this.refs.password).value.trim(); - if (!password || password.length < 5) { - this.setState({passwordError: 'Please enter at least 5 characters'}); + if (!password || password.length < Constants.MIN_PASSWORD_LENGTH) { + this.setState({passwordError: 'Please enter at least ' + Constants.MIN_PASSWORD_LENGTH + ' characters'}); return; } @@ -92,15 +93,15 @@ export default class TeamSignupPasswordPage extends React.Component { className='signup-team-logo' src='/static/images/logo.png' /> -

Your password

-
Select a password that you'll use to login with your email address:
+

{'Your password'}

+
{"Select a password that you'll use to login with your email address:"}
-
Email
+
{'Email'}
{this.props.state.team.email}
-
Choose your password
+
{'Choose your password'}
- Passwords must contain 5 to 50 characters. Your password will be strongest if it contains a mix of symbols, numbers, and upper and lowercase characters. + {'Passwords must contain ' + Constants.MIN_PASSWORD_LENGTH + ' to ' + Constants.MAX_PASSWORD_LENGTH + ' characters. Your password will be strongest if it contains a mix of symbols, numbers, and upper and lowercase characters.'}
{passwordError} @@ -125,7 +126,7 @@ export default class TeamSignupPasswordPage extends React.Component { data-loading-text={' Creating team...'} onClick={this.submitNext} > - Finish + {'Finish'}

By proceeding to create your account and use {global.window.mm_config.SiteName}, you agree to our Terms of Service and Privacy Policy. If you do not agree, you cannot use {global.window.mm_config.SiteName}.

@@ -134,7 +135,7 @@ export default class TeamSignupPasswordPage extends React.Component { href='#' onClick={this.submitBack} > - Back to previous step + {'Back to previous step'}
diff --git a/web/react/components/team_signup_username_page.jsx b/web/react/components/team_signup_username_page.jsx index de239f169..6ccab6656 100644 --- a/web/react/components/team_signup_username_page.jsx +++ b/web/react/components/team_signup_username_page.jsx @@ -3,6 +3,7 @@ import * as Utils from '../utils/utils.jsx'; import * as Client from '../utils/client.jsx'; +import Constants from '../utils/constants.jsx'; export default class TeamSignupUsernamePage extends React.Component { constructor(props) { @@ -33,7 +34,7 @@ export default class TeamSignupUsernamePage extends React.Component { this.setState({nameError: 'This username is reserved, please choose a new one.'}); return; } else if (usernameError) { - this.setState({nameError: 'Username must begin with a letter, and contain 3 to 15 characters in total, which may be numbers, lowercase letters, or any of the symbols \'.\', \'-\', or \'_\''}); + this.setState({nameError: 'Username must begin with a letter, and contain between ' + Constants.MIN_USERNAME_LENGTH + ' to ' + Constants.MAX_USERNAME_LENGTH + ' characters in total, which may be numbers, lowercase letters, or any of the symbols \'.\', \'-\', or \'_\''}); return; } @@ -45,9 +46,11 @@ export default class TeamSignupUsernamePage extends React.Component { Client.track('signup', 'signup_team_06_username'); var nameError = null; + var nameHelpText = {'Usernames must begin with a letter and contain between ' + Constants.MIN_USERNAME_LENGTH + ' to ' + Constants.MAX_USERNAME_LENGTH + " characters made up of lowercase letters, numbers, and the symbols '.', '-' and '_'"}; var nameDivClass = 'form-group'; if (this.state.nameError) { nameError = ; + nameHelpText = ''; nameDivClass += ' has-error'; } @@ -58,13 +61,13 @@ export default class TeamSignupUsernamePage extends React.Component { className='signup-team-logo' src='/static/images/logo.png' /> -

Your username

+

{'Your username'}

{'Select a memorable username that makes it easy for teammates to identify you:'}
-
Choose your username
+
{'Choose your username'}
- Usernames must begin with a letter and contain 3 to 15 characters made up of lowercase letters, numbers, and the symbols '.', '-' and '_' + {nameHelpText}
{nameError} @@ -86,7 +89,7 @@ export default class TeamSignupUsernamePage extends React.Component { className='btn btn-primary margin--extra' onClick={this.submitNext} > - Next + {'Next'}
@@ -94,7 +97,7 @@ export default class TeamSignupUsernamePage extends React.Component { href='#' onClick={this.submitBack} > - Back to previous step + {'Back to previous step'}
diff --git a/web/react/components/user_settings/user_settings_general.jsx b/web/react/components/user_settings/user_settings_general.jsx index 014038dd4..db8cd277d 100644 --- a/web/react/components/user_settings/user_settings_general.jsx +++ b/web/react/components/user_settings/user_settings_general.jsx @@ -47,7 +47,7 @@ export default class UserSettingsGeneralTab extends React.Component { this.setState({clientError: 'This username is reserved, please choose a new one.'}); return; } else if (usernameError) { - this.setState({clientError: "Username must begin with a letter, and contain between 3 to 15 lowercase characters made up of numbers, letters, and the symbols '.', '-' and '_'."}); + this.setState({clientError: 'Username must begin with a letter, and contain between ' + Constants.MIN_USERNAME_LENGTH + ' to ' + Constants.MAX_USERNAME_LENGTH + " lowercase characters made up of numbers, letters, and the symbols '.', '-' and '_'."}); return; } diff --git a/web/react/components/user_settings/user_settings_security.jsx b/web/react/components/user_settings/user_settings_security.jsx index d1266dd3f..5a21abd19 100644 --- a/web/react/components/user_settings/user_settings_security.jsx +++ b/web/react/components/user_settings/user_settings_security.jsx @@ -48,8 +48,8 @@ export default class SecurityTab extends React.Component { return; } - if (newPassword.length < 5) { - this.setState({passwordError: 'New passwords must be at least 5 characters', serverError: ''}); + if (newPassword.length < Constants.MIN_PASSWORD_LENGTH) { + this.setState({passwordError: 'New passwords must be at least ' + Constants.MIN_PASSWORD_LENGTH + ' characters', serverError: ''}); return; } @@ -337,7 +337,7 @@ export default class SecurityTab extends React.Component { className='security-links theme' dialogType={AccessHistoryModal} > - View Access History + {'View Access History'} 15) { - error = 'Must be between 3 and 15 characters'; + } else if (name.length < Constants.MIN_USERNAME_LENGTH || name.length > Constants.MAX_USERNAME_LENGTH) { + error = 'Must be between ' + Constants.MIN_USERNAME_LENGTH + ' and ' + Constants.MAX_USERNAME_LENGTH + ' characters'; } else if (!(/^[a-z0-9\.\-\_]+$/).test(name)) { error = "Must contain only letters, numbers, and the symbols '.', '-', and '_'."; } else if (!(/[a-z]/).test(name.charAt(0))) { //eslint-disable-line no-negated-condition -- cgit v1.2.3-1-g7c22 From f09b3fbe78c5e7dc5aae05859f8a5a302ae99710 Mon Sep 17 00:00:00 2001 From: Eric Sethna Date: Wed, 20 Jan 2016 10:27:54 -0700 Subject: Update team_general_tab.jsx Add more direct instructions on enabling the team directory in the system console. From community issue: https://github.com/mattermost/platform/issues/1835 --- web/react/components/team_general_tab.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web/react') diff --git a/web/react/components/team_general_tab.jsx b/web/react/components/team_general_tab.jsx index cc06a940e..86cd80498 100644 --- a/web/react/components/team_general_tab.jsx +++ b/web/react/components/team_general_tab.jsx @@ -66,7 +66,7 @@ export default class GeneralTab extends React.Component { handleTeamListingRadio(listing) { if (global.window.mm_config.EnableTeamListing !== 'true' && listing) { - this.setState({clientError: 'Team directory has been disabled. Please ask a system admin to enable it.'}); + this.setState({clientError: 'Team directory has been disabled. Please ask a system admin to enable the team directory in the system console team settings.'}); } else { this.setState({allow_team_listing: listing}); } -- cgit v1.2.3-1-g7c22 From e4e3178e9440ab351a722d939f0af2637de2df9f Mon Sep 17 00:00:00 2001 From: hmhealey Date: Wed, 20 Jan 2016 14:33:08 -0500 Subject: Changed the post textbox resizing code to be more reliable and not rely on magic numbers --- web/react/components/textbox.jsx | 52 ++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 23 deletions(-) (limited to 'web/react') diff --git a/web/react/components/textbox.jsx b/web/react/components/textbox.jsx index b29f304ab..1e9c7de74 100644 --- a/web/react/components/textbox.jsx +++ b/web/react/components/textbox.jsx @@ -81,36 +81,42 @@ export default class Textbox extends React.Component { } resize() { - const e = this.refs.message.getTextbox(); - const w = ReactDOM.findDOMNode(this.refs.wrapper); + const textbox = this.refs.message.getTextbox(); + const $textbox = $(textbox); + const $wrapper = $(ReactDOM.findDOMNode(this.refs.wrapper)); - const prevHeight = $(e).height(); + const padding = parseInt($textbox.css('padding-bottom'), 10) + parseInt($textbox.css('padding-top'), 10); + const borders = parseInt($textbox.css('border-bottom-width'), 10) + parseInt($textbox.css('border-top-width'), 10); + const maxHeight = parseInt($textbox.css('max-height'), 10) - borders; - const lht = parseInt($(e).css('lineHeight'), 10); - const lines = e.scrollHeight / lht; - let mod = 15; + const prevHeight = $textbox.height(); - if (lines < 2.5 || this.props.messageText === '') { - mod = 30; - } + // set the height to auto and remove the scrollbar so we can get the actual size of the contents + $textbox.css('height', 'auto').css('overflow-y', 'hidden'); + + let height = textbox.scrollHeight - padding; - if (e.scrollHeight - mod < 167) { - $(e).css({height: 'auto', 'overflow-y': 'hidden'}).height(e.scrollHeight - mod); - $(w).css({height: 'auto'}).height(e.scrollHeight + 2); - $(w).closest('.post-body__cell').removeClass('scroll'); - if (this.state.preview) { - $(ReactDOM.findDOMNode(this.refs.preview)).css({height: 'auto', 'overflow-y': 'auto'}).height(e.scrollHeight - mod); - } + if (height + padding > maxHeight) { + height = maxHeight - padding; + + // turn scrollbar on and move over attachment icon to compensate for that + $textbox.css('overflow-y', 'scroll'); + $wrapper.closest('.post-body__cell').addClass('scroll'); } else { - $(e).css({height: 'auto', 'overflow-y': 'scroll'}).height(167 - mod); - $(w).css({height: 'auto'}).height(163); - $(w).closest('.post-body__cell').addClass('scroll'); - if (this.state.preview) { - $(ReactDOM.findDOMNode(this.refs.preview)).css({height: 'auto', 'overflow-y': 'scroll'}).height(163); - } + $wrapper.closest('.post-body__cell').removeClass('scroll'); + } + + // set the textarea to be the proper height + $textbox.height(height); + + // set the wrapper height to match the height of the textbox including padding and borders + $wrapper.height(height + padding + borders); + + if (this.state.preview) { + $(ReactDOM.findDOMNode(this.refs.preview)).height(height + borders); } - if (prevHeight !== $(e).height() && this.props.onHeightChange) { + if (height !== prevHeight && this.props.onHeightChange) { this.props.onHeightChange(); } } -- cgit v1.2.3-1-g7c22 From d8149fb26982eab00f632d8bfc98f6a9cceebca6 Mon Sep 17 00:00:00 2001 From: hmhealey Date: Wed, 20 Jan 2016 14:49:37 -0500 Subject: Removed some vestigial code from the post textbox --- web/react/components/textbox.jsx | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'web/react') diff --git a/web/react/components/textbox.jsx b/web/react/components/textbox.jsx index 1e9c7de74..62c0d5218 100644 --- a/web/react/components/textbox.jsx +++ b/web/react/components/textbox.jsx @@ -22,8 +22,6 @@ export default class Textbox extends React.Component { this.handleKeyPress = this.handleKeyPress.bind(this); this.handleKeyDown = this.handleKeyDown.bind(this); this.resize = this.resize.bind(this); - this.handleFocus = this.handleFocus.bind(this); - this.handleBlur = this.handleBlur.bind(this); this.showPreview = this.showPreview.bind(this); this.state = { @@ -121,20 +119,6 @@ export default class Textbox extends React.Component { } } - handleFocus() { - const elm = this.refs.message.getTextbox(); - if (elm.title === elm.value) { - elm.value = ''; - } - } - - handleBlur() { - const elm = this.refs.message.getTextbox(); - if (elm.value === '') { - elm.value = elm.title; - } - } - showPreview(e) { e.preventDefault(); e.target.blur(); @@ -184,9 +168,6 @@ export default class Textbox extends React.Component { onUserInput={this.props.onUserInput} onKeyPress={this.handleKeyPress} onKeyDown={this.handleKeyDown} - onFocus={this.handleFocus} - onBlur={this.handleBlur} - onPaste={this.handlePaste} style={{visibility: this.state.preview ? 'hidden' : 'visible'}} listComponent={SuggestionList} providers={this.suggestionProviders} -- cgit v1.2.3-1-g7c22 From e4cea41cbf678f553ffffd9c9fdb86e3d35bc0ca Mon Sep 17 00:00:00 2001 From: hmhealey Date: Wed, 20 Jan 2016 14:57:34 -0500 Subject: Added a small margin where the PostsView will be considered to be at the bottom even if it's not exactly at the bottom --- web/react/components/posts_view.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'web/react') diff --git a/web/react/components/posts_view.jsx b/web/react/components/posts_view.jsx index 7d8c7e265..856403af5 100644 --- a/web/react/components/posts_view.jsx +++ b/web/react/components/posts_view.jsx @@ -57,7 +57,10 @@ export default class PostsView extends React.Component { this.setState({displayNameType: PreferenceStore.get(Preferences.CATEGORY_DISPLAY_SETTINGS, 'name_format', 'false')}); } isAtBottom() { - return ((this.refs.postlist.scrollHeight - this.refs.postlist.scrollTop) === this.refs.postlist.clientHeight); + // consider the view to be at the bottom if it's within this many pixels of the bottom + const atBottomMargin = 10; + + return this.refs.postlist.clientHeight + this.refs.postlist.scrollTop >= this.refs.postlist.scrollHeight - atBottomMargin; } handleScroll() { // HACK FOR RHS -- REMOVE WHEN RHS DIES -- cgit v1.2.3-1-g7c22 From 6b26aa94135bb08d74ba18ab609ada5e967d5a0d Mon Sep 17 00:00:00 2001 From: hmhealey Date: Wed, 20 Jan 2016 16:29:06 -0500 Subject: Changed UnreadChannelIndicator display style so that it uses a value that IE11 supports --- web/react/components/unread_channel_indicator.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web/react') diff --git a/web/react/components/unread_channel_indicator.jsx b/web/react/components/unread_channel_indicator.jsx index 6ae06528b..c0c34584f 100644 --- a/web/react/components/unread_channel_indicator.jsx +++ b/web/react/components/unread_channel_indicator.jsx @@ -10,7 +10,7 @@ export default class UnreadChannelIndicator extends React.Component { render() { let displayValue = 'none'; if (this.props.show) { - displayValue = 'initial'; + displayValue = 'block'; } return (
Date: Wed, 20 Jan 2016 17:20:14 -0500 Subject: Completely disabled broken pasting of images on IE11 --- web/react/components/file_upload.jsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'web/react') diff --git a/web/react/components/file_upload.jsx b/web/react/components/file_upload.jsx index fef253c52..7e6cc2942 100644 --- a/web/react/components/file_upload.jsx +++ b/web/react/components/file_upload.jsx @@ -151,7 +151,11 @@ export default class FileUpload extends React.Component { }); } - document.addEventListener('paste', function handlePaste(e) { + document.addEventListener('paste', (e) => { + if (!e.clipboardData) { + return; + } + var textarea = $(inputDiv.parentNode.parentNode).find('.custom-textarea')[0]; if (textarea !== e.target && !$.contains(textarea, e.target)) { -- cgit v1.2.3-1-g7c22 From 051e06d4c1bc80f3bea956d38642420b1f31563a Mon Sep 17 00:00:00 2001 From: Eric Sethna Date: Thu, 21 Jan 2016 10:18:28 -0700 Subject: Update team_general_tab.jsx Correct capitalization based on UX discussion --- web/react/components/team_general_tab.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web/react') diff --git a/web/react/components/team_general_tab.jsx b/web/react/components/team_general_tab.jsx index 86cd80498..b6fb3389f 100644 --- a/web/react/components/team_general_tab.jsx +++ b/web/react/components/team_general_tab.jsx @@ -66,7 +66,7 @@ export default class GeneralTab extends React.Component { handleTeamListingRadio(listing) { if (global.window.mm_config.EnableTeamListing !== 'true' && listing) { - this.setState({clientError: 'Team directory has been disabled. Please ask a system admin to enable the team directory in the system console team settings.'}); + this.setState({clientError: 'Team Directory has been disabled. Please ask a System Admin to enable the Team Directory in the System Console team settings.'}); } else { this.setState({allow_team_listing: listing}); } -- cgit v1.2.3-1-g7c22 From 261b38be45420b45f97842ec55247ea7b47a527e Mon Sep 17 00:00:00 2001 From: hmhealey Date: Thu, 21 Jan 2016 13:55:47 -0500 Subject: Added download param to getFile api call --- web/react/components/view_image.jsx | 3 ++- web/react/utils/utils.jsx | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'web/react') diff --git a/web/react/components/view_image.jsx b/web/react/components/view_image.jsx index 31ec91248..d11f8a21c 100644 --- a/web/react/components/view_image.jsx +++ b/web/react/components/view_image.jsx @@ -211,7 +211,7 @@ export default class ViewImageModal extends React.Component { } const filename = this.props.filenames[this.state.imgId]; - const fileUrl = Utils.getFileUrl(filename); + const fileUrl = Utils.getFileUrl(filename, true); var content; if (this.state.loaded[this.state.imgId]) { @@ -377,6 +377,7 @@ function ImagePreview({filename, fileUrl, fileInfo, maxHeight}) { Date: Thu, 21 Jan 2016 13:54:21 -0600 Subject: PLT-7 Adding react-intl libs --- web/react/.eslintrc | 2 ++ web/react/pages/login.jsx | 70 ++++++++++++++++++++++++++++++++++++++----- web/react/utils/client.jsx | 12 ++++++++ web/react/utils/locales/en.js | 16 ++++++++++ web/react/utils/locales/es.js | 10 +++++++ 5 files changed, 102 insertions(+), 8 deletions(-) create mode 100644 web/react/utils/locales/en.js create mode 100644 web/react/utils/locales/es.js (limited to 'web/react') diff --git a/web/react/.eslintrc b/web/react/.eslintrc index baaf7eaa5..013175567 100644 --- a/web/react/.eslintrc +++ b/web/react/.eslintrc @@ -22,6 +22,8 @@ "React": false, "ReactDOM": false, "ReactBootstrap": false, + "ReactIntl": false, + "ReactIntlLocaleData": false, "Chart": false, "katex": false }, diff --git a/web/react/pages/login.jsx b/web/react/pages/login.jsx index 4a565623e..edf2d4f66 100644 --- a/web/react/pages/login.jsx +++ b/web/react/pages/login.jsx @@ -1,17 +1,71 @@ // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. +import * as Client from '../utils/client.jsx'; import Login from '../components/login.jsx'; -function setupLoginPage(props) { +var IntlProvider = ReactIntl.IntlProvider; +ReactIntl.addLocaleData(ReactIntlLocaleData.en); +ReactIntl.addLocaleData(ReactIntlLocaleData.es); + +class Root extends React.Component { + constructor() { + super(); + this.state = { + translations: null, + loaded: false + }; + } + + static propTypes() { + return { + map: React.PropTypes.object.isRequired + }; + } + + componentWillMount() { + Client.getTranslations( + 'es', + (data) => { + this.setState({ + translations: data, + loaded: true + }); + }, + () => { + this.setState({ + loaded: true + }); + } + ); + } + + render() { + if (!this.state.loaded) { + return
; + } + + return ( + + + + ); + } +} + +global.window.setup_login_page = function setup(props) { ReactDOM.render( - , + , document.getElementById('login') ); -} +}; + -global.window.setup_login_page = setupLoginPage; +//locale={this.props.map.Locale} \ No newline at end of file diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx index d60fea872..65353b70d 100644 --- a/web/react/utils/client.jsx +++ b/web/react/utils/client.jsx @@ -60,6 +60,18 @@ function handleError(methodName, xhr, status, err) { return e; } +export function getTranslations(locale, success, error) { + $.ajax({ + url: '/static/i18n/' + locale + '.json', + dataType: 'json', + success, + error: function onError(xhr, status, err) { + var e = handleError('getTranslations', xhr, status, err); + error(e); + } + }); +} + export function createTeamFromSignup(teamSignup, success, error) { $.ajax({ url: '/api/v1/teams/create_from_signup', diff --git a/web/react/utils/locales/en.js b/web/react/utils/locales/en.js new file mode 100644 index 000000000..08d41225a --- /dev/null +++ b/web/react/utils/locales/en.js @@ -0,0 +1,16 @@ +// GENERATED FILE +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports["default"] = [{ "locale": "en", "pluralRuleFunction": function pluralRuleFunction(n, ord) { + var s = String(n).split("."), + v0 = !s[1], + t0 = Number(s[0]) == n, + n10 = t0 && s[0].slice(-1), + n100 = t0 && s[0].slice(-2);if (ord) return n10 == 1 && n100 != 11 ? "one" : n10 == 2 && n100 != 12 ? "two" : n10 == 3 && n100 != 13 ? "few" : "other";return n == 1 && v0 ? "one" : "other"; +}, "fields": { "year": { "displayName": "Year", "relative": { "0": "this year", "1": "next year", "-1": "last year" }, "relativeTime": { "future": { "one": "in {0} year", "other": "in {0} years" }, "past": { "one": "{0} year ago", "other": "{0} years ago" } } }, "month": { "displayName": "Month", "relative": { "0": "this month", "1": "next month", "-1": "last month" }, "relativeTime": { "future": { "one": "in {0} month", "other": "in {0} months" }, "past": { "one": "{0} month ago", "other": "{0} months ago" } } }, "day": { "displayName": "Day", "relative": { "0": "today", "1": "tomorrow", "-1": "yesterday" }, "relativeTime": { "future": { "one": "in {0} day", "other": "in {0} days" }, "past": { "one": "{0} day ago", "other": "{0} days ago" } } }, "hour": { "displayName": "Hour", "relativeTime": { "future": { "one": "in {0} hour", "other": "in {0} hours" }, "past": { "one": "{0} hour ago", "other": "{0} hours ago" } } }, "minute": { "displayName": "Minute", "relativeTime": { "future": { "one": "in {0} minute", "other": "in {0} minutes" }, "past": { "one": "{0} minute ago", "other": "{0} minutes ago" } } }, "second": { "displayName": "Second", "relative": { "0": "now" }, "relativeTime": { "future": { "one": "in {0} second", "other": "in {0} seconds" }, "past": { "one": "{0} second ago", "other": "{0} seconds ago" } } } } }, { "locale": "en-001", "parentLocale": "en" }, { "locale": "en-150", "parentLocale": "en-GB" }, { "locale": "en-GB", "parentLocale": "en-001" }, { "locale": "en-AG", "parentLocale": "en-001" }, { "locale": "en-AI", "parentLocale": "en-001" }, { "locale": "en-AS", "parentLocale": "en" }, { "locale": "en-AU", "parentLocale": "en-GB", "fields": { "year": { "displayName": "Year", "relative": { "0": "This year", "1": "Next year", "-1": "Last year" }, "relativeTime": { "future": { "one": "in {0} year", "other": "in {0} years" }, "past": { "one": "{0} year ago", "other": "{0} years ago" } } }, "month": { "displayName": "Month", "relative": { "0": "This month", "1": "Next month", "-1": "Last month" }, "relativeTime": { "future": { "one": "in {0} month", "other": "in {0} months" }, "past": { "one": "{0} month ago", "other": "{0} months ago" } } }, "day": { "displayName": "Day", "relative": { "0": "today", "1": "tomorrow", "-1": "yesterday" }, "relativeTime": { "future": { "one": "in {0} day", "other": "in {0} days" }, "past": { "one": "{0} day ago", "other": "{0} days ago" } } }, "hour": { "displayName": "Hour", "relativeTime": { "future": { "one": "in {0} hour", "other": "in {0} hours" }, "past": { "one": "{0} hour ago", "other": "{0} hours ago" } } }, "minute": { "displayName": "Minute", "relativeTime": { "future": { "one": "in {0} minute", "other": "in {0} minutes" }, "past": { "one": "{0} minute ago", "other": "{0} minutes ago" } } }, "second": { "displayName": "Second", "relative": { "0": "now" }, "relativeTime": { "future": { "one": "in {0} second", "other": "in {0} seconds" }, "past": { "one": "{0} second ago", "other": "{0} seconds ago" } } } } }, { "locale": "en-BB", "parentLocale": "en-001" }, { "locale": "en-BE", "parentLocale": "en-GB" }, { "locale": "en-BM", "parentLocale": "en-001" }, { "locale": "en-BS", "parentLocale": "en-001" }, { "locale": "en-BW", "parentLocale": "en-001" }, { "locale": "en-BZ", "parentLocale": "en-001" }, { "locale": "en-CA", "parentLocale": "en" }, { "locale": "en-CC", "parentLocale": "en-001" }, { "locale": "en-CK", "parentLocale": "en-001" }, { "locale": "en-CM", "parentLocale": "en-001" }, { "locale": "en-CX", "parentLocale": "en-001" }, { "locale": "en-DG", "parentLocale": "en-GB" }, { "locale": "en-DM", "parentLocale": "en-001" }, { "locale": "en-Dsrt", "pluralRuleFunction": function pluralRuleFunction(n, ord) { + if (ord) return "other";return "other"; +}, "fields": { "year": { "displayName": "Year", "relative": { "0": "this year", "1": "next year", "-1": "last year" }, "relativeTime": { "future": { "other": "+{0} y" }, "past": { "other": "-{0} y" } } }, "month": { "displayName": "Month", "relative": { "0": "this month", "1": "next month", "-1": "last month" }, "relativeTime": { "future": { "other": "+{0} m" }, "past": { "other": "-{0} m" } } }, "day": { "displayName": "Day", "relative": { "0": "today", "1": "tomorrow", "-1": "yesterday" }, "relativeTime": { "future": { "other": "+{0} d" }, "past": { "other": "-{0} d" } } }, "hour": { "displayName": "Hour", "relativeTime": { "future": { "other": "+{0} h" }, "past": { "other": "-{0} h" } } }, "minute": { "displayName": "Minute", "relativeTime": { "future": { "other": "+{0} min" }, "past": { "other": "-{0} min" } } }, "second": { "displayName": "Second", "relative": { "0": "now" }, "relativeTime": { "future": { "other": "+{0} s" }, "past": { "other": "-{0} s" } } } } }, { "locale": "en-ER", "parentLocale": "en-001" }, { "locale": "en-FJ", "parentLocale": "en-001" }, { "locale": "en-FK", "parentLocale": "en-GB" }, { "locale": "en-FM", "parentLocale": "en-001" }, { "locale": "en-GD", "parentLocale": "en-001" }, { "locale": "en-GG", "parentLocale": "en-GB" }, { "locale": "en-GH", "parentLocale": "en-001" }, { "locale": "en-GI", "parentLocale": "en-GB" }, { "locale": "en-GM", "parentLocale": "en-001" }, { "locale": "en-GU", "parentLocale": "en" }, { "locale": "en-GY", "parentLocale": "en-001" }, { "locale": "en-HK", "parentLocale": "en-GB" }, { "locale": "en-IE", "parentLocale": "en-GB" }, { "locale": "en-IM", "parentLocale": "en-GB" }, { "locale": "en-IN", "parentLocale": "en-GB" }, { "locale": "en-IO", "parentLocale": "en-GB" }, { "locale": "en-JE", "parentLocale": "en-GB" }, { "locale": "en-JM", "parentLocale": "en-001" }, { "locale": "en-KE", "parentLocale": "en-001" }, { "locale": "en-KI", "parentLocale": "en-001" }, { "locale": "en-KN", "parentLocale": "en-001" }, { "locale": "en-KY", "parentLocale": "en-001" }, { "locale": "en-LC", "parentLocale": "en-001" }, { "locale": "en-LR", "parentLocale": "en-001" }, { "locale": "en-LS", "parentLocale": "en-001" }, { "locale": "en-MG", "parentLocale": "en-001" }, { "locale": "en-MH", "parentLocale": "en" }, { "locale": "en-MO", "parentLocale": "en-GB" }, { "locale": "en-MP", "parentLocale": "en" }, { "locale": "en-MS", "parentLocale": "en-001" }, { "locale": "en-MT", "parentLocale": "en-GB" }, { "locale": "en-MU", "parentLocale": "en-001" }, { "locale": "en-MW", "parentLocale": "en-001" }, { "locale": "en-MY", "parentLocale": "en-001" }, { "locale": "en-NA", "parentLocale": "en-001" }, { "locale": "en-NF", "parentLocale": "en-001" }, { "locale": "en-NG", "parentLocale": "en-001" }, { "locale": "en-NR", "parentLocale": "en-001" }, { "locale": "en-NU", "parentLocale": "en-001" }, { "locale": "en-NZ", "parentLocale": "en-GB" }, { "locale": "en-PG", "parentLocale": "en-001" }, { "locale": "en-PH", "parentLocale": "en-001" }, { "locale": "en-PK", "parentLocale": "en-GB" }, { "locale": "en-PN", "parentLocale": "en-001" }, { "locale": "en-PR", "parentLocale": "en" }, { "locale": "en-PW", "parentLocale": "en-001" }, { "locale": "en-RW", "parentLocale": "en-001" }, { "locale": "en-SB", "parentLocale": "en-001" }, { "locale": "en-SC", "parentLocale": "en-001" }, { "locale": "en-SD", "parentLocale": "en-001" }, { "locale": "en-SG", "parentLocale": "en-GB" }, { "locale": "en-SH", "parentLocale": "en-GB" }, { "locale": "en-SL", "parentLocale": "en-001" }, { "locale": "en-SS", "parentLocale": "en-001" }, { "locale": "en-SX", "parentLocale": "en-001" }, { "locale": "en-SZ", "parentLocale": "en-001" }, { "locale": "en-TC", "parentLocale": "en-001" }, { "locale": "en-TK", "parentLocale": "en-001" }, { "locale": "en-TO", "parentLocale": "en-001" }, { "locale": "en-TT", "parentLocale": "en-001" }, { "locale": "en-TV", "parentLocale": "en-001" }, { "locale": "en-TZ", "parentLocale": "en-001" }, { "locale": "en-UG", "parentLocale": "en-001" }, { "locale": "en-UM", "parentLocale": "en" }, { "locale": "en-US", "parentLocale": "en" }, { "locale": "en-US-POSIX", "parentLocale": "en-US" }, { "locale": "en-VC", "parentLocale": "en-001" }, { "locale": "en-VG", "parentLocale": "en-GB" }, { "locale": "en-VI", "parentLocale": "en" }, { "locale": "en-VU", "parentLocale": "en-001" }, { "locale": "en-WS", "parentLocale": "en-001" }, { "locale": "en-ZA", "parentLocale": "en-001" }, { "locale": "en-ZM", "parentLocale": "en-001" }, { "locale": "en-ZW", "parentLocale": "en-001" }]; +module.exports = exports["default"]; \ No newline at end of file diff --git a/web/react/utils/locales/es.js b/web/react/utils/locales/es.js new file mode 100644 index 000000000..8591950ca --- /dev/null +++ b/web/react/utils/locales/es.js @@ -0,0 +1,10 @@ +// GENERATED FILE +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports["default"] = [{ "locale": "es", "pluralRuleFunction": function pluralRuleFunction(n, ord) { + if (ord) return "other";return n == 1 ? "one" : "other"; +}, "fields": { "year": { "displayName": "Año", "relative": { "0": "este año", "1": "el próximo año", "-1": "el año pasado" }, "relativeTime": { "future": { "one": "dentro de {0} año", "other": "dentro de {0} años" }, "past": { "one": "hace {0} año", "other": "hace {0} años" } } }, "month": { "displayName": "Mes", "relative": { "0": "este mes", "1": "el próximo mes", "-1": "el mes pasado" }, "relativeTime": { "future": { "one": "dentro de {0} mes", "other": "dentro de {0} meses" }, "past": { "one": "hace {0} mes", "other": "hace {0} meses" } } }, "day": { "displayName": "Día", "relative": { "0": "hoy", "1": "mañana", "2": "pasado mañana", "-1": "ayer", "-2": "antes de ayer" }, "relativeTime": { "future": { "one": "dentro de {0} día", "other": "dentro de {0} días" }, "past": { "one": "hace {0} día", "other": "hace {0} días" } } }, "hour": { "displayName": "Hora", "relativeTime": { "future": { "one": "dentro de {0} hora", "other": "dentro de {0} horas" }, "past": { "one": "hace {0} hora", "other": "hace {0} horas" } } }, "minute": { "displayName": "Minuto", "relativeTime": { "future": { "one": "dentro de {0} minuto", "other": "dentro de {0} minutos" }, "past": { "one": "hace {0} minuto", "other": "hace {0} minutos" } } }, "second": { "displayName": "Segundo", "relative": { "0": "ahora" }, "relativeTime": { "future": { "one": "dentro de {0} segundo", "other": "dentro de {0} segundos" }, "past": { "one": "hace {0} segundo", "other": "hace {0} segundos" } } } } }, { "locale": "es-419", "parentLocale": "es", "fields": { "year": { "displayName": "Año", "relative": { "0": "Este año", "1": "Año próximo", "-1": "Año pasado" }, "relativeTime": { "future": { "one": "En {0} año", "other": "En {0} años" }, "past": { "one": "hace {0} año", "other": "hace {0} años" } } }, "month": { "displayName": "Mes", "relative": { "0": "Este mes", "1": "Mes próximo", "-1": "El mes pasado" }, "relativeTime": { "future": { "one": "En {0} mes", "other": "En {0} meses" }, "past": { "one": "hace {0} mes", "other": "hace {0} meses" } } }, "day": { "displayName": "Día", "relative": { "0": "hoy", "1": "mañana", "2": "pasado mañana", "-1": "ayer", "-2": "antes de ayer" }, "relativeTime": { "future": { "one": "En {0} día", "other": "En {0} días" }, "past": { "one": "hace {0} día", "other": "hace {0} días" } } }, "hour": { "displayName": "Hora", "relativeTime": { "future": { "one": "En {0} hora", "other": "En {0} horas" }, "past": { "one": "hace {0} hora", "other": "hace {0} horas" } } }, "minute": { "displayName": "Minuto", "relativeTime": { "future": { "one": "En {0} minuto", "other": "En {0} minutos" }, "past": { "one": "hace {0} minuto", "other": "hace {0} minutos" } } }, "second": { "displayName": "Segundo", "relative": { "0": "ahora" }, "relativeTime": { "future": { "one": "En {0} segundo", "other": "En {0} segundos" }, "past": { "one": "hace {0} segundo", "other": "hace {0} segundos" } } } } }, { "locale": "es-AR", "parentLocale": "es-419" }, { "locale": "es-BO", "parentLocale": "es-419" }, { "locale": "es-CL", "parentLocale": "es-419" }, { "locale": "es-CO", "parentLocale": "es-419" }, { "locale": "es-CR", "parentLocale": "es-419" }, { "locale": "es-CU", "parentLocale": "es-419" }, { "locale": "es-DO", "parentLocale": "es-419" }, { "locale": "es-EA", "parentLocale": "es" }, { "locale": "es-EC", "parentLocale": "es-419" }, { "locale": "es-ES", "parentLocale": "es" }, { "locale": "es-GQ", "parentLocale": "es" }, { "locale": "es-GT", "parentLocale": "es-419" }, { "locale": "es-HN", "parentLocale": "es-419" }, { "locale": "es-IC", "parentLocale": "es" }, { "locale": "es-MX", "parentLocale": "es-419", "fields": { "year": { "displayName": "Año", "relative": { "0": "este año", "1": "el año próximo", "-1": "el año pasado" }, "relativeTime": { "future": { "one": "En {0} año", "other": "En {0} años" }, "past": { "one": "hace {0} año", "other": "hace {0} años" } } }, "month": { "displayName": "Mes", "relative": { "0": "este mes", "1": "el mes próximo", "-1": "el mes pasado" }, "relativeTime": { "future": { "one": "en {0} mes", "other": "en {0} meses" }, "past": { "one": "hace {0} mes", "other": "hace {0} meses" } } }, "day": { "displayName": "Día", "relative": { "0": "hoy", "1": "mañana", "2": "pasado mañana", "-1": "ayer", "-2": "antes de ayer" }, "relativeTime": { "future": { "one": "En {0} día", "other": "En {0} días" }, "past": { "one": "hace {0} día", "other": "hace {0} días" } } }, "hour": { "displayName": "Hora", "relativeTime": { "future": { "one": "En {0} hora", "other": "En {0} horas" }, "past": { "one": "hace {0} hora", "other": "hace {0} horas" } } }, "minute": { "displayName": "Minuto", "relativeTime": { "future": { "one": "En {0} minuto", "other": "En {0} minutos" }, "past": { "one": "hace {0} minuto", "other": "hace {0} minutos" } } }, "second": { "displayName": "Segundo", "relative": { "0": "ahora" }, "relativeTime": { "future": { "one": "En {0} segundo", "other": "En {0} segundos" }, "past": { "one": "hace {0} segundo", "other": "hace {0} segundos" } } } } }, { "locale": "es-NI", "parentLocale": "es-419" }, { "locale": "es-PA", "parentLocale": "es-419" }, { "locale": "es-PE", "parentLocale": "es-419" }, { "locale": "es-PH", "parentLocale": "es" }, { "locale": "es-PR", "parentLocale": "es-419" }, { "locale": "es-PY", "parentLocale": "es-419" }, { "locale": "es-SV", "parentLocale": "es-419" }, { "locale": "es-US", "parentLocale": "es-419" }, { "locale": "es-UY", "parentLocale": "es-419" }, { "locale": "es-VE", "parentLocale": "es-419" }]; +module.exports = exports["default"]; \ No newline at end of file -- cgit v1.2.3-1-g7c22 From 221985435966dbf583d3e367c243822e338b6bc4 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Thu, 21 Jan 2016 14:15:44 -0600 Subject: PLT-7 client side infra --- web/react/components/login.jsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'web/react') diff --git a/web/react/components/login.jsx b/web/react/components/login.jsx index 1d9b3e906..6887489a7 100644 --- a/web/react/components/login.jsx +++ b/web/react/components/login.jsx @@ -7,6 +7,8 @@ import LoginLdap from './login_ldap.jsx'; import * as Utils from '../utils/utils.jsx'; import Constants from '../utils/constants.jsx'; +var FormattedMessage = ReactIntl.FormattedMessage; + export default class Login extends React.Component { constructor(props) { super(props); @@ -86,7 +88,12 @@ export default class Login extends React.Component { if (emailSignup) { forgotPassword = (
); } @@ -141,7 +148,13 @@ export default class Login extends React.Component { {ldapLogin} {userSignUp} {forgotPassword} {teamSignUp} -- cgit v1.2.3-1-g7c22 From 3ff05780a1b4f08d256a983bc9ec06f9841f0538 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Thu, 21 Jan 2016 14:25:20 -0600 Subject: PLT-7 client side infra --- web/react/pages/login.jsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'web/react') diff --git a/web/react/pages/login.jsx b/web/react/pages/login.jsx index edf2d4f66..e0957a65b 100644 --- a/web/react/pages/login.jsx +++ b/web/react/pages/login.jsx @@ -25,7 +25,7 @@ class Root extends React.Component { componentWillMount() { Client.getTranslations( - 'es', + this.props.map.Locale, (data) => { this.setState({ translations: data, @@ -47,7 +47,7 @@ class Root extends React.Component { return ( , document.getElementById('login') ); -}; - - -//locale={this.props.map.Locale} \ No newline at end of file +}; \ No newline at end of file -- cgit v1.2.3-1-g7c22 From ec5b278fca848172cb505793628aaf8a27406292 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Thu, 21 Jan 2016 16:36:12 -0600 Subject: PLT-7 fixing dist build --- web/react/pages/login.jsx | 2 -- 1 file changed, 2 deletions(-) (limited to 'web/react') diff --git a/web/react/pages/login.jsx b/web/react/pages/login.jsx index e0957a65b..38852ad7c 100644 --- a/web/react/pages/login.jsx +++ b/web/react/pages/login.jsx @@ -5,8 +5,6 @@ import * as Client from '../utils/client.jsx'; import Login from '../components/login.jsx'; var IntlProvider = ReactIntl.IntlProvider; -ReactIntl.addLocaleData(ReactIntlLocaleData.en); -ReactIntl.addLocaleData(ReactIntlLocaleData.es); class Root extends React.Component { constructor() { -- cgit v1.2.3-1-g7c22 From 518efd7d2e971572c104dde09f90ef9f7619dd08 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Fri, 22 Jan 2016 08:04:02 -0600 Subject: PLT-7 fixing unit test for chunk 2 server --- web/react/components/create_comment.jsx | 2 +- web/react/components/create_post.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'web/react') diff --git a/web/react/components/create_comment.jsx b/web/react/components/create_comment.jsx index cae94429c..aa7ab6a7b 100644 --- a/web/react/components/create_comment.jsx +++ b/web/react/components/create_comment.jsx @@ -129,7 +129,7 @@ export default class CreateComment extends React.Component { function handlePostError(err) { let state = {}; - if (err.message === 'Invalid RootId parameter') { + if (err.id === 'api.post.create_post.root_id.app_error') { PostStore.removePendingPost(post.channel_id, post.pending_post_id); if ($('#post_deleted').length > 0) { diff --git a/web/react/components/create_post.jsx b/web/react/components/create_post.jsx index a476863a3..de971c43f 100644 --- a/web/react/components/create_post.jsx +++ b/web/react/components/create_post.jsx @@ -191,7 +191,7 @@ export default class CreatePost extends React.Component { (err) => { const state = {}; - if (err.message === 'Invalid RootId parameter') { + if (err.id === 'api.post.create_post.root_id.app_error') { if ($('#post_deleted').length > 0) { $('#post_deleted').modal('show'); } -- cgit v1.2.3-1-g7c22 From da1d52d546121e6c36cca9dea90c4a3bc540b0b7 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Fri, 22 Jan 2016 09:10:08 -0600 Subject: PLT-7 adding lang selector --- .../components/user_settings/manage_languages.jsx | 101 +++++++++++++++++++++ .../components/user_settings/user_settings.jsx | 1 + .../user_settings/user_settings_display.jsx | 44 +++++++++ web/react/utils/utils.jsx | 15 +++ 4 files changed, 161 insertions(+) create mode 100644 web/react/components/user_settings/manage_languages.jsx (limited to 'web/react') diff --git a/web/react/components/user_settings/manage_languages.jsx b/web/react/components/user_settings/manage_languages.jsx new file mode 100644 index 000000000..123165b76 --- /dev/null +++ b/web/react/components/user_settings/manage_languages.jsx @@ -0,0 +1,101 @@ +// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. +// See License.txt for license information. + +import * as Client from '../../utils/client.jsx'; +import * as Utils from '../../utils/utils.jsx'; + +export default class ManageLanguage extends React.Component { + constructor(props) { + super(props); + + this.setupInitialState = this.setupInitialState.bind(this); + this.setLanguage = this.setLanguage.bind(this); + this.changeLanguage = this.changeLanguage.bind(this); + this.submitUser = this.submitUser.bind(this); + this.state = this.setupInitialState(props); + } + setupInitialState(props) { + var user = props.user; + return { + languages: Utils.languages(), + locale: user.locale + }; + } + setLanguage(e) { + this.setState({locale: e.target.value}); + } + changeLanguage(e) { + e.preventDefault(); + + var user = this.props.user; + var locale = this.state.locale; + + user.locale = locale; + + this.submitUser(user); + } + submitUser(user) { + Client.updateUser(user, + () => { + window.location.reload(true); + }, + (err) => { + let serverError; + if (err.message) { + serverError = err.message; + } else { + serverError = err; + } + this.setState({serverError}); + } + ); + } + render() { + let serverError; + if (this.state.serverError) { + serverError = ; + } + + const options = []; + this.state.languages.forEach((lang) => { + options.push( + ); + }); + + return ( +
+
+ +
+ + {serverError} + +
+
+ ); + } +} + +ManageLanguage.propTypes = { + user: React.PropTypes.object +}; \ No newline at end of file diff --git a/web/react/components/user_settings/user_settings.jsx b/web/react/components/user_settings/user_settings.jsx index 54d98bbde..9303d874d 100644 --- a/web/react/components/user_settings/user_settings.jsx +++ b/web/react/components/user_settings/user_settings.jsx @@ -11,6 +11,7 @@ import DeveloperTab from './user_settings_developer.jsx'; import IntegrationsTab from './user_settings_integrations.jsx'; import DisplayTab from './user_settings_display.jsx'; import AdvancedTab from './user_settings_advanced.jsx'; +import LanguagesTab from './user_settings_language.jsx'; export default class UserSettings extends React.Component { constructor(props) { diff --git a/web/react/components/user_settings/user_settings_display.jsx b/web/react/components/user_settings/user_settings_display.jsx index 1ff0a2913..b12eb2d9c 100644 --- a/web/react/components/user_settings/user_settings_display.jsx +++ b/web/react/components/user_settings/user_settings_display.jsx @@ -6,6 +6,7 @@ import SettingItemMin from '../setting_item_min.jsx'; import SettingItemMax from '../setting_item_max.jsx'; import Constants from '../../utils/constants.jsx'; import PreferenceStore from '../../stores/preference_store.jsx'; +import ManageLanguages from './manage_languages.jsx'; import * as Utils from '../../utils/utils.jsx'; function getDisplayStateFromStores() { @@ -78,6 +79,7 @@ export default class UserSettingsDisplay extends React.Component { let clockSection; let nameFormatSection; let fontSection; + let languagesSection; if (this.props.activeSection === 'clock') { const clockFormat = [false, false]; @@ -292,6 +294,46 @@ export default class UserSettingsDisplay extends React.Component { ); } + if (this.props.activeSection === 'languages') { + var inputs = []; + inputs.push( + + ); + + languagesSection = ( + { + this.updateSection(''); + e.preventDefault(); + }} + /> + ); + } else { + var locale = 'English'; + Utils.languages().forEach((l) => { + if (l.value === this.props.user.locale) { + locale = l.name; + } + }); + + languagesSection = ( + { + this.updateSection('languages'); + }} + /> + ); + } + return (
@@ -324,6 +366,8 @@ export default class UserSettingsDisplay extends React.Component {
{nameFormatSection}
+ {languagesSection} +
); diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index 1b31adf69..82e9bc447 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -1340,3 +1340,18 @@ export function clearFileInput(elm) { // Do nothing } } + +export function languages() { + return ( + [ + { + value: 'en', + name: 'English' + }, + { + value: 'es', + name: 'Español' + } + ] + ); +} -- cgit v1.2.3-1-g7c22 From 058d6b24672ce22d72451607eef7c9dcc48a255a Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Fri, 22 Jan 2016 09:27:27 -0600 Subject: PLT-7 adding loc feature to preview --- .../user_settings/user_settings_display.jsx | 76 +++++++++++----------- web/react/utils/constants.jsx | 4 ++ 2 files changed, 43 insertions(+), 37 deletions(-) (limited to 'web/react') diff --git a/web/react/components/user_settings/user_settings_display.jsx b/web/react/components/user_settings/user_settings_display.jsx index b12eb2d9c..f2c2502fb 100644 --- a/web/react/components/user_settings/user_settings_display.jsx +++ b/web/react/components/user_settings/user_settings_display.jsx @@ -5,6 +5,7 @@ import {savePreferences} from '../../utils/client.jsx'; import SettingItemMin from '../setting_item_min.jsx'; import SettingItemMax from '../setting_item_max.jsx'; import Constants from '../../utils/constants.jsx'; +const PreReleaseFeatures = Constants.PRE_RELEASE_FEATURES; import PreferenceStore from '../../stores/preference_store.jsx'; import ManageLanguages from './manage_languages.jsx'; import * as Utils from '../../utils/utils.jsx'; @@ -294,44 +295,46 @@ export default class UserSettingsDisplay extends React.Component { ); } - if (this.props.activeSection === 'languages') { - var inputs = []; - inputs.push( - - ); + if (Utils.isFeatureEnabled(PreReleaseFeatures.LOC_PREVIEW)) { + if (this.props.activeSection === 'languages') { + var inputs = []; + inputs.push( + + ); - languagesSection = ( - { - this.updateSection(''); - e.preventDefault(); - }} - /> - ); - } else { - var locale = 'English'; - Utils.languages().forEach((l) => { - if (l.value === this.props.user.locale) { - locale = l.name; - } - }); + languagesSection = ( + { + this.updateSection(''); + e.preventDefault(); + }} + /> + ); + } else { + var locale = 'English'; + Utils.languages().forEach((l) => { + if (l.value === this.props.user.locale) { + locale = l.name; + } + }); - languagesSection = ( - { - this.updateSection('languages'); - }} - /> - ); + languagesSection = ( + { + this.updateSection('languages'); + }} + /> + ); + } } return ( @@ -367,7 +370,6 @@ export default class UserSettingsDisplay extends React.Component { {nameFormatSection}
{languagesSection} -
); diff --git a/web/react/utils/constants.jsx b/web/react/utils/constants.jsx index 5d6aa9329..851bc5f6c 100644 --- a/web/react/utils/constants.jsx +++ b/web/react/utils/constants.jsx @@ -451,6 +451,10 @@ export default { EMBED_PREVIEW: { label: 'embed_preview', description: 'Show preview snippet of links below message' + }, + LOC_PREVIEW: { + label: 'loc_preview', + description: 'Show user language in display settings' } }, OVERLAY_TIME_DELAY: 400, -- cgit v1.2.3-1-g7c22 From 0b3c988ed3ced12c64f84e9c5afd08470cbb84bc Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Fri, 22 Jan 2016 09:29:21 -0600 Subject: PLT-7 adding loc feature to preview --- web/react/components/user_settings/user_settings.jsx | 1 - 1 file changed, 1 deletion(-) (limited to 'web/react') diff --git a/web/react/components/user_settings/user_settings.jsx b/web/react/components/user_settings/user_settings.jsx index 9303d874d..54d98bbde 100644 --- a/web/react/components/user_settings/user_settings.jsx +++ b/web/react/components/user_settings/user_settings.jsx @@ -11,7 +11,6 @@ import DeveloperTab from './user_settings_developer.jsx'; import IntegrationsTab from './user_settings_integrations.jsx'; import DisplayTab from './user_settings_display.jsx'; import AdvancedTab from './user_settings_advanced.jsx'; -import LanguagesTab from './user_settings_language.jsx'; export default class UserSettings extends React.Component { constructor(props) { -- cgit v1.2.3-1-g7c22 From b9fb855c6c8bf86a0f3730b892dda2131380b3ff Mon Sep 17 00:00:00 2001 From: Asaad Mahmood Date: Fri, 22 Jan 2016 22:17:09 +0500 Subject: Updating favicon stuff --- web/react/components/sidebar.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'web/react') diff --git a/web/react/components/sidebar.jsx b/web/react/components/sidebar.jsx index eaeb7bb91..c902731c9 100644 --- a/web/react/components/sidebar.jsx +++ b/web/react/components/sidebar.jsx @@ -506,9 +506,9 @@ export default class Sidebar extends React.Component { link.rel = 'shortcut icon'; link.id = 'favicon'; if (this.badgesActive) { - link.href = '/static/images/redfavicon.ico'; + link.href = '/static/images/favicon/redfavicon-16x16.png'; } else { - link.href = '/static/images/favicon.ico'; + link.href = '/static/images/favicon/favicon-16x16.png'; } var head = document.getElementsByTagName('head')[0]; var oldLink = document.getElementById('favicon'); -- cgit v1.2.3-1-g7c22