From 145876681f03f68d2fcdd4f0339f6b2b9f7b9958 Mon Sep 17 00:00:00 2001 From: enahum Date: Mon, 5 Dec 2016 10:19:12 -0300 Subject: Fix react warnings and part of backstage (#4706) --- webapp/actions/user_actions.jsx | 2 +- webapp/components/access_history_modal.jsx | 6 +- .../admin_console/admin_sidebar_section.jsx | 2 - .../admin_console/file_upload_setting.jsx | 3 +- webapp/components/admin_console/team_users.jsx | 4 ++ webapp/components/admin_console/text_setting.jsx | 2 +- webapp/components/analytics/doughnut_chart.jsx | 2 +- .../components/backstage/backstage_controller.jsx | 9 +-- .../backstage/components/backstage_section.jsx | 1 - webapp/components/channel_invite_button.jsx | 4 -- webapp/components/channel_invite_modal.jsx | 4 +- webapp/components/emoji/components/add_emoji.jsx | 8 +-- webapp/components/emoji/components/emoji_list.jsx | 78 +++++++++++++--------- webapp/components/form_error.jsx | 2 +- webapp/components/get_link_modal.jsx | 3 +- webapp/components/header_footer_template.jsx | 4 ++ .../integrations/components/add_command.jsx | 4 +- .../components/add_incoming_webhook.jsx | 2 +- .../integrations/components/add_oauth_app.jsx | 2 +- .../components/add_outgoing_webhook.jsx | 13 ++-- .../integrations/components/commands_container.jsx | 11 ++- .../components/confirm_integration.jsx | 8 +-- .../integrations/components/edit_command.jsx | 4 +- .../integrations/components/installed_command.jsx | 8 ++- .../integrations/components/installed_commands.jsx | 9 +-- .../components/installed_incoming_webhooks.jsx | 2 +- .../components/installed_oauth_apps.jsx | 2 +- .../components/installed_outgoing_webhooks.jsx | 2 +- .../integrations/components/integrations.jsx | 4 +- webapp/components/login/login_controller.jsx | 11 --- webapp/components/more_direct_channels.jsx | 11 +-- webapp/components/rhs_dropdown.jsx | 9 +-- webapp/components/rhs_header_post.jsx | 4 +- webapp/components/rhs_thread.jsx | 4 +- webapp/components/search_results.jsx | 4 +- webapp/components/search_results_header.jsx | 4 +- webapp/components/search_results_item.jsx | 2 +- webapp/components/sidebar_header_dropdown.jsx | 2 +- .../user_settings/user_settings_modal.jsx | 10 ++- .../components/webrtc/components/webrtc_header.jsx | 2 +- webapp/components/webrtc/webrtc_controller.jsx | 4 +- webapp/i18n/en.json | 2 +- webapp/stores/integration_store.jsx | 9 --- webapp/stores/user_store.jsx | 2 +- webapp/utils/async_client.jsx | 4 +- webapp/utils/constants.jsx | 2 +- 46 files changed, 142 insertions(+), 149 deletions(-) diff --git a/webapp/actions/user_actions.jsx b/webapp/actions/user_actions.jsx index a93f84e7c..6f19e9ace 100644 --- a/webapp/actions/user_actions.jsx +++ b/webapp/actions/user_actions.jsx @@ -378,7 +378,7 @@ export function updateUserRoles(userId, newRoles, success, error) { userId, newRoles, () => { - AsyncClient.getUser(this.props.user.id); + AsyncClient.getUser(userId); if (success) { success(); diff --git a/webapp/components/access_history_modal.jsx b/webapp/components/access_history_modal.jsx index 4ed2ad9ab..28a2b6b8f 100644 --- a/webapp/components/access_history_modal.jsx +++ b/webapp/components/access_history_modal.jsx @@ -57,15 +57,15 @@ export default class AccessHistoryModal extends React.Component { } onAuditChange() { - var newState = this.getStateFromStoresForAudits(); + const newState = this.getStateFromStoresForAudits(); if (!Utils.areObjectsEqual(newState.audits, this.state.audits)) { this.setState(newState); } } render() { - var content; - if (this.state.audits.loading) { + let content; + if (this.state.audits.length === 0) { content = (); } else { content = ( diff --git a/webapp/components/admin_console/admin_sidebar_section.jsx b/webapp/components/admin_console/admin_sidebar_section.jsx index a958150b5..097907bfa 100644 --- a/webapp/components/admin_console/admin_sidebar_section.jsx +++ b/webapp/components/admin_console/admin_sidebar_section.jsx @@ -79,8 +79,6 @@ export default class AdminSidebarSection extends React.Component { sidebarItem = (
{this.props.title} diff --git a/webapp/components/admin_console/file_upload_setting.jsx b/webapp/components/admin_console/file_upload_setting.jsx index 0c1efc168..85cb7f499 100644 --- a/webapp/components/admin_console/file_upload_setting.jsx +++ b/webapp/components/admin_console/file_upload_setting.jsx @@ -51,7 +51,6 @@ export default class FileUploadSetting extends Setting { if (error) { Utils.clearFileInput(this.refs.fileInput); } - this.setState({fileSelected: false, fileName: null, serverError: error}); }); } @@ -61,7 +60,7 @@ export default class FileUploadSetting extends Setting { serverError =
; } - var btnClass = 'btn'; + let btnClass = 'btn'; if (this.state.fileSelected) { btnClass = 'btn btn-primary'; } diff --git a/webapp/components/admin_console/team_users.jsx b/webapp/components/admin_console/team_users.jsx index fce0f18ea..49550d8af 100644 --- a/webapp/components/admin_console/team_users.jsx +++ b/webapp/components/admin_console/team_users.jsx @@ -191,6 +191,7 @@ export default class UserList extends React.Component { const service = (user.auth_service === Constants.LDAP_SERVICE || user.auth_service === Constants.SAML_SERVICE) ? user.auth_service.toUpperCase() : Utils.toTitleCase(user.auth_service); info.push( @@ -212,6 +214,7 @@ export default class UserList extends React.Component { if (user.mfa_active) { info.push( @@ -219,6 +222,7 @@ export default class UserList extends React.Component { } else { info.push( diff --git a/webapp/components/admin_console/text_setting.jsx b/webapp/components/admin_console/text_setting.jsx index a5844aca7..47a501dcc 100644 --- a/webapp/components/admin_console/text_setting.jsx +++ b/webapp/components/admin_console/text_setting.jsx @@ -18,7 +18,7 @@ export default class TextSetting extends React.Component { React.PropTypes.number ]).isRequired, maxLength: React.PropTypes.number, - onChange: React.PropTypes.func.isRequired, + onChange: React.PropTypes.func, disabled: React.PropTypes.bool, type: React.PropTypes.oneOf([ 'input', diff --git a/webapp/components/analytics/doughnut_chart.jsx b/webapp/components/analytics/doughnut_chart.jsx index 5834e290a..ee5365c9b 100644 --- a/webapp/components/analytics/doughnut_chart.jsx +++ b/webapp/components/analytics/doughnut_chart.jsx @@ -83,6 +83,6 @@ DoughnutChart.propTypes = { title: React.PropTypes.node, width: React.PropTypes.string, height: React.PropTypes.string, - data: React.PropTypes.array, + data: React.PropTypes.object, options: React.PropTypes.object }; diff --git a/webapp/components/backstage/backstage_controller.jsx b/webapp/components/backstage/backstage_controller.jsx index 4890dfddb..9e842e1f7 100644 --- a/webapp/components/backstage/backstage_controller.jsx +++ b/webapp/components/backstage/backstage_controller.jsx @@ -4,6 +4,7 @@ import React from 'react'; import TeamStore from 'stores/team_store.jsx'; +import UserStore from 'stores/user_store.jsx'; import BackstageSidebar from './components/backstage_sidebar.jsx'; import BackstageNavbar from './components/backstage_navbar.jsx'; @@ -13,8 +14,7 @@ export default class BackstageController extends React.Component { static get propTypes() { return { children: React.PropTypes.node.isRequired, - params: React.PropTypes.object.isRequired, - user: React.PropTypes.object.isRequired + params: React.PropTypes.object.isRequired }; } @@ -24,6 +24,7 @@ export default class BackstageController extends React.Component { this.onTeamChange = this.onTeamChange.bind(this); this.state = { + user: UserStore.getCurrentUser(), team: props.params.team ? TeamStore.getByName(props.params.team) : TeamStore.getCurrent() }; } @@ -50,7 +51,7 @@ export default class BackstageController extends React.Component {
{ React.Children.map(this.props.children, (child) => { @@ -60,7 +61,7 @@ export default class BackstageController extends React.Component { return React.cloneElement(child, { team: this.state.team, - user: this.props.user + user: this.state.user }); }) } diff --git a/webapp/components/backstage/components/backstage_section.jsx b/webapp/components/backstage/components/backstage_section.jsx index c8b63af18..e89ec9861 100644 --- a/webapp/components/backstage/components/backstage_section.jsx +++ b/webapp/components/backstage/components/backstage_section.jsx @@ -65,7 +65,6 @@ export default class BackstageSection extends React.Component { diff --git a/webapp/components/channel_invite_button.jsx b/webapp/components/channel_invite_button.jsx index 290c2bea4..7c2718cb9 100644 --- a/webapp/components/channel_invite_button.jsx +++ b/webapp/components/channel_invite_button.jsx @@ -40,10 +40,6 @@ export default class ChannelInviteButton extends React.Component { this.props.channel.id, this.props.user.id, () => { - this.setState({ - addingUser: false - }); - this.props.onInviteError(null); }, (err) => { diff --git a/webapp/components/channel_invite_modal.jsx b/webapp/components/channel_invite_modal.jsx index 9ffe4816a..a9655f183 100644 --- a/webapp/components/channel_invite_modal.jsx +++ b/webapp/components/channel_invite_modal.jsx @@ -123,12 +123,12 @@ export default class ChannelInviteModal extends React.Component { } render() { - var inviteError = null; + let inviteError = null; if (this.state.inviteError) { inviteError = (); } - var content; + let content; if (this.state.loading) { content = (); } else { diff --git a/webapp/components/emoji/components/add_emoji.jsx b/webapp/components/emoji/components/add_emoji.jsx index d859da0df..e496e42a0 100644 --- a/webapp/components/emoji/components/add_emoji.jsx +++ b/webapp/components/emoji/components/add_emoji.jsx @@ -14,13 +14,13 @@ import SpinnerButton from 'components/spinner_button.jsx'; export default class AddEmoji extends React.Component { static propTypes = { - team: React.PropTypes.object.isRequired, - user: React.PropTypes.object.isRequired - } + team: React.PropTypes.object, + user: React.PropTypes.object + }; static contextTypes = { router: React.PropTypes.object.isRequired - } + }; constructor(props) { super(props); diff --git a/webapp/components/emoji/components/emoji_list.jsx b/webapp/components/emoji/components/emoji_list.jsx index a539a5537..949c74c45 100644 --- a/webapp/components/emoji/components/emoji_list.jsx +++ b/webapp/components/emoji/components/emoji_list.jsx @@ -19,8 +19,8 @@ import {FormattedMessage} from 'react-intl'; export default class EmojiList extends React.Component { static get propTypes() { return { - team: React.propTypes.object.isRequired, - user: React.propTypes.object.isRequired + team: React.PropTypes.object, + user: React.PropTypes.object }; } @@ -95,11 +95,21 @@ export default class EmojiList extends React.Component { const emojis = []; if (this.state.loading) { emojis.push( - + + + + + ); - } else if (this.state.emojis.length === 0) { + } else if (this.state.emojis.size === 0) { emojis.push( - +
- - - - - - - {emojis} + + + + + + + + + + {emojis} +
- - - - - - - -
+ + + + + + + +
diff --git a/webapp/components/form_error.jsx b/webapp/components/form_error.jsx index df6fa3ab0..9dce98ae9 100644 --- a/webapp/components/form_error.jsx +++ b/webapp/components/form_error.jsx @@ -9,7 +9,7 @@ export default class FormError extends React.Component { return { type: React.PropTypes.node, error: React.PropTypes.node, - margin: React.PropTypes.node, + margin: React.PropTypes.bool, errors: React.PropTypes.arrayOf(React.PropTypes.node) }; } diff --git a/webapp/components/get_link_modal.jsx b/webapp/components/get_link_modal.jsx index 5363ad217..8d4cbbc1c 100644 --- a/webapp/components/get_link_modal.jsx +++ b/webapp/components/get_link_modal.jsx @@ -90,10 +90,11 @@ export default class GetLinkModal extends React.Component { className='form-control no-resize min-height' ref='textarea' value={this.props.link} + readOnly={true} /> ); - var copyLinkConfirm = null; + let copyLinkConfirm = null; if (this.state.copiedLink) { copyLinkConfirm = (

diff --git a/webapp/components/header_footer_template.jsx b/webapp/components/header_footer_template.jsx index 0c5f53861..b508d9ba5 100644 --- a/webapp/components/header_footer_template.jsx +++ b/webapp/components/header_footer_template.jsx @@ -21,6 +21,7 @@ export default class NotLoggedIn extends React.Component { if (global.window.mm_config.HelpLink) { content.push(

- + {localizeMessage('add_outgoing_webhook.triggerWordsTriggerWhenFullWord', 'First word matches a trigger word exactly')}
diff --git a/webapp/components/integrations/components/commands_container.jsx b/webapp/components/integrations/components/commands_container.jsx index 1c2b7af3e..4ab465218 100644 --- a/webapp/components/integrations/components/commands_container.jsx +++ b/webapp/components/integrations/components/commands_container.jsx @@ -2,7 +2,6 @@ // See License.txt for license information. import IntegrationStore from 'stores/integration_store.jsx'; -import TeamStore from 'stores/team_store.jsx'; import UserStore from 'stores/user_store.jsx'; import {loadTeamCommands} from 'actions/integration_actions.jsx'; @@ -12,8 +11,8 @@ import React from 'react'; export default class CommandsContainer extends React.Component { static get propTypes() { return { - team: React.propTypes.object.isRequired, - children: React.propTypes.node.isRequired + team: React.PropTypes.object, + children: React.PropTypes.node }; } @@ -23,10 +22,10 @@ export default class CommandsContainer extends React.Component { this.handleIntegrationChange = this.handleIntegrationChange.bind(this); this.handleUserChange = this.handleUserChange.bind(this); - const teamId = TeamStore.getCurrentId(); + const teamId = this.props.team ? this.props.team.id : ''; this.state = { - commands: IntegrationStore.getCommands(teamId), + commands: IntegrationStore.getCommands(teamId) || [], loading: !IntegrationStore.hasReceivedCommands(teamId), users: UserStore.getProfiles() }; @@ -47,7 +46,7 @@ export default class CommandsContainer extends React.Component { } handleIntegrationChange() { - const teamId = TeamStore.getCurrentId(); + const teamId = this.props.team.id; this.setState({ commands: IntegrationStore.getCommands(teamId), diff --git a/webapp/components/integrations/components/confirm_integration.jsx b/webapp/components/integrations/components/confirm_integration.jsx index 1cc1e727b..6d778f241 100644 --- a/webapp/components/integrations/components/confirm_integration.jsx +++ b/webapp/components/integrations/components/confirm_integration.jsx @@ -15,7 +15,7 @@ import Constants from 'utils/constants.jsx'; export default class ConfirmIntegration extends React.Component { static get propTypes() { return { - team: React.PropTypes.object.isRequired, + team: React.PropTypes.object, location: React.PropTypes.object, loading: React.PropTypes.bool }; @@ -159,7 +159,7 @@ export default class ConfirmIntegration extends React.Component { helpText = []; helpText.push( -

+

); helpText.push( -

+

+

{' - '} - - + {' - '} - - - ); - } - if (gitlabSigninEnabled) { loginControls.push( { AppDispatcher.handleServerAction({ - type: ActionTypes.RECEIVED_COMMAND, + type: ActionTypes.UPDATED_COMMAND, command: data }); @@ -1576,4 +1576,4 @@ export function listReactions(channelId, postId) { dispatchError(err, 'listReactions'); } ); -} \ No newline at end of file +} diff --git a/webapp/utils/constants.jsx b/webapp/utils/constants.jsx index 2c881e024..1eac2732b 100644 --- a/webapp/utils/constants.jsx +++ b/webapp/utils/constants.jsx @@ -90,7 +90,7 @@ export const ActionTypes = keyMirror({ RECEIVED_PROFILES_IN_TEAM: null, RECEIVED_PROFILE: null, RECEIVED_PROFILES_IN_CHANNEL: null, - RECEIVED_PROFILE_NOT_IN_CHANNEL: null, + RECEIVED_PROFILES_NOT_IN_CHANNEL: null, RECEIVED_ME: null, RECEIVED_SESSIONS: null, RECEIVED_AUDITS: null, -- cgit v1.2.3-1-g7c22