From 49e5f18f62edddede47ec288d7c37a1a15860207 Mon Sep 17 00:00:00 2001
From: Kegan Dougal <kegan@matrix.org>
Date: Thu, 26 Nov 2015 15:43:57 +0000
Subject: [PATCH] Move and merge create_room atoms to react SDK

---
 src/skins/vector/skindex.js                   |  7 +-
 .../atoms/create_room/CreateRoomButton.js     | 32 --------
 .../vector/views/atoms/create_room/Presets.js | 40 ----------
 .../views/atoms/create_room/RoomAlias.js      | 79 -------------------
 .../vector/views/organisms/CreateRoom.js      | 12 ++-
 5 files changed, 12 insertions(+), 158 deletions(-)
 delete mode 100644 src/skins/vector/views/atoms/create_room/CreateRoomButton.js
 delete mode 100644 src/skins/vector/views/atoms/create_room/Presets.js
 delete mode 100644 src/skins/vector/views/atoms/create_room/RoomAlias.js

diff --git a/src/skins/vector/skindex.js b/src/skins/vector/skindex.js
index 2f18e3d2..9de0fa3b 100644
--- a/src/skins/vector/skindex.js
+++ b/src/skins/vector/skindex.js
@@ -34,11 +34,12 @@ skin['avatars.MemberAvatar'] = require('matrix-react-sdk/lib/components/views/av
 skin['settings.EnableNotificationsButton'] = require('matrix-react-sdk/lib/components/views/settings/EnableNotificationsButton');
 skin['elements.EditableText'] = require('matrix-react-sdk/lib/components/views/elements/EditableText');
 skin['voip.VideoFeed'] = require('matrix-react-sdk/lib/components/views/voip/VideoFeed');
+skin['create_room.CreateRoomButton'] = require('matrix-react-sdk/lib/components/views/create_room/CreateRoomButton');
+skin['create_room.Presets'] = require('matrix-react-sdk/lib/components/views/create_room/Presets');
+skin['create_room.RoomAlias'] = require('matrix-react-sdk/lib/components/views/create_room/RoomAlias');
+
 
 // Old style stuff
-skin['atoms.create_room.CreateRoomButton'] = require('./views/atoms/create_room/CreateRoomButton');
-skin['atoms.create_room.Presets'] = require('./views/atoms/create_room/Presets');
-skin['atoms.create_room.RoomAlias'] = require('./views/atoms/create_room/RoomAlias');
 skin['molecules.BottomLeftMenu'] = require('./views/molecules/BottomLeftMenu');
 skin['molecules.BottomLeftMenuTile'] = require('./views/molecules/BottomLeftMenuTile');
 skin['molecules.ChangeAvatar'] = require('./views/molecules/ChangeAvatar');
diff --git a/src/skins/vector/views/atoms/create_room/CreateRoomButton.js b/src/skins/vector/views/atoms/create_room/CreateRoomButton.js
deleted file mode 100644
index 2fc9d057..00000000
--- a/src/skins/vector/views/atoms/create_room/CreateRoomButton.js
+++ /dev/null
@@ -1,32 +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 CreateRoomButtonController = require('matrix-react-sdk/lib/controllers/atoms/create_room/CreateRoomButton')
-
-module.exports = React.createClass({
-    displayName: 'CreateRoomButton',
-    mixins: [CreateRoomButtonController],
-
-    render: function() {
-        return (
-            <button className="mx_CreateRoomButton" onClick={this.onClick}>Create Room</button>
-        );
-    }
-});
diff --git a/src/skins/vector/views/atoms/create_room/Presets.js b/src/skins/vector/views/atoms/create_room/Presets.js
deleted file mode 100644
index a098a7d7..00000000
--- a/src/skins/vector/views/atoms/create_room/Presets.js
+++ /dev/null
@@ -1,40 +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 PresetsController = require('matrix-react-sdk/lib/controllers/atoms/create_room/Presets')
-
-module.exports = React.createClass({
-    displayName: 'CreateRoomPresets',
-    mixins: [PresetsController],
-
-    onValueChanged: function(ev) {
-        this.props.onChange(ev.target.value)
-    },
-
-    render: function() {
-        return (
-            <select className="mx_Presets" onChange={this.onValueChanged} value={this.props.preset}>
-                <option value={this.Presets.PrivateChat}>Private Chat</option>
-                <option value={this.Presets.PublicChat}>Public Chat</option>
-                <option value={this.Presets.Custom}>Custom</option>
-            </select>
-        );
-    }
-});
diff --git a/src/skins/vector/views/atoms/create_room/RoomAlias.js b/src/skins/vector/views/atoms/create_room/RoomAlias.js
deleted file mode 100644
index 0a8cadc8..00000000
--- a/src/skins/vector/views/atoms/create_room/RoomAlias.js
+++ /dev/null
@@ -1,79 +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 RoomAliasController = require('matrix-react-sdk/lib/controllers/atoms/create_room/RoomAlias')
-
-module.exports = React.createClass({
-    displayName: 'RoomAlias',
-    mixins: [RoomAliasController],
-
-    onValueChanged: function(ev) {
-        this.props.onChange(ev.target.value);
-    },
-
-    onFocus: function(ev) {
-        var target = ev.target;
-        var curr_val = ev.target.value;
-
-        if (this.props.homeserver) {
-            if (curr_val == "") {
-                setTimeout(function() {
-                    target.value = "#:" + this.props.homeserver;
-                    target.setSelectionRange(1, 1);
-                }, 0);
-            } else {
-                var suffix = ":" + this.props.homeserver;
-                setTimeout(function() {
-                    target.setSelectionRange(
-                        curr_val.startsWith("#") ? 1 : 0,
-                        curr_val.endsWith(suffix) ? (target.value.length - suffix.length) : target.value.length
-                    );
-                }, 0);
-            }
-        }
-    },
-
-    onBlur: function(ev) {
-        var curr_val = ev.target.value;
-
-        if (this.props.homeserver) {
-            if (curr_val == "#:" + this.props.homeserver) {
-                ev.target.value = "";
-                return;
-            }
-
-            if (curr_val != "") {
-                var new_val = ev.target.value;
-                var suffix = ":" + this.props.homeserver;
-                if (!curr_val.startsWith("#")) new_val = "#" + new_val;
-                if (!curr_val.endsWith(suffix)) new_val = new_val + suffix;
-                ev.target.value = new_val;
-            }
-        }
-    },
-
-    render: function() {
-        return (
-            <input type="text" className="mx_RoomAlias" placeholder="Alias (optional)"
-                onChange={this.onValueChanged} onFocus={this.onFocus} onBlur={this.onBlur}
-                value={this.props.alias}/>
-        );
-    }
-});
diff --git a/src/skins/vector/views/organisms/CreateRoom.js b/src/skins/vector/views/organisms/CreateRoom.js
index b54e3919..f18279db 100644
--- a/src/skins/vector/views/organisms/CreateRoom.js
+++ b/src/skins/vector/views/organisms/CreateRoom.js
@@ -22,7 +22,11 @@ var CreateRoomController = require('matrix-react-sdk/lib/controllers/organisms/C
 
 var sdk = require('matrix-react-sdk')
 
-var PresetValues = require('matrix-react-sdk/lib/controllers/atoms/create_room/Presets').Presets;
+var PresetValues = {
+    PrivateChat: "private_chat",
+    PublicChat: "public_chat",
+    Custom: "custom",
+};
 
 module.exports = React.createClass({
     displayName: 'CreateRoom',
@@ -133,9 +137,9 @@ module.exports = React.createClass({
                 );
             }
 
-            var CreateRoomButton = sdk.getComponent("atoms.create_room.CreateRoomButton");
-            var RoomAlias = sdk.getComponent("atoms.create_room.RoomAlias");
-            var Presets = sdk.getComponent("atoms.create_room.Presets");
+            var CreateRoomButton = sdk.getComponent("create_room.CreateRoomButton");
+            var RoomAlias = sdk.getComponent("create_room.RoomAlias");
+            var Presets = sdk.getComponent("create_room.Presets");
             var UserSelector = sdk.getComponent("molecules.UserSelector");
             var RoomHeader = sdk.getComponent("molecules.RoomHeader");