]> git.zarvox.org Git - imoo.git/commitdiff
Add propTypes to everything that takes React props
authorDrew Fisher <drew.m.fisher@gmail.com>
Sun, 18 May 2014 02:04:03 +0000 (19:04 -0700)
committerDrew Fisher <drew.m.fisher@gmail.com>
Sun, 18 May 2014 05:26:14 +0000 (22:26 -0700)
reactornado/widgets.js

index cb3e32507192bd01cd2e07b5e5c69126aee95a46..4565ebaafd95b559e718d13ed87c851696af243b 100644 (file)
@@ -41,6 +41,11 @@ var LoginForm = React.createClass({
 // Buddy list stuff
 
 var BuddyListItem = React.createClass({
+    propTypes: {
+        bicon_url: React.PropTypes.string,
+        display_name: React.PropTypes.string.isRequired,
+        status_msg: React.PropTypes.string
+    },
     render: function () {
         return <div className="buddy">
         <img className="buddyicon" src={this.props.bicon_url} />
@@ -84,6 +89,13 @@ var BuddyList = React.createClass({
 });
 
 var ConversationTab = React.createClass({
+    // TODO: consider DRY-ing these propTypes up by making some model classes?
+    propTypes: {
+        buddy: React.PropTypes.shape({
+                   display_name: React.PropTypes.string.isRequired,
+               }).isRequired,
+        onClick:  React.PropTypes.func.isRequired
+    },
     render: function() {
         var classname = "conv-tab";
         if (this.props.active) {
@@ -95,6 +107,15 @@ var ConversationTab = React.createClass({
 });
 
 var ConversationTabBar = React.createClass({
+    propTypes: {
+        tabs:        React.PropTypes.arrayOf(
+                           React.PropTypes.shape({
+                               display_name: React.PropTypes.string.isRequired,
+                           }).isRequired
+                     ).isRequired,
+        onTabSwitch: React.PropTypes.func.isRequired,
+        focused_tab: React.PropTypes.number
+    },
     render: function() {
         var tabs = [];
         for (var i = 0 ; i < this.props.tabs.length ; i++) {
@@ -111,6 +132,9 @@ var ConversationTabBar = React.createClass({
 
 var ConversationTextEntry = React.createClass({
     mixins: [React.addons.LinkedStateMixin],
+    propTypes: {
+        onSendMessage: React.PropTypes.func.isRequired
+    },
     getInitialState: function() {
         return {"text": ""};
     },
@@ -130,6 +154,18 @@ var ConversationTextEntry = React.createClass({
 });
 
 var ConversationTabContent = React.createClass({
+    propTypes: {
+        messages:      React.PropTypes.arrayOf(React.PropTypes.shape({
+                           direction: React.PropTypes.string.isRequired,
+                           timestamp: React.PropTypes.string.isRequired,
+                           text:      React.PropTypes.string.isRequired
+                       })).isRequired,
+        buddy:         React.PropTypes.shape({
+                           id:           React.PropTypes.string.isRequired,
+                           display_name: React.PropTypes.string.isRequired
+                       }),
+        onSendMessage: React.PropTypes.func.isRequired
+    },
     render: function() {
         var messages = [];
         for (var i = 0 ; i < this.props.messages.length ; i++) {