From 12896bd23eeba79884245c1c29fdc568cf21a7fa Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 14 Mar 2016 08:50:46 -0400 Subject: Converting to Webpack. Stage 1. --- webapp/components/setting_picture.jsx | 162 ++++++++++++++++++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 webapp/components/setting_picture.jsx (limited to 'webapp/components/setting_picture.jsx') diff --git a/webapp/components/setting_picture.jsx b/webapp/components/setting_picture.jsx new file mode 100644 index 000000000..b74ee8eb7 --- /dev/null +++ b/webapp/components/setting_picture.jsx @@ -0,0 +1,162 @@ +// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import $ from 'jquery'; +import ReactDOM from 'react-dom'; +import {FormattedMessage} from 'react-intl'; + +import loadingGif from 'images/load.gif'; + +import React from 'react'; + +export default class SettingPicture extends React.Component { + constructor(props) { + super(props); + + this.setPicture = this.setPicture.bind(this); + } + + setPicture(file) { + if (file) { + var reader = new FileReader(); + + var img = ReactDOM.findDOMNode(this.refs.image); + reader.onload = function load(e) { + $(img).attr('src', e.target.result); + }; + + reader.readAsDataURL(file); + } + } + + componentWillReceiveProps(nextProps) { + if (nextProps.picture) { + this.setPicture(nextProps.picture); + } + } + + render() { + var clientError = null; + if (this.props.client_error) { + clientError =
; + } + var serverError = null; + if (this.props.server_error) { + serverError =
; + } + + var img = null; + if (this.props.picture) { + img = ( + + ); + } else { + img = ( + + ); + } + + var confirmButton; + if (this.props.loadingPicture) { + confirmButton = ( + + ); + } else { + var confirmButtonClass = 'btn btn-sm'; + if (this.props.submitActive) { + confirmButtonClass += ' btn-primary'; + } else { + confirmButtonClass += ' btn-inactive disabled'; + } + + confirmButton = ( + + + + ); + } + var helpText = ( + + ); + + var self = this; + return ( + + ); + } +} + +SettingPicture.propTypes = { + client_error: React.PropTypes.string, + server_error: React.PropTypes.string, + src: React.PropTypes.string, + picture: React.PropTypes.object, + loadingPicture: React.PropTypes.bool, + submitActive: React.PropTypes.bool, + submit: React.PropTypes.func, + title: React.PropTypes.string, + pictureChange: React.PropTypes.func +}; -- cgit v1.2.3-1-g7c22