From 8d27cfde36c8e4f205b1f014b180eaec6c7357ee Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Wed, 27 Mar 2019 13:57:48 +0000 Subject: [PATCH 1/3] Remove unused import --- src/components/structures/RoomDirectory.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/structures/RoomDirectory.js b/src/components/structures/RoomDirectory.js index e13eab8eb3a..b155f514f4f 100644 --- a/src/components/structures/RoomDirectory.js +++ b/src/components/structures/RoomDirectory.js @@ -511,7 +511,6 @@ module.exports = React.createClass({ }, render: function() { - const SimpleRoomHeader = sdk.getComponent('rooms.SimpleRoomHeader'); const Loader = sdk.getComponent("elements.Spinner"); const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); const AccessibleButton = sdk.getComponent('elements.AccessibleButton'); From 0466e0a3067c31dff975677e131c1d291c7a7201 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Wed, 27 Mar 2019 14:17:24 +0000 Subject: [PATCH 2/3] Reorganise room directory code so new room is always available This reorganises the room directory so that the new room buttons is always available no matter what state the overall directory is in. Part of https://github.com/vector-im/riot-web/issues/9046 --- src/components/structures/RoomDirectory.js | 87 ++++++++++------------ 1 file changed, 41 insertions(+), 46 deletions(-) diff --git a/src/components/structures/RoomDirectory.js b/src/components/structures/RoomDirectory.js index b155f514f4f..d0c0c32eaad 100644 --- a/src/components/structures/RoomDirectory.js +++ b/src/components/structures/RoomDirectory.js @@ -515,20 +515,9 @@ module.exports = React.createClass({ const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); const AccessibleButton = sdk.getComponent('elements.AccessibleButton'); - // TODO: clean this up - if (this.state.protocolsLoading) { - return ( -
- -
- ); - } - let content; - if (this.state.loading) { - content =
- -
; + if (this.state.protocolsLoading || this.state.loading) { + content = ; } else { const rows = this.getRows(); // we still show the scrollpanel, at least for now, because @@ -556,33 +545,48 @@ module.exports = React.createClass({ ; } - const protocolName = protocolNameForInstanceId(this.protocols, this.state.instanceId); - let instance_expected_field_type; - if ( - protocolName && - this.protocols && - this.protocols[protocolName] && - this.protocols[protocolName].location_fields.length > 0 && - this.protocols[protocolName].field_types - ) { - const last_field = this.protocols[protocolName].location_fields.slice(-1)[0]; - instance_expected_field_type = this.protocols[protocolName].field_types[last_field]; - } + 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); + let instance_expected_field_type; + if ( + protocolName && + this.protocols && + this.protocols[protocolName] && + this.protocols[protocolName].location_fields.length > 0 && + this.protocols[protocolName].field_types + ) { + const last_field = this.protocols[protocolName].location_fields.slice(-1)[0]; + instance_expected_field_type = this.protocols[protocolName].field_types[last_field]; + } - let placeholder = _t('Search for a room'); - if (!this.state.instanceId) { - placeholder = _t('Search for a room like #example') + ':' + this.state.roomServer; - } else if (instance_expected_field_type) { - placeholder = instance_expected_field_type.placeholder; - } + let placeholder = _t('Search for a room'); + if (!this.state.instanceId) { + placeholder = _t('Search for a room like #example') + ':' + this.state.roomServer; + } else if (instance_expected_field_type) { + placeholder = instance_expected_field_type.placeholder; + } - let showJoinButton = this._stringLooksLikeId(this.state.filterString, instance_expected_field_type); - if (protocolName) { - const instance = instanceForInstanceId(this.protocols, this.state.instanceId); - if (this._getFieldsForThirdPartyLocation(this.state.filterString, this.protocols[protocolName], instance) === null) { - showJoinButton = false; + let showJoinButton = this._stringLooksLikeId(this.state.filterString, instance_expected_field_type); + if (protocolName) { + const instance = instanceForInstanceId(this.protocols, this.state.instanceId); + if (this._getFieldsForThirdPartyLocation(this.state.filterString, this.protocols[protocolName], instance) === null) { + showJoinButton = false; + } } + + listHeader =
+ + +
; } const createRoomButton = ({_t("Create new room")}); - const NetworkDropdown = sdk.getComponent('directory.NetworkDropdown'); - const DirectorySearchBox = sdk.getComponent('elements.DirectorySearchBox'); return (
-
- - -
+ {listHeader} {content}
From 055f8330425e321fde110a491150c74c09714c81 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Wed, 27 Mar 2019 14:54:18 +0000 Subject: [PATCH 3/3] Change loading errors in room directory to inline instead of modal This changes errors that may occur when loading the room directory so that the message appears inline with the overall directory UI instead of in a new modal. This is important so that the new room button remains on screen even if the directory is down. Fixes https://github.com/vector-im/riot-web/issues/9046 --- src/components/structures/RoomDirectory.js | 36 ++++++++++++++-------- src/i18n/strings/en_EN.json | 8 ++--- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/components/structures/RoomDirectory.js b/src/components/structures/RoomDirectory.js index d0c0c32eaad..a7211f6f462 100644 --- a/src/components/structures/RoomDirectory.js +++ b/src/components/structures/RoomDirectory.js @@ -26,14 +26,17 @@ const dis = require('../../dispatcher'); import { linkifyAndSanitizeHtml } from '../../HtmlUtils'; import Promise from 'bluebird'; - 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_TOPIC_LENGTH = 160; +function track(action) { + Analytics.trackEvent('RoomDirectory', action); +} + module.exports = React.createClass({ displayName: 'RoomDirectory', @@ -53,6 +56,7 @@ module.exports = React.createClass({ publicRooms: [], loading: true, protocolsLoading: true, + error: null, instanceId: null, includeAll: false, roomServer: null, @@ -95,10 +99,12 @@ module.exports = React.createClass({ // thing you see when loading the client! return; } - const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); - Modal.createTrackedDialog('Failed to get protocol list from homeserver', '', ErrorDialog, { - title: _t('Failed to get protocol list from homeserver'), - description: _t('The homeserver may be too old to support third party networks'), + track('Failed to get protocol list from homeserver'); + this.setState({ + error: _t( + '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; } - this.setState({ loading: false }); console.error("Failed to get publicRooms: %s", JSON.stringify(err)); - const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); - Modal.createTrackedDialog('Failed to get public room list', '', ErrorDialog, { - title: _t('Failed to get public room list'), - description: ((err && err.message) ? err.message : _t('The server may be unavailable or overloaded')), + track('Failed to get public room list'); + this.setState({ + loading: false, + error: + `${_t('Riot failed to get the public room list.')} ` + + `${(err && err.message) ? err.message : _t('The homeserver may be unavailable or overloaded.')}` + , }); }); }, @@ -516,7 +524,9 @@ module.exports = React.createClass({ const AccessibleButton = sdk.getComponent('elements.AccessibleButton'); let content; - if (this.state.protocolsLoading || this.state.loading) { + if (this.state.error) { + content = this.state.error; + } else if (this.state.protocolsLoading || this.state.loading) { content = ; } else { const rows = this.getRows(); diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index e85537ba038..94d524d767c 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1379,15 +1379,15 @@ "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.", "You have no visible notifications": "You have no visible notifications", - "Failed to get protocol list from homeserver": "Failed to get protocol list from homeserver", - "The homeserver may be too old to support third party networks": "The homeserver may be too old to support third party networks", - "Failed to get public room list": "Failed to get public room list", - "The server may be unavailable or overloaded": "The server may be unavailable or overloaded", + "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.", + "Riot failed to get the public room list.": "Riot failed to get the public room list.", + "The homeserver may be unavailable or overloaded.": "The homeserver 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?", "Remove %(name)s from the directory?": "Remove %(name)s from the directory?", "Remove from Directory": "Remove from Directory", "remove %(name)s from the directory.": "remove %(name)s from the directory.", "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", "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",