Merge pull request #1167 from matrix-org/dbkr/my_groups
Implement 'Groups' page
This commit is contained in:
commit
9643f0c00b
12 changed files with 487 additions and 33 deletions
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2015, 2016 OpenMarket Ltd
|
Copyright 2015, 2016 OpenMarket Ltd
|
||||||
|
Copyright 2017 Vector Creations Ltd
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -23,4 +24,5 @@ export default {
|
||||||
RoomDirectory: "room_directory",
|
RoomDirectory: "room_directory",
|
||||||
UserView: "user_view",
|
UserView: "user_view",
|
||||||
GroupView: "group_view",
|
GroupView: "group_view",
|
||||||
|
MyGroups: "my_groups",
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,17 +15,18 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import MatrixClientPeg from '../../MatrixClientPeg';
|
import MatrixClientPeg from '../../MatrixClientPeg';
|
||||||
import sdk from '../../index';
|
import sdk from '../../index';
|
||||||
import { sanitizedHtmlNode } from '../../HtmlUtils';
|
import { sanitizedHtmlNode } from '../../HtmlUtils';
|
||||||
import { _t } from '../../languageHandler';
|
import { _t } from '../../languageHandler';
|
||||||
|
|
||||||
|
|
||||||
module.exports = React.createClass({
|
export default React.createClass({
|
||||||
displayName: 'GroupView',
|
displayName: 'GroupView',
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
groupId: React.PropTypes.string.isRequired,
|
groupId: PropTypes.string.isRequired,
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
|
@ -65,36 +66,47 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
const BaseAvatar = sdk.getComponent("avatars.BaseAvatar");
|
const GroupAvatar = sdk.getComponent("avatars.GroupAvatar");
|
||||||
const Loader = sdk.getComponent("elements.Spinner");
|
const Loader = sdk.getComponent("elements.Spinner");
|
||||||
|
|
||||||
if (this.state.summary === null && this.state.error === null) {
|
if (this.state.summary === null && this.state.error === null) {
|
||||||
return <Loader />;
|
return <Loader />;
|
||||||
} else if (this.state.summary) {
|
} else if (this.state.summary) {
|
||||||
const summary = this.state.summary;
|
const summary = this.state.summary;
|
||||||
let avatarUrl = null;
|
|
||||||
if (summary.profile && summary.profile.avatar_url) {
|
|
||||||
avatarUrl = MatrixClientPeg.get().mxcUrlToHttp(summary.profile.avatar_url);
|
|
||||||
}
|
|
||||||
let description = null;
|
let description = null;
|
||||||
if (summary.profile && summary.profile.long_description) {
|
if (summary.profile && summary.profile.long_description) {
|
||||||
description = sanitizedHtmlNode(summary.profile.long_description);
|
description = sanitizedHtmlNode(summary.profile.long_description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let nameNode;
|
||||||
|
if (summary.profile && summary.profile.name) {
|
||||||
|
nameNode = <div className="mx_RoomHeader_name">
|
||||||
|
<span>{summary.profile.name}</span>
|
||||||
|
<span className="mx_GroupView_header_groupid">
|
||||||
|
({this.props.groupId})
|
||||||
|
</span>
|
||||||
|
</div>;
|
||||||
|
} else {
|
||||||
|
nameNode = <div className="mx_RoomHeader_name">
|
||||||
|
<span>{this.props.groupId}</span>
|
||||||
|
</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const groupAvatarUrl = summary.profile ? summary.profile.avatar_url : null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mx_GroupView">
|
<div className="mx_GroupView">
|
||||||
<div className="mx_RoomHeader">
|
<div className="mx_RoomHeader">
|
||||||
<div className="mx_RoomHeader_wrapper">
|
<div className="mx_RoomHeader_wrapper">
|
||||||
<div className="mx_RoomHeader_avatar">
|
<div className="mx_RoomHeader_avatar">
|
||||||
<BaseAvatar url={avatarUrl} name={summary.profile.name}
|
<GroupAvatar
|
||||||
width={48} height={48} />
|
groupId={this.props.groupId}
|
||||||
|
groupAvatarUrl={groupAvatarUrl}
|
||||||
|
width={48} height={48}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="mx_RoomHeader_info">
|
<div className="mx_RoomHeader_info">
|
||||||
<div className="mx_RoomHeader_name">
|
{nameNode}
|
||||||
<span>{summary.profile.name}</span>
|
|
||||||
<span className="mx_GroupView_header_groupid">
|
|
||||||
({this.props.groupId})
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div className="mx_RoomHeader_topic">
|
<div className="mx_RoomHeader_topic">
|
||||||
{summary.profile.short_description}
|
{summary.profile.short_description}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -211,6 +211,7 @@ export default React.createClass({
|
||||||
const RoomDirectory = sdk.getComponent('structures.RoomDirectory');
|
const RoomDirectory = sdk.getComponent('structures.RoomDirectory');
|
||||||
const HomePage = sdk.getComponent('structures.HomePage');
|
const HomePage = sdk.getComponent('structures.HomePage');
|
||||||
const GroupView = sdk.getComponent('structures.GroupView');
|
const GroupView = sdk.getComponent('structures.GroupView');
|
||||||
|
const MyGroups = sdk.getComponent('structures.MyGroups');
|
||||||
const MatrixToolbar = sdk.getComponent('globals.MatrixToolbar');
|
const MatrixToolbar = sdk.getComponent('globals.MatrixToolbar');
|
||||||
const NewVersionBar = sdk.getComponent('globals.NewVersionBar');
|
const NewVersionBar = sdk.getComponent('globals.NewVersionBar');
|
||||||
const UpdateCheckBar = sdk.getComponent('globals.UpdateCheckBar');
|
const UpdateCheckBar = sdk.getComponent('globals.UpdateCheckBar');
|
||||||
|
@ -248,6 +249,10 @@ export default React.createClass({
|
||||||
if (!this.props.collapse_rhs) right_panel = <RightPanel opacity={this.props.rightOpacity}/>;
|
if (!this.props.collapse_rhs) right_panel = <RightPanel opacity={this.props.rightOpacity}/>;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PageTypes.MyGroups:
|
||||||
|
page_element = <MyGroups />;
|
||||||
|
break;
|
||||||
|
|
||||||
case PageTypes.CreateRoom:
|
case PageTypes.CreateRoom:
|
||||||
page_element = <CreateRoom
|
page_element = <CreateRoom
|
||||||
onRoomCreated={this.props.onRoomCreated}
|
onRoomCreated={this.props.onRoomCreated}
|
||||||
|
@ -264,6 +269,7 @@ export default React.createClass({
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PageTypes.HomePage:
|
case PageTypes.HomePage:
|
||||||
|
{
|
||||||
// If team server config is present, pass the teamServerURL. props.teamToken
|
// If team server config is present, pass the teamServerURL. props.teamToken
|
||||||
// must also be set for the team page to be displayed, otherwise the
|
// must also be set for the team page to be displayed, otherwise the
|
||||||
// welcomePageUrl is used (which might be undefined).
|
// welcomePageUrl is used (which might be undefined).
|
||||||
|
@ -275,6 +281,7 @@ export default React.createClass({
|
||||||
teamToken={this.props.teamToken}
|
teamToken={this.props.teamToken}
|
||||||
homePageUrl={this.props.config.welcomePageUrl}
|
homePageUrl={this.props.config.welcomePageUrl}
|
||||||
/>;
|
/>;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PageTypes.UserView:
|
case PageTypes.UserView:
|
||||||
|
|
|
@ -486,6 +486,10 @@ module.exports = React.createClass({
|
||||||
this._setPage(PageTypes.RoomDirectory);
|
this._setPage(PageTypes.RoomDirectory);
|
||||||
this.notifyNewScreen('directory');
|
this.notifyNewScreen('directory');
|
||||||
break;
|
break;
|
||||||
|
case 'view_my_groups':
|
||||||
|
this._setPage(PageTypes.MyGroups);
|
||||||
|
this.notifyNewScreen('groups');
|
||||||
|
break;
|
||||||
case 'view_group':
|
case 'view_group':
|
||||||
{
|
{
|
||||||
const groupId = payload.group_id;
|
const groupId = payload.group_id;
|
||||||
|
@ -1151,6 +1155,10 @@ module.exports = React.createClass({
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'view_room_directory',
|
action: 'view_room_directory',
|
||||||
});
|
});
|
||||||
|
} else if (screen == 'groups') {
|
||||||
|
dis.dispatch({
|
||||||
|
action: 'view_my_groups',
|
||||||
|
});
|
||||||
} else if (screen == 'post_registration') {
|
} else if (screen == 'post_registration') {
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'start_post_registration',
|
action: 'start_post_registration',
|
||||||
|
|
141
src/components/structures/MyGroups.js
Normal file
141
src/components/structures/MyGroups.js
Normal file
|
@ -0,0 +1,141 @@
|
||||||
|
/*
|
||||||
|
Copyright 2017 Vector Creations 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
import sdk from '../../index';
|
||||||
|
import { _t, _tJsx } from '../../languageHandler';
|
||||||
|
import withMatrixClient from '../../wrappers/withMatrixClient';
|
||||||
|
import AccessibleButton from '../views/elements/AccessibleButton';
|
||||||
|
import dis from '../../dispatcher';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import Modal from '../../Modal';
|
||||||
|
|
||||||
|
const GroupTile = React.createClass({
|
||||||
|
displayName: 'GroupTile',
|
||||||
|
|
||||||
|
propTypes: {
|
||||||
|
groupId: PropTypes.string.isRequired,
|
||||||
|
},
|
||||||
|
|
||||||
|
onClick: function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
dis.dispatch({
|
||||||
|
action: 'view_group',
|
||||||
|
group_id: this.props.groupId,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function() {
|
||||||
|
return <a onClick={this.onClick} href="#">{this.props.groupId}</a>;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default withMatrixClient(React.createClass({
|
||||||
|
displayName: 'MyGroups',
|
||||||
|
|
||||||
|
propTypes: {
|
||||||
|
matrixClient: React.PropTypes.object.isRequired,
|
||||||
|
},
|
||||||
|
|
||||||
|
getInitialState: function() {
|
||||||
|
return {
|
||||||
|
groups: null,
|
||||||
|
error: null,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
componentWillMount: function() {
|
||||||
|
this._fetch();
|
||||||
|
},
|
||||||
|
|
||||||
|
_onCreateGroupClick: function() {
|
||||||
|
const CreateGroupDialog = sdk.getComponent("dialogs.CreateGroupDialog");
|
||||||
|
Modal.createDialog(CreateGroupDialog);
|
||||||
|
},
|
||||||
|
|
||||||
|
_fetch: function() {
|
||||||
|
this.props.matrixClient.getJoinedGroups().done((result) => {
|
||||||
|
this.setState({groups: result.groups, error: null});
|
||||||
|
}, (err) => {
|
||||||
|
this.setState({groups: null, error: err});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function() {
|
||||||
|
const Loader = sdk.getComponent("elements.Spinner");
|
||||||
|
const SimpleRoomHeader = sdk.getComponent('rooms.SimpleRoomHeader');
|
||||||
|
const TintableSvg = sdk.getComponent("elements.TintableSvg");
|
||||||
|
|
||||||
|
let content;
|
||||||
|
if (this.state.groups) {
|
||||||
|
const groupNodes = [];
|
||||||
|
this.state.groups.forEach((g) => {
|
||||||
|
groupNodes.push(
|
||||||
|
<div key={g}>
|
||||||
|
<GroupTile groupId={g} />
|
||||||
|
</div>,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
content = <div>
|
||||||
|
<div>{_t('You are a member of these groups:')}</div>
|
||||||
|
{groupNodes}
|
||||||
|
</div>;
|
||||||
|
} else if (this.state.error) {
|
||||||
|
content = <div className="mx_MyGroups_error">
|
||||||
|
{_t('Error whilst fetching joined groups')}
|
||||||
|
</div>;
|
||||||
|
} else {
|
||||||
|
content = <Loader />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return <div className="mx_MyGroups">
|
||||||
|
<SimpleRoomHeader title={ _t("Groups") } />
|
||||||
|
<div className='mx_MyGroups_joinCreateBox'>
|
||||||
|
<div className="mx_MyGroups_createBox">
|
||||||
|
<div className="mx_MyGroups_joinCreateHeader">
|
||||||
|
{_t('Create a new group')}
|
||||||
|
</div>
|
||||||
|
<AccessibleButton className='mx_MyGroups_joinCreateButton' onClick={this._onCreateGroupClick}>
|
||||||
|
<TintableSvg src="img/icons-create-room.svg" width="50" height="50" />
|
||||||
|
</AccessibleButton>
|
||||||
|
{_t(
|
||||||
|
'Create a group to represent your community! '+
|
||||||
|
'Define a set of rooms and your own custom homepage '+
|
||||||
|
'to mark out your space in the Matrix universe.',
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="mx_MyGroups_joinBox">
|
||||||
|
<div className="mx_MyGroups_joinCreateHeader">
|
||||||
|
{_t('Join an existing group')}
|
||||||
|
</div>
|
||||||
|
<AccessibleButton className='mx_MyGroups_joinCreateButton' onClick={this._onJoinGroupClick}>
|
||||||
|
<TintableSvg src="img/icons-create-room.svg" width="50" height="50" />
|
||||||
|
</AccessibleButton>
|
||||||
|
{_tJsx(
|
||||||
|
'To join an exisitng group you\'ll have to '+
|
||||||
|
'know its group identifier; this will look '+
|
||||||
|
'something like <i>+example:matrix.org</i>.',
|
||||||
|
/<i>(.*)<\/i>/,
|
||||||
|
(sub) => <i>{sub}</i>,
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="mx_MyGroups_content">
|
||||||
|
{content}
|
||||||
|
</div>
|
||||||
|
</div>;
|
||||||
|
},
|
||||||
|
}));
|
66
src/components/views/avatars/GroupAvatar.js
Normal file
66
src/components/views/avatars/GroupAvatar.js
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
Copyright 2017 Vector Creations 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import sdk from '../../../index';
|
||||||
|
import MatrixClientPeg from '../../../MatrixClientPeg';
|
||||||
|
|
||||||
|
export default React.createClass({
|
||||||
|
displayName: 'GroupAvatar',
|
||||||
|
|
||||||
|
propTypes: {
|
||||||
|
groupId: PropTypes.string,
|
||||||
|
groupAvatarUrl: PropTypes.string,
|
||||||
|
width: PropTypes.number,
|
||||||
|
height: PropTypes.number,
|
||||||
|
resizeMethod: PropTypes.string,
|
||||||
|
},
|
||||||
|
|
||||||
|
getDefaultProps: function() {
|
||||||
|
return {
|
||||||
|
width: 36,
|
||||||
|
height: 36,
|
||||||
|
resizeMethod: 'crop',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
getGroupAvatarUrl: function() {
|
||||||
|
return MatrixClientPeg.get().mxcUrlToHttp(
|
||||||
|
this.props.groupAvatarUrl,
|
||||||
|
this.props.width,
|
||||||
|
this.props.height,
|
||||||
|
this.props.resizeMethod,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function() {
|
||||||
|
const BaseAvatar = sdk.getComponent("avatars.BaseAvatar");
|
||||||
|
// extract the props we use from props so we can pass any others through
|
||||||
|
// should consider adding this as a global rule in js-sdk?
|
||||||
|
/*eslint no-unused-vars: ["error", { "ignoreRestSiblings": true }]*/
|
||||||
|
const {groupId, groupAvatarUrl, ...otherProps} = this.props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<BaseAvatar
|
||||||
|
name={this.props.groupId[1]}
|
||||||
|
idName={this.props.groupId}
|
||||||
|
url={this.getGroupAvatarUrl()}
|
||||||
|
{...otherProps}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
199
src/components/views/dialogs/CreateGroupDialog.js
Normal file
199
src/components/views/dialogs/CreateGroupDialog.js
Normal file
|
@ -0,0 +1,199 @@
|
||||||
|
/*
|
||||||
|
Copyright 2017 Vector Creations 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import sdk from '../../../index';
|
||||||
|
import dis from '../../../dispatcher';
|
||||||
|
import { _t } from '../../../languageHandler';
|
||||||
|
import MatrixClientPeg from '../../../MatrixClientPeg';
|
||||||
|
|
||||||
|
// We match fairly liberally and leave it up to the server to reject if
|
||||||
|
// there are invalid characters etc.
|
||||||
|
const GROUP_REGEX = /^\+(.*?):(.*)$/;
|
||||||
|
|
||||||
|
export default React.createClass({
|
||||||
|
displayName: 'CreateGroupDialog',
|
||||||
|
propTypes: {
|
||||||
|
onFinished: PropTypes.func.isRequired,
|
||||||
|
},
|
||||||
|
|
||||||
|
getInitialState: function() {
|
||||||
|
return {
|
||||||
|
groupName: '',
|
||||||
|
groupId: '',
|
||||||
|
groupError: null,
|
||||||
|
creating: false,
|
||||||
|
createError: null,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
_onGroupNameChange: function(e) {
|
||||||
|
this.setState({
|
||||||
|
groupName: e.target.value,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
_onGroupIdChange: function(e) {
|
||||||
|
this.setState({
|
||||||
|
groupId: e.target.value,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
_onGroupIdBlur: function(e) {
|
||||||
|
this._checkGroupId();
|
||||||
|
},
|
||||||
|
|
||||||
|
_checkGroupId: function(e) {
|
||||||
|
const parsedGroupId = this._parseGroupId(this.state.groupId);
|
||||||
|
let error = null;
|
||||||
|
if (parsedGroupId === null) {
|
||||||
|
error = _t(
|
||||||
|
"Group IDs must be of the form +localpart:%(domain)s",
|
||||||
|
{domain: MatrixClientPeg.get().getDomain()},
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const domain = parsedGroupId[1];
|
||||||
|
if (domain !== MatrixClientPeg.get().getDomain()) {
|
||||||
|
error = _t(
|
||||||
|
"It is currently only possible to create groups on your own home server: "+
|
||||||
|
"use a group ID ending with %(domain)s",
|
||||||
|
{domain: MatrixClientPeg.get().getDomain()},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.setState({
|
||||||
|
groupIdError: error,
|
||||||
|
});
|
||||||
|
return error;
|
||||||
|
},
|
||||||
|
|
||||||
|
_onFormSubmit: function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
if (this._checkGroupId()) return;
|
||||||
|
|
||||||
|
const parsedGroupId = this._parseGroupId(this.state.groupId);
|
||||||
|
const profile = {};
|
||||||
|
if (this.state.groupName !== '') {
|
||||||
|
profile.name = this.state.groupName;
|
||||||
|
}
|
||||||
|
this.setState({creating: true});
|
||||||
|
MatrixClientPeg.get().createGroup({
|
||||||
|
localpart: parsedGroupId[0],
|
||||||
|
profile: profile,
|
||||||
|
}).then((result) => {
|
||||||
|
dis.dispatch({
|
||||||
|
action: 'view_group',
|
||||||
|
group_id: result.group_id,
|
||||||
|
});
|
||||||
|
this.props.onFinished(true);
|
||||||
|
}).catch((e) => {
|
||||||
|
this.setState({createError: e});
|
||||||
|
}).finally(() => {
|
||||||
|
this.setState({creating: false});
|
||||||
|
}).done();
|
||||||
|
},
|
||||||
|
|
||||||
|
_onCancel: function() {
|
||||||
|
this.props.onFinished(false);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a string that may be a group ID
|
||||||
|
* If the string is a valid group ID, return a list of [localpart, domain],
|
||||||
|
* otherwise return null.
|
||||||
|
*
|
||||||
|
* @param {string} groupId The ID of the group
|
||||||
|
* @return {string[]} array of localpart, domain
|
||||||
|
*/
|
||||||
|
_parseGroupId: function(groupId) {
|
||||||
|
const matches = GROUP_REGEX.exec(this.state.groupId);
|
||||||
|
if (!matches || matches.length < 3) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return [matches[1], matches[2]];
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function() {
|
||||||
|
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
|
||||||
|
const Spinner = sdk.getComponent('elements.Spinner');
|
||||||
|
|
||||||
|
if (this.state.creating) {
|
||||||
|
return <Spinner />;
|
||||||
|
}
|
||||||
|
|
||||||
|
let createErrorNode;
|
||||||
|
if (this.state.createError) {
|
||||||
|
// XXX: We should catch errcodes and give sensible i18ned messages for them,
|
||||||
|
// rather than displaying what the server gives us, but synapse doesn't give
|
||||||
|
// any yet.
|
||||||
|
createErrorNode = <div className="error">
|
||||||
|
<div>{_t('Room creation failed')}</div>
|
||||||
|
<div>{this.state.createError.message}</div>
|
||||||
|
</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<BaseDialog className="mx_CreateGroupDialog" onFinished={this.props.onFinished}
|
||||||
|
onEnterPressed={this._onFormSubmit}
|
||||||
|
title={_t('Create Group')}
|
||||||
|
>
|
||||||
|
<form onSubmit={this._onFormSubmit}>
|
||||||
|
<div className="mx_Dialog_content">
|
||||||
|
<div className="mx_CreateGroupDialog_inputRow">
|
||||||
|
<div className="mx_CreateGroupDialog_label">
|
||||||
|
<label htmlFor="groupname">{_t('Group Name')}</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input id="groupname" className="mx_CreateGroupDialog_input"
|
||||||
|
autoFocus={true} size="64"
|
||||||
|
placeholder={_t('Example')}
|
||||||
|
onChange={this._onGroupNameChange}
|
||||||
|
value={this.state.groupName}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="mx_CreateGroupDialog_inputRow">
|
||||||
|
<div className="mx_CreateGroupDialog_label">
|
||||||
|
<label htmlFor="groupid">{_t('Group ID')}</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input id="groupid" className="mx_CreateGroupDialog_input"
|
||||||
|
size="64"
|
||||||
|
placeholder={_t('+example:%(domain)s', {domain: MatrixClientPeg.get().getDomain()})}
|
||||||
|
onChange={this._onGroupIdChange}
|
||||||
|
onBlur={this._onGroupIdBlur}
|
||||||
|
value={this.state.groupId}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="error">
|
||||||
|
{this.state.groupIdError}
|
||||||
|
</div>
|
||||||
|
{createErrorNode}
|
||||||
|
</div>
|
||||||
|
<div className="mx_Dialog_buttons">
|
||||||
|
<button onClick={this._onCancel}>
|
||||||
|
{ _t("Cancel") }
|
||||||
|
</button>
|
||||||
|
<input type="submit" value={_t('Create')} className="mx_Dialog_primary" />
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</BaseDialog>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
|
@ -24,7 +24,7 @@ var Modal = require('../../../Modal');
|
||||||
|
|
||||||
var sdk = require('../../../index');
|
var sdk = require('../../../index');
|
||||||
var TextForEvent = require('../../../TextForEvent');
|
var TextForEvent = require('../../../TextForEvent');
|
||||||
import WithMatrixClient from '../../../wrappers/WithMatrixClient';
|
import withMatrixClient from '../../../wrappers/withMatrixClient';
|
||||||
|
|
||||||
var ContextualMenu = require('../../structures/ContextualMenu');
|
var ContextualMenu = require('../../structures/ContextualMenu');
|
||||||
import dis from '../../../dispatcher';
|
import dis from '../../../dispatcher';
|
||||||
|
@ -59,7 +59,7 @@ var MAX_READ_AVATARS = 5;
|
||||||
// | '--------------------------------------' |
|
// | '--------------------------------------' |
|
||||||
// '----------------------------------------------------------'
|
// '----------------------------------------------------------'
|
||||||
|
|
||||||
module.exports = WithMatrixClient(React.createClass({
|
module.exports = withMatrixClient(React.createClass({
|
||||||
displayName: 'EventTile',
|
displayName: 'EventTile',
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
|
|
@ -36,12 +36,12 @@ import createRoom from '../../../createRoom';
|
||||||
import DMRoomMap from '../../../utils/DMRoomMap';
|
import DMRoomMap from '../../../utils/DMRoomMap';
|
||||||
import Unread from '../../../Unread';
|
import Unread from '../../../Unread';
|
||||||
import { findReadReceiptFromUserId } from '../../../utils/Receipt';
|
import { findReadReceiptFromUserId } from '../../../utils/Receipt';
|
||||||
import WithMatrixClient from '../../../wrappers/WithMatrixClient';
|
import withMatrixClient from '../../../wrappers/withMatrixClient';
|
||||||
import AccessibleButton from '../elements/AccessibleButton';
|
import AccessibleButton from '../elements/AccessibleButton';
|
||||||
import GeminiScrollbar from 'react-gemini-scrollbar';
|
import GeminiScrollbar from 'react-gemini-scrollbar';
|
||||||
|
|
||||||
|
|
||||||
module.exports = WithMatrixClient(React.createClass({
|
module.exports = withMatrixClient(React.createClass({
|
||||||
displayName: 'MemberInfo',
|
displayName: 'MemberInfo',
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
|
|
@ -19,10 +19,10 @@ import { _t } from '../../../languageHandler';
|
||||||
|
|
||||||
import sdk from '../../../index';
|
import sdk from '../../../index';
|
||||||
import AddThreepid from '../../../AddThreepid';
|
import AddThreepid from '../../../AddThreepid';
|
||||||
import WithMatrixClient from '../../../wrappers/WithMatrixClient';
|
import withMatrixClient from '../../../wrappers/withMatrixClient';
|
||||||
import Modal from '../../../Modal';
|
import Modal from '../../../Modal';
|
||||||
|
|
||||||
export default WithMatrixClient(React.createClass({
|
export default withMatrixClient(React.createClass({
|
||||||
displayName: 'AddPhoneNumber',
|
displayName: 'AddPhoneNumber',
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
|
|
@ -934,5 +934,23 @@
|
||||||
"You added a new device '%(displayName)s', which is requesting encryption keys.": "You added a new device '%(displayName)s', which is requesting encryption keys.",
|
"You added a new device '%(displayName)s', which is requesting encryption keys.": "You added a new device '%(displayName)s', which is requesting encryption keys.",
|
||||||
"Your unverified device '%(displayName)s' is requesting encryption keys.": "Your unverified device '%(displayName)s' is requesting encryption keys.",
|
"Your unverified device '%(displayName)s' is requesting encryption keys.": "Your unverified device '%(displayName)s' is requesting encryption keys.",
|
||||||
"Encryption key request": "Encryption key request",
|
"Encryption key request": "Encryption key request",
|
||||||
"Autocomplete Delay (ms):": "Autocomplete Delay (ms):"
|
"Autocomplete Delay (ms):": "Autocomplete Delay (ms):",
|
||||||
|
"This Home server does not support groups": "This Home server does not support groups",
|
||||||
|
"Loading device info...": "Loading device info...",
|
||||||
|
"Groups": "Groups",
|
||||||
|
"Create a new group": "Create a new group",
|
||||||
|
"Create Group": "Create Group",
|
||||||
|
"Group Name": "Group Name",
|
||||||
|
"Example": "Example",
|
||||||
|
"Create": "Create",
|
||||||
|
"Group ID": "Group ID",
|
||||||
|
"+example:%(domain)s": "+example:%(domain)s",
|
||||||
|
"Group IDs must be of the form +localpart:%(domain)s": "Group IDs must be of the form +localpart:%(domain)s",
|
||||||
|
"It is currently only possible to create groups on your own home server: use a group ID ending with %(domain)s": "It is currently only possible to create groups on your own home server: use a group ID ending with %(domain)s",
|
||||||
|
"Room creation failed": "Room creation failed",
|
||||||
|
"You are a member of these groups:": "You are a member of these groups:",
|
||||||
|
"Create a group to represent your community! Define a set of rooms and your own custom homepage to mark out your space in the Matrix universe.": "Create a group to represent your community! Define a set of rooms and your own custom homepage to mark out your space in the Matrix universe.",
|
||||||
|
"Join an existing group": "Join an existing group",
|
||||||
|
"To join an exisitng group you'll have to know its group identifier; this will look something like <i>+example:matrix.org</i>.": "To join an exisitng group you'll have to know its group identifier; this will look something like <i>+example:matrix.org</i>.",
|
||||||
|
"Error whilst fetching joined groups": "Error whilst fetching joined groups"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2015, 2016 OpenMarket Ltd
|
Copyright 2015, 2016 OpenMarket Ltd
|
||||||
|
Copyright 2017 Vector Creations Ltd
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -26,7 +27,7 @@ import React from 'react';
|
||||||
*/
|
*/
|
||||||
export default function(WrappedComponent) {
|
export default function(WrappedComponent) {
|
||||||
return React.createClass({
|
return React.createClass({
|
||||||
displayName: "WithMatrixClient<" + WrappedComponent.displayName + ">",
|
displayName: "withMatrixClient<" + WrappedComponent.displayName + ">",
|
||||||
|
|
||||||
contextTypes: {
|
contextTypes: {
|
||||||
matrixClient: React.PropTypes.instanceOf(Matrix.MatrixClient).isRequired,
|
matrixClient: React.PropTypes.instanceOf(Matrix.MatrixClient).isRequired,
|
Loading…
Add table
Add a link
Reference in a new issue