From d079617ce2989b6662985af7731403d9177fddc3 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 26 Nov 2015 13:25:56 +0000 Subject: [PATCH 1/4] Nuke MemberAvatar/RoomAvatar; moved to react SDK --- src/skins/vector/views/atoms/MemberAvatar.js | 71 ------------------ src/skins/vector/views/atoms/RoomAvatar.js | 75 -------------------- 2 files changed, 146 deletions(-) delete mode 100644 src/skins/vector/views/atoms/MemberAvatar.js delete mode 100644 src/skins/vector/views/atoms/RoomAvatar.js diff --git a/src/skins/vector/views/atoms/MemberAvatar.js b/src/skins/vector/views/atoms/MemberAvatar.js deleted file mode 100644 index c719d70c59..0000000000 --- a/src/skins/vector/views/atoms/MemberAvatar.js +++ /dev/null @@ -1,71 +0,0 @@ -/* -Copyright 2015 OpenMarket Ltd - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -'use strict'; - -var React = require('react'); -var Avatar = require('../../../../Avatar'); - -var MemberAvatarController = require('matrix-react-sdk/lib/controllers/atoms/MemberAvatar') - -module.exports = React.createClass({ - displayName: 'MemberAvatar', - mixins: [MemberAvatarController], - - avatarUrlForMember: function(member) { - return Avatar.avatarUrlForMember( - member, - this.props.member, - this.props.width, - this.props.height, - this.props.resizeMethod - ); - }, - - skinnedDefaultAvatarUrl: function(member, width, height, resizeMethod) { - return Avatar.defaultAvatarUrlForString(member.userId); - }, - - render: function() { - // XXX: recalculates default avatar url constantly - if (this.state.imageUrl === this.defaultAvatarUrl(this.props.member)) { - var initial; - if (this.props.member.name[0]) - initial = this.props.member.name[0].toUpperCase(); - if (initial === '@' && this.props.member.name[1]) - initial = this.props.member.name[1].toUpperCase(); - - return ( - - - - - ); - } - return ( - - ); - } -}); diff --git a/src/skins/vector/views/atoms/RoomAvatar.js b/src/skins/vector/views/atoms/RoomAvatar.js deleted file mode 100644 index bdd28bad59..0000000000 --- a/src/skins/vector/views/atoms/RoomAvatar.js +++ /dev/null @@ -1,75 +0,0 @@ -/* -Copyright 2015 OpenMarket Ltd - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -'use strict'; - -var React = require('react'); - -var RoomAvatarController = require('matrix-react-sdk/lib/controllers/atoms/RoomAvatar') - -module.exports = React.createClass({ - displayName: 'RoomAvatar', - mixins: [RoomAvatarController], - - getUrlList: function() { - return [ - this.roomAvatarUrl(), - this.getOneToOneAvatar(), - this.getFallbackAvatar() - ]; - }, - - getFallbackAvatar: function() { - var images = [ '76cfa6', '50e2c2', 'f4c371' ]; - var total = 0; - for (var i = 0; i < this.props.room.roomId.length; ++i) { - total += this.props.room.roomId.charCodeAt(i); - } - return 'img/' + images[total % images.length] + '.png'; - }, - - render: function() { - var style = { - width: this.props.width, - height: this.props.height, - }; - - // XXX: recalculates fallback avatar constantly - if (this.state.imageUrl === this.getFallbackAvatar()) { - var initial; - if (this.props.room.name[0]) - initial = this.props.room.name[0].toUpperCase(); - if ((initial === '@' || initial === '#') && this.props.room.name[1]) - initial = this.props.room.name[1].toUpperCase(); - - return ( - - - - - ); - } - else { - return - } - - } -}); From 8898b444af0eb5a96d3b588f133b14bef483d41c Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 26 Nov 2015 13:48:37 +0000 Subject: [PATCH 2/4] Point things at the right places --- src/components/login/Login.js | 4 ++-- src/components/login/Registration.js | 2 +- src/skins/vector/skindex.js | 6 ++++-- src/skins/vector/views/molecules/EventTile.js | 4 ++-- src/skins/vector/views/molecules/MRoomMemberTile.js | 2 +- src/skins/vector/views/molecules/MemberInfo.js | 2 +- src/skins/vector/views/molecules/MemberTile.js | 2 +- src/skins/vector/views/molecules/MessageComposer.js | 2 +- src/skins/vector/views/molecules/RoomHeader.js | 2 +- src/skins/vector/views/molecules/RoomTile.js | 2 +- 10 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/components/login/Login.js b/src/components/login/Login.js index 80d0314fca..394fa0ccd1 100644 --- a/src/components/login/Login.js +++ b/src/components/login/Login.js @@ -20,8 +20,8 @@ var React = require('react'); var ReactDOM = require('react-dom'); var sdk = require('matrix-react-sdk'); var Signup = require("matrix-react-sdk/lib/Signup"); -var PasswordLogin = require("matrix-react-sdk/lib/components/login/PasswordLogin"); -var CasLogin = require("matrix-react-sdk/lib/components/login/CasLogin"); +var PasswordLogin = require("matrix-react-sdk/lib/components/views/login/PasswordLogin"); +var CasLogin = require("matrix-react-sdk/lib/components/views/login/CasLogin"); var ServerConfig = require("./ServerConfig"); /** diff --git a/src/components/login/Registration.js b/src/components/login/Registration.js index b06f9ffef5..e8d3cbb65b 100644 --- a/src/components/login/Registration.js +++ b/src/components/login/Registration.js @@ -23,7 +23,7 @@ var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg'); var dis = require('matrix-react-sdk/lib/dispatcher'); var ServerConfig = require("./ServerConfig"); var RegistrationForm = require("./RegistrationForm"); -var CaptchaForm = require("matrix-react-sdk/lib/components/login/CaptchaForm"); +var CaptchaForm = require("matrix-react-sdk/lib/components/views/login/CaptchaForm"); var Signup = require("matrix-react-sdk/lib/Signup"); var MIN_PASSWORD_LENGTH = 6; diff --git a/src/skins/vector/skindex.js b/src/skins/vector/skindex.js index 83a1284cbd..d558751b79 100644 --- a/src/skins/vector/skindex.js +++ b/src/skins/vector/skindex.js @@ -23,13 +23,15 @@ limitations under the License. var skin = {}; +// TODO: Fix this so matrix-react-sdk stuff is in react SDK. +skin['avatars.RoomAvatar'] = require('matrix-react-sdk/lib/components/views/avatars/RoomAvatar'); +skin['avatars.MemberAvatar'] = require('matrix-react-sdk/lib/components/views/avatars/MemberAvatar'); + skin['atoms.EditableText'] = require('./views/atoms/EditableText'); skin['atoms.EnableNotificationsButton'] = require('./views/atoms/EnableNotificationsButton'); skin['atoms.ImageView'] = require('./views/atoms/ImageView'); skin['atoms.LogoutButton'] = require('./views/atoms/LogoutButton'); -skin['atoms.MemberAvatar'] = require('./views/atoms/MemberAvatar'); skin['atoms.MessageTimestamp'] = require('./views/atoms/MessageTimestamp'); -skin['atoms.RoomAvatar'] = require('./views/atoms/RoomAvatar'); skin['atoms.Spinner'] = require('./views/atoms/Spinner'); skin['atoms.create_room.CreateRoomButton'] = require('./views/atoms/create_room/CreateRoomButton'); skin['atoms.create_room.Presets'] = require('./views/atoms/create_room/Presets'); diff --git a/src/skins/vector/views/molecules/EventTile.js b/src/skins/vector/views/molecules/EventTile.js index 236e7b1fd8..f3f8ae7096 100644 --- a/src/skins/vector/views/molecules/EventTile.js +++ b/src/skins/vector/views/molecules/EventTile.js @@ -109,7 +109,7 @@ module.exports = React.createClass({ return r2.data.ts - r1.data.ts; }); - var MemberAvatar = sdk.getComponent('atoms.MemberAvatar'); + var MemberAvatar = sdk.getComponent('avatars.MemberAvatar'); var left = 0; @@ -211,7 +211,7 @@ module.exports = React.createClass({ render: function() { var MessageTimestamp = sdk.getComponent('atoms.MessageTimestamp'); var SenderProfile = sdk.getComponent('molecules.SenderProfile'); - var MemberAvatar = sdk.getComponent('atoms.MemberAvatar'); + var MemberAvatar = sdk.getComponent('avatars.MemberAvatar'); var content = this.props.mxEvent.getContent(); var msgtype = content.msgtype; diff --git a/src/skins/vector/views/molecules/MRoomMemberTile.js b/src/skins/vector/views/molecules/MRoomMemberTile.js index 0048306d39..9dd51a5562 100644 --- a/src/skins/vector/views/molecules/MRoomMemberTile.js +++ b/src/skins/vector/views/molecules/MRoomMemberTile.js @@ -34,7 +34,7 @@ module.exports = React.createClass({ var text = this.getMemberEventText(); if (!text) return
; var MessageTimestamp = sdk.getComponent('atoms.MessageTimestamp'); - var MemberAvatar = sdk.getComponent('atoms.MemberAvatar'); + var MemberAvatar = sdk.getComponent('avatars.MemberAvatar'); return (
diff --git a/src/skins/vector/views/molecules/MemberInfo.js b/src/skins/vector/views/molecules/MemberInfo.js index 24fa1e91a4..8db6452f24 100644 --- a/src/skins/vector/views/molecules/MemberInfo.js +++ b/src/skins/vector/views/molecules/MemberInfo.js @@ -73,7 +73,7 @@ module.exports = React.createClass({
} - var MemberAvatar = sdk.getComponent('atoms.MemberAvatar'); + var MemberAvatar = sdk.getComponent('avatars.MemberAvatar'); return (
diff --git a/src/skins/vector/views/molecules/MemberTile.js b/src/skins/vector/views/molecules/MemberTile.js index 25ba3db94c..d0a9f47943 100644 --- a/src/skins/vector/views/molecules/MemberTile.js +++ b/src/skins/vector/views/molecules/MemberTile.js @@ -166,7 +166,7 @@ module.exports = React.createClass({
} - var MemberAvatar = sdk.getComponent('atoms.MemberAvatar'); + var MemberAvatar = sdk.getComponent('avatars.MemberAvatar'); return (
diff --git a/src/skins/vector/views/molecules/MessageComposer.js b/src/skins/vector/views/molecules/MessageComposer.js index 96001bed60..c613dac879 100644 --- a/src/skins/vector/views/molecules/MessageComposer.js +++ b/src/skins/vector/views/molecules/MessageComposer.js @@ -64,7 +64,7 @@ module.exports = React.createClass({ render: function() { var me = this.props.room.getMember(MatrixClientPeg.get().credentials.userId); var uploadInputStyle = {display: 'none'}; - var MemberAvatar = sdk.getComponent('atoms.MemberAvatar'); + var MemberAvatar = sdk.getComponent('avatars.MemberAvatar'); return (
diff --git a/src/skins/vector/views/molecules/RoomHeader.js b/src/skins/vector/views/molecules/RoomHeader.js index cc43b1cd01..e90865490b 100644 --- a/src/skins/vector/views/molecules/RoomHeader.js +++ b/src/skins/vector/views/molecules/RoomHeader.js @@ -44,7 +44,7 @@ module.exports = React.createClass({ render: function() { var EditableText = sdk.getComponent("atoms.EditableText"); - var RoomAvatar = sdk.getComponent('atoms.RoomAvatar'); + var RoomAvatar = sdk.getComponent('avatars.RoomAvatar'); var header; if (this.props.simpleHeader) { diff --git a/src/skins/vector/views/molecules/RoomTile.js b/src/skins/vector/views/molecules/RoomTile.js index 31dead455c..ec7d48b498 100644 --- a/src/skins/vector/views/molecules/RoomTile.js +++ b/src/skins/vector/views/molecules/RoomTile.js @@ -274,7 +274,7 @@ var RoomTile = React.createClass({ label = ; } - var RoomAvatar = sdk.getComponent('atoms.RoomAvatar'); + var RoomAvatar = sdk.getComponent('avatars.RoomAvatar'); // These props are injected by React DnD, // as defined by your `collect` function above: From ab22ca6a285df5e8f4833a6e82fc33db66c827ac Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 26 Nov 2015 14:11:45 +0000 Subject: [PATCH 3/4] Also move the existing login components to the new structure --- src/components/{ => structures}/login/Login.js | 2 +- src/components/{ => structures}/login/PostRegistration.js | 0 src/components/{ => structures}/login/Registration.js | 4 ++-- src/components/{ => views}/login/RegistrationForm.js | 0 src/components/{ => views}/login/ServerConfig.js | 0 src/skins/vector/views/pages/MatrixChat.js | 6 +++--- 6 files changed, 6 insertions(+), 6 deletions(-) rename src/components/{ => structures}/login/Login.js (99%) rename src/components/{ => structures}/login/PostRegistration.js (100%) rename src/components/{ => structures}/login/Registration.js (98%) rename src/components/{ => views}/login/RegistrationForm.js (100%) rename src/components/{ => views}/login/ServerConfig.js (100%) diff --git a/src/components/login/Login.js b/src/components/structures/login/Login.js similarity index 99% rename from src/components/login/Login.js rename to src/components/structures/login/Login.js index 394fa0ccd1..3503fdba9f 100644 --- a/src/components/login/Login.js +++ b/src/components/structures/login/Login.js @@ -22,7 +22,7 @@ var sdk = require('matrix-react-sdk'); var Signup = require("matrix-react-sdk/lib/Signup"); var PasswordLogin = require("matrix-react-sdk/lib/components/views/login/PasswordLogin"); var CasLogin = require("matrix-react-sdk/lib/components/views/login/CasLogin"); -var ServerConfig = require("./ServerConfig"); +var ServerConfig = require("../../views/login/ServerConfig"); /** * A wire component which glues together login UI components and Signup logic diff --git a/src/components/login/PostRegistration.js b/src/components/structures/login/PostRegistration.js similarity index 100% rename from src/components/login/PostRegistration.js rename to src/components/structures/login/PostRegistration.js diff --git a/src/components/login/Registration.js b/src/components/structures/login/Registration.js similarity index 98% rename from src/components/login/Registration.js rename to src/components/structures/login/Registration.js index e8d3cbb65b..7137582ce4 100644 --- a/src/components/login/Registration.js +++ b/src/components/structures/login/Registration.js @@ -21,8 +21,8 @@ var React = require('react'); var sdk = require('matrix-react-sdk'); var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg'); var dis = require('matrix-react-sdk/lib/dispatcher'); -var ServerConfig = require("./ServerConfig"); -var RegistrationForm = require("./RegistrationForm"); +var ServerConfig = require("../../views/login/ServerConfig"); +var RegistrationForm = require("../../views/login/RegistrationForm"); var CaptchaForm = require("matrix-react-sdk/lib/components/views/login/CaptchaForm"); var Signup = require("matrix-react-sdk/lib/Signup"); var MIN_PASSWORD_LENGTH = 6; diff --git a/src/components/login/RegistrationForm.js b/src/components/views/login/RegistrationForm.js similarity index 100% rename from src/components/login/RegistrationForm.js rename to src/components/views/login/RegistrationForm.js diff --git a/src/components/login/ServerConfig.js b/src/components/views/login/ServerConfig.js similarity index 100% rename from src/components/login/ServerConfig.js rename to src/components/views/login/ServerConfig.js diff --git a/src/skins/vector/views/pages/MatrixChat.js b/src/skins/vector/views/pages/MatrixChat.js index 2783a77f74..714c637b40 100644 --- a/src/skins/vector/views/pages/MatrixChat.js +++ b/src/skins/vector/views/pages/MatrixChat.js @@ -25,9 +25,9 @@ var dis = require('matrix-react-sdk/lib/dispatcher'); var Matrix = require("matrix-js-sdk"); var ContextualMenu = require("../../../../ContextualMenu"); -var Login = require("../../../../components/login/Login"); -var Registration = require("../../../../components/login/Registration"); -var PostRegistration = require("../../../../components/login/PostRegistration"); +var Login = require("../../../../components/structures/login/Login"); +var Registration = require("../../../../components/structures/login/Registration"); +var PostRegistration = require("../../../../components/structures/login/PostRegistration"); var config = require("../../../../../config.json"); module.exports = React.createClass({ From 8517f9f2bfaf2c7d3abe05ce95a7393c4362680e Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 26 Nov 2015 14:29:26 +0000 Subject: [PATCH 4/4] Missed one --- src/skins/vector/views/molecules/ChangeAvatar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/skins/vector/views/molecules/ChangeAvatar.js b/src/skins/vector/views/molecules/ChangeAvatar.js index 7afac77fd5..dd5727e2de 100644 --- a/src/skins/vector/views/molecules/ChangeAvatar.js +++ b/src/skins/vector/views/molecules/ChangeAvatar.js @@ -37,7 +37,7 @@ module.exports = React.createClass({ }, render: function() { - var RoomAvatar = sdk.getComponent('atoms.RoomAvatar'); + var RoomAvatar = sdk.getComponent('avatars.RoomAvatar'); var avatarImg; // Having just set an avatar we just display that since it will take a little // time to propagate through to the RoomAvatar.