Merge pull request #2834 from jryans/create-room-blocked
Rework room directory so that new room is always availablepull/21833/head
commit
3b1dfab227
|
@ -26,14 +26,17 @@ const dis = require('../../dispatcher');
|
||||||
|
|
||||||
import { linkifyAndSanitizeHtml } from '../../HtmlUtils';
|
import { linkifyAndSanitizeHtml } from '../../HtmlUtils';
|
||||||
import Promise from 'bluebird';
|
import Promise from 'bluebird';
|
||||||
|
|
||||||
import { _t } from '../../languageHandler';
|
import { _t } from '../../languageHandler';
|
||||||
|
import { instanceForInstanceId, protocolNameForInstanceId } from '../../utils/DirectoryUtils';
|
||||||
import {instanceForInstanceId, protocolNameForInstanceId} from '../../utils/DirectoryUtils';
|
import Analytics from '../../Analytics';
|
||||||
|
|
||||||
const MAX_NAME_LENGTH = 80;
|
const MAX_NAME_LENGTH = 80;
|
||||||
const MAX_TOPIC_LENGTH = 160;
|
const MAX_TOPIC_LENGTH = 160;
|
||||||
|
|
||||||
|
function track(action) {
|
||||||
|
Analytics.trackEvent('RoomDirectory', action);
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
displayName: 'RoomDirectory',
|
displayName: 'RoomDirectory',
|
||||||
|
|
||||||
|
@ -53,6 +56,7 @@ module.exports = React.createClass({
|
||||||
publicRooms: [],
|
publicRooms: [],
|
||||||
loading: true,
|
loading: true,
|
||||||
protocolsLoading: true,
|
protocolsLoading: true,
|
||||||
|
error: null,
|
||||||
instanceId: null,
|
instanceId: null,
|
||||||
includeAll: false,
|
includeAll: false,
|
||||||
roomServer: null,
|
roomServer: null,
|
||||||
|
@ -95,10 +99,12 @@ module.exports = React.createClass({
|
||||||
// thing you see when loading the client!
|
// thing you see when loading the client!
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
track('Failed to get protocol list from homeserver');
|
||||||
Modal.createTrackedDialog('Failed to get protocol list from homeserver', '', ErrorDialog, {
|
this.setState({
|
||||||
title: _t('Failed to get protocol list from homeserver'),
|
error: _t(
|
||||||
description: _t('The homeserver may be too old to support third party networks'),
|
'Riot failed to get the protocol list from the homeserver. ' +
|
||||||
|
'The homeserver may be too old to support third party networks.',
|
||||||
|
),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -187,12 +193,14 @@ module.exports = React.createClass({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({ loading: false });
|
|
||||||
console.error("Failed to get publicRooms: %s", JSON.stringify(err));
|
console.error("Failed to get publicRooms: %s", JSON.stringify(err));
|
||||||
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
track('Failed to get public room list');
|
||||||
Modal.createTrackedDialog('Failed to get public room list', '', ErrorDialog, {
|
this.setState({
|
||||||
title: _t('Failed to get public room list'),
|
loading: false,
|
||||||
description: ((err && err.message) ? err.message : _t('The server may be unavailable or overloaded')),
|
error:
|
||||||
|
`${_t('Riot failed to get the public room list.')} ` +
|
||||||
|
`${(err && err.message) ? err.message : _t('The homeserver may be unavailable or overloaded.')}`
|
||||||
|
,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -511,25 +519,15 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
const SimpleRoomHeader = sdk.getComponent('rooms.SimpleRoomHeader');
|
|
||||||
const Loader = sdk.getComponent("elements.Spinner");
|
const Loader = sdk.getComponent("elements.Spinner");
|
||||||
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
|
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
|
||||||
const AccessibleButton = sdk.getComponent('elements.AccessibleButton');
|
const AccessibleButton = sdk.getComponent('elements.AccessibleButton');
|
||||||
|
|
||||||
// TODO: clean this up
|
|
||||||
if (this.state.protocolsLoading) {
|
|
||||||
return (
|
|
||||||
<div className="mx_RoomDirectory">
|
|
||||||
<Loader />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let content;
|
let content;
|
||||||
if (this.state.loading) {
|
if (this.state.error) {
|
||||||
content = <div className="mx_RoomDirectory">
|
content = this.state.error;
|
||||||
<Loader />
|
} else if (this.state.protocolsLoading || this.state.loading) {
|
||||||
</div>;
|
content = <Loader />;
|
||||||
} else {
|
} else {
|
||||||
const rows = this.getRows();
|
const rows = this.getRows();
|
||||||
// we still show the scrollpanel, at least for now, because
|
// we still show the scrollpanel, at least for now, because
|
||||||
|
@ -557,6 +555,11 @@ module.exports = React.createClass({
|
||||||
</ScrollPanel>;
|
</ScrollPanel>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let listHeader;
|
||||||
|
if (!this.state.protocolsLoading) {
|
||||||
|
const NetworkDropdown = sdk.getComponent('directory.NetworkDropdown');
|
||||||
|
const DirectorySearchBox = sdk.getComponent('elements.DirectorySearchBox');
|
||||||
|
|
||||||
const protocolName = protocolNameForInstanceId(this.protocols, this.state.instanceId);
|
const protocolName = protocolNameForInstanceId(this.protocols, this.state.instanceId);
|
||||||
let instance_expected_field_type;
|
let instance_expected_field_type;
|
||||||
if (
|
if (
|
||||||
|
@ -586,13 +589,21 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
listHeader = <div className="mx_RoomDirectory_listheader">
|
||||||
|
<DirectorySearchBox
|
||||||
|
className="mx_RoomDirectory_searchbox"
|
||||||
|
onChange={this.onFilterChange} onClear={this.onFilterClear} onJoinClick={this.onJoinClick}
|
||||||
|
placeholder={placeholder} showJoinButton={showJoinButton}
|
||||||
|
/>
|
||||||
|
<NetworkDropdown config={this.props.config} protocols={this.protocols} onOptionChange={this.onOptionChange} />
|
||||||
|
</div>;
|
||||||
|
}
|
||||||
|
|
||||||
const createRoomButton = (<AccessibleButton
|
const createRoomButton = (<AccessibleButton
|
||||||
onClick={this.onCreateRoomClicked}
|
onClick={this.onCreateRoomClicked}
|
||||||
className="mx_RoomDirectory_createRoom"
|
className="mx_RoomDirectory_createRoom"
|
||||||
>{_t("Create new room")}</AccessibleButton>);
|
>{_t("Create new room")}</AccessibleButton>);
|
||||||
|
|
||||||
const NetworkDropdown = sdk.getComponent('directory.NetworkDropdown');
|
|
||||||
const DirectorySearchBox = sdk.getComponent('elements.DirectorySearchBox');
|
|
||||||
return (
|
return (
|
||||||
<BaseDialog
|
<BaseDialog
|
||||||
className={'mx_RoomDirectory_dialog'}
|
className={'mx_RoomDirectory_dialog'}
|
||||||
|
@ -603,14 +614,7 @@ module.exports = React.createClass({
|
||||||
>
|
>
|
||||||
<div className="mx_RoomDirectory">
|
<div className="mx_RoomDirectory">
|
||||||
<div className="mx_RoomDirectory_list">
|
<div className="mx_RoomDirectory_list">
|
||||||
<div className="mx_RoomDirectory_listheader">
|
{listHeader}
|
||||||
<DirectorySearchBox
|
|
||||||
className="mx_RoomDirectory_searchbox"
|
|
||||||
onChange={this.onFilterChange} onClear={this.onFilterClear} onJoinClick={this.onJoinClick}
|
|
||||||
placeholder={placeholder} showJoinButton={showJoinButton}
|
|
||||||
/>
|
|
||||||
<NetworkDropdown config={this.props.config} protocols={this.protocols} onOptionChange={this.onOptionChange} />
|
|
||||||
</div>
|
|
||||||
{content}
|
{content}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1379,15 +1379,15 @@
|
||||||
"Create a new community": "Create a new community",
|
"Create a new community": "Create a new community",
|
||||||
"Create a community to group together users and rooms! Build a custom homepage to mark out your space in the Matrix universe.": "Create a community to group together users and rooms! Build a custom homepage to mark out your space in the Matrix universe.",
|
"Create a community to group together users and rooms! Build a custom homepage to mark out your space in the Matrix universe.": "Create a community to group together users and rooms! Build a custom homepage to mark out your space in the Matrix universe.",
|
||||||
"You have no visible notifications": "You have no visible notifications",
|
"You have no visible notifications": "You have no visible notifications",
|
||||||
"Failed to get protocol list from homeserver": "Failed to get protocol list from homeserver",
|
"Riot failed to get the protocol list from the homeserver. The homeserver may be too old to support third party networks.": "Riot failed to get the protocol list from the homeserver. The homeserver may be too old to support third party networks.",
|
||||||
"The homeserver may be too old to support third party networks": "The homeserver may be too old to support third party networks",
|
"Riot failed to get the public room list.": "Riot failed to get the public room list.",
|
||||||
"Failed to get public room list": "Failed to get public room list",
|
"The homeserver may be unavailable or overloaded.": "The homeserver may be unavailable or overloaded.",
|
||||||
"The server may be unavailable or overloaded": "The server may be unavailable or overloaded",
|
|
||||||
"Delete the room alias %(alias)s and remove %(name)s from the directory?": "Delete the room alias %(alias)s and remove %(name)s from the directory?",
|
"Delete the room alias %(alias)s and remove %(name)s from the directory?": "Delete the room alias %(alias)s and remove %(name)s from the directory?",
|
||||||
"Remove %(name)s from the directory?": "Remove %(name)s from the directory?",
|
"Remove %(name)s from the directory?": "Remove %(name)s from the directory?",
|
||||||
"Remove from Directory": "Remove from Directory",
|
"Remove from Directory": "Remove from Directory",
|
||||||
"remove %(name)s from the directory.": "remove %(name)s from the directory.",
|
"remove %(name)s from the directory.": "remove %(name)s from the directory.",
|
||||||
"delete the alias.": "delete the alias.",
|
"delete the alias.": "delete the alias.",
|
||||||
|
"The server may be unavailable or overloaded": "The server may be unavailable or overloaded",
|
||||||
"Unable to join network": "Unable to join network",
|
"Unable to join network": "Unable to join network",
|
||||||
"Riot does not know how to join a room on this network": "Riot does not know how to join a room on this network",
|
"Riot does not know how to join a room on this network": "Riot does not know how to join a room on this network",
|
||||||
"Room not found": "Room not found",
|
"Room not found": "Room not found",
|
||||||
|
|
Loading…
Reference in New Issue