Merge pull request #2044 from matrix-org/t3chguy/optional_new_behaviour_roomsublist
make new hiding of roomsublist behaviour opt-in
This commit is contained in:
commit
7f3b5939c6
5 changed files with 68 additions and 55 deletions
|
@ -27,6 +27,7 @@ import * as RoomNotifs from '../../RoomNotifs';
|
||||||
import * as FormattingUtils from '../../utils/FormattingUtils';
|
import * as FormattingUtils from '../../utils/FormattingUtils';
|
||||||
import { KeyCode } from '../../Keyboard';
|
import { KeyCode } from '../../Keyboard';
|
||||||
import { Group } from 'matrix-js-sdk';
|
import { Group } from 'matrix-js-sdk';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
|
||||||
// turn this on for drop & drag console debugging galore
|
// turn this on for drop & drag console debugging galore
|
||||||
|
@ -40,27 +41,28 @@ const RoomSubList = React.createClass({
|
||||||
debug: debug,
|
debug: debug,
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
list: React.PropTypes.arrayOf(React.PropTypes.object).isRequired,
|
list: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||||
label: React.PropTypes.string.isRequired,
|
label: PropTypes.string.isRequired,
|
||||||
tagName: React.PropTypes.string,
|
tagName: PropTypes.string,
|
||||||
editable: React.PropTypes.bool,
|
editable: PropTypes.bool,
|
||||||
|
|
||||||
order: React.PropTypes.string.isRequired,
|
order: PropTypes.string.isRequired,
|
||||||
|
|
||||||
// passed through to RoomTile and used to highlight room with `!` regardless of notifications count
|
// passed through to RoomTile and used to highlight room with `!` regardless of notifications count
|
||||||
isInvite: React.PropTypes.bool,
|
isInvite: PropTypes.bool,
|
||||||
|
|
||||||
startAsHidden: React.PropTypes.bool,
|
startAsHidden: PropTypes.bool,
|
||||||
showSpinner: React.PropTypes.bool, // true to show a spinner if 0 elements when expanded
|
showSpinner: PropTypes.bool, // true to show a spinner if 0 elements when expanded
|
||||||
collapsed: React.PropTypes.bool.isRequired, // is LeftPanel collapsed?
|
collapsed: PropTypes.bool.isRequired, // is LeftPanel collapsed?
|
||||||
onHeaderClick: React.PropTypes.func,
|
onHeaderClick: PropTypes.func,
|
||||||
alwaysShowHeader: React.PropTypes.bool,
|
alwaysShowHeader: PropTypes.bool,
|
||||||
incomingCall: React.PropTypes.object,
|
incomingCall: PropTypes.object,
|
||||||
onShowMoreRooms: React.PropTypes.func,
|
onShowMoreRooms: PropTypes.func,
|
||||||
searchFilter: React.PropTypes.string,
|
searchFilter: PropTypes.string,
|
||||||
emptyContent: React.PropTypes.node, // content shown if the list is empty
|
emptyContent: PropTypes.node, // content shown if the list is empty
|
||||||
headerItems: React.PropTypes.node, // content shown in the sublist header
|
headerItems: PropTypes.node, // content shown in the sublist header
|
||||||
extraTiles: React.PropTypes.arrayOf(React.PropTypes.node), // extra elements added beneath tiles
|
extraTiles: PropTypes.arrayOf(PropTypes.node), // extra elements added beneath tiles
|
||||||
|
showEmpty: PropTypes.bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
|
@ -79,6 +81,7 @@ const RoomSubList = React.createClass({
|
||||||
}, // NOP
|
}, // NOP
|
||||||
extraTiles: [],
|
extraTiles: [],
|
||||||
isInvite: false,
|
isInvite: false,
|
||||||
|
showEmpty: true,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -392,6 +395,17 @@ const RoomSubList = React.createClass({
|
||||||
const TruncatedList = sdk.getComponent('elements.TruncatedList');
|
const TruncatedList = sdk.getComponent('elements.TruncatedList');
|
||||||
|
|
||||||
let content;
|
let content;
|
||||||
|
|
||||||
|
if (this.props.showEmpty) {
|
||||||
|
// this is new behaviour with still controversial UX in that in hiding RoomSubLists the drop zones for DnD
|
||||||
|
// are also gone so when filtering users can't DnD rooms to some tags but is a lot cleaner otherwise.
|
||||||
|
if (this.state.sortedList.length === 0 && !this.props.searchFilter && this.props.extraTiles.length === 0) {
|
||||||
|
content = this.props.emptyContent;
|
||||||
|
} else {
|
||||||
|
content = this.makeRoomTiles();
|
||||||
|
content.push(...this.props.extraTiles);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (this.state.sortedList.length === 0 && this.props.extraTiles.length === 0) {
|
if (this.state.sortedList.length === 0 && this.props.extraTiles.length === 0) {
|
||||||
// if no search filter is applied and there is a placeholder defined then show it, otherwise show nothing
|
// if no search filter is applied and there is a placeholder defined then show it, otherwise show nothing
|
||||||
if (!this.props.searchFilter && this.props.emptyContent) {
|
if (!this.props.searchFilter && this.props.emptyContent) {
|
||||||
|
@ -404,6 +418,7 @@ const RoomSubList = React.createClass({
|
||||||
content = this.makeRoomTiles();
|
content = this.makeRoomTiles();
|
||||||
content.push(...this.props.extraTiles);
|
content.push(...this.props.extraTiles);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (this.state.sortedList.length > 0 || this.props.extraTiles.length > 0 || this.props.editable) {
|
if (this.state.sortedList.length > 0 || this.props.extraTiles.length > 0 || this.props.editable) {
|
||||||
let subList;
|
let subList;
|
||||||
|
|
|
@ -81,6 +81,7 @@ const SIMPLE_SETTINGS = [
|
||||||
{ id: "VideoView.flipVideoHorizontally" },
|
{ id: "VideoView.flipVideoHorizontally" },
|
||||||
{ id: "TagPanel.disableTagPanel" },
|
{ id: "TagPanel.disableTagPanel" },
|
||||||
{ id: "enableWidgetScreenshots" },
|
{ id: "enableWidgetScreenshots" },
|
||||||
|
{ id: "RoomSubList.showEmpty" },
|
||||||
];
|
];
|
||||||
|
|
||||||
// These settings must be defined in SettingsStore
|
// These settings must be defined in SettingsStore
|
||||||
|
|
|
@ -16,6 +16,8 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
import SettingsStore from "../../../settings/SettingsStore";
|
||||||
|
|
||||||
const React = require("react");
|
const React = require("react");
|
||||||
const ReactDOM = require("react-dom");
|
const ReactDOM = require("react-dom");
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
@ -608,6 +610,10 @@ module.exports = React.createClass({
|
||||||
const RoomSubList = sdk.getComponent('structures.RoomSubList');
|
const RoomSubList = sdk.getComponent('structures.RoomSubList');
|
||||||
const GeminiScrollbarWrapper = sdk.getComponent("elements.GeminiScrollbarWrapper");
|
const GeminiScrollbarWrapper = sdk.getComponent("elements.GeminiScrollbarWrapper");
|
||||||
|
|
||||||
|
// XXX: we can't detect device-level (localStorage) settings onChange as the SettingsStore does not notify
|
||||||
|
// so checking on every render is the sanest thing at this time.
|
||||||
|
const showEmpty = SettingsStore.getValue('RoomSubList.showEmpty');
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
return (
|
return (
|
||||||
<GeminiScrollbarWrapper className="mx_RoomList_scrollbar"
|
<GeminiScrollbarWrapper className="mx_RoomList_scrollbar"
|
||||||
|
@ -623,6 +629,7 @@ module.exports = React.createClass({
|
||||||
searchFilter={self.props.searchFilter}
|
searchFilter={self.props.searchFilter}
|
||||||
onHeaderClick={self.onSubListHeaderClick}
|
onHeaderClick={self.onSubListHeaderClick}
|
||||||
onShowMoreRooms={self.onShowMoreRooms}
|
onShowMoreRooms={self.onShowMoreRooms}
|
||||||
|
showEmpty={showEmpty}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<RoomSubList list={self.state.lists['im.vector.fake.invite']}
|
<RoomSubList list={self.state.lists['im.vector.fake.invite']}
|
||||||
|
@ -635,6 +642,7 @@ module.exports = React.createClass({
|
||||||
searchFilter={self.props.searchFilter}
|
searchFilter={self.props.searchFilter}
|
||||||
onHeaderClick={self.onSubListHeaderClick}
|
onHeaderClick={self.onSubListHeaderClick}
|
||||||
onShowMoreRooms={self.onShowMoreRooms}
|
onShowMoreRooms={self.onShowMoreRooms}
|
||||||
|
showEmpty={showEmpty}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<RoomSubList list={self.state.lists['m.favourite']}
|
<RoomSubList list={self.state.lists['m.favourite']}
|
||||||
|
@ -647,7 +655,8 @@ module.exports = React.createClass({
|
||||||
collapsed={self.props.collapsed}
|
collapsed={self.props.collapsed}
|
||||||
searchFilter={self.props.searchFilter}
|
searchFilter={self.props.searchFilter}
|
||||||
onHeaderClick={self.onSubListHeaderClick}
|
onHeaderClick={self.onSubListHeaderClick}
|
||||||
onShowMoreRooms={self.onShowMoreRooms} />
|
onShowMoreRooms={self.onShowMoreRooms}
|
||||||
|
showEmpty={showEmpty} />
|
||||||
|
|
||||||
<RoomSubList list={self.state.lists['im.vector.fake.direct']}
|
<RoomSubList list={self.state.lists['im.vector.fake.direct']}
|
||||||
label={_t('People')}
|
label={_t('People')}
|
||||||
|
@ -661,7 +670,8 @@ module.exports = React.createClass({
|
||||||
alwaysShowHeader={true}
|
alwaysShowHeader={true}
|
||||||
searchFilter={self.props.searchFilter}
|
searchFilter={self.props.searchFilter}
|
||||||
onHeaderClick={self.onSubListHeaderClick}
|
onHeaderClick={self.onSubListHeaderClick}
|
||||||
onShowMoreRooms={self.onShowMoreRooms} />
|
onShowMoreRooms={self.onShowMoreRooms}
|
||||||
|
showEmpty={showEmpty} />
|
||||||
|
|
||||||
<RoomSubList list={self.state.lists['im.vector.fake.recent']}
|
<RoomSubList list={self.state.lists['im.vector.fake.recent']}
|
||||||
label={_t('Rooms')}
|
label={_t('Rooms')}
|
||||||
|
@ -673,7 +683,8 @@ module.exports = React.createClass({
|
||||||
collapsed={self.props.collapsed}
|
collapsed={self.props.collapsed}
|
||||||
searchFilter={self.props.searchFilter}
|
searchFilter={self.props.searchFilter}
|
||||||
onHeaderClick={self.onSubListHeaderClick}
|
onHeaderClick={self.onSubListHeaderClick}
|
||||||
onShowMoreRooms={self.onShowMoreRooms} />
|
onShowMoreRooms={self.onShowMoreRooms}
|
||||||
|
showEmpty={showEmpty} />
|
||||||
|
|
||||||
{ Object.keys(self.state.lists).map((tagName) => {
|
{ Object.keys(self.state.lists).map((tagName) => {
|
||||||
if (!tagName.match(STANDARD_TAGS_REGEX)) {
|
if (!tagName.match(STANDARD_TAGS_REGEX)) {
|
||||||
|
@ -688,7 +699,8 @@ module.exports = React.createClass({
|
||||||
collapsed={self.props.collapsed}
|
collapsed={self.props.collapsed}
|
||||||
searchFilter={self.props.searchFilter}
|
searchFilter={self.props.searchFilter}
|
||||||
onHeaderClick={self.onSubListHeaderClick}
|
onHeaderClick={self.onSubListHeaderClick}
|
||||||
onShowMoreRooms={self.onShowMoreRooms} />;
|
onShowMoreRooms={self.onShowMoreRooms}
|
||||||
|
showEmpty={showEmpty} />;
|
||||||
}
|
}
|
||||||
}) }
|
}) }
|
||||||
|
|
||||||
|
@ -702,7 +714,8 @@ module.exports = React.createClass({
|
||||||
collapsed={self.props.collapsed}
|
collapsed={self.props.collapsed}
|
||||||
searchFilter={self.props.searchFilter}
|
searchFilter={self.props.searchFilter}
|
||||||
onHeaderClick={self.onSubListHeaderClick}
|
onHeaderClick={self.onSubListHeaderClick}
|
||||||
onShowMoreRooms={self.onShowMoreRooms} />
|
onShowMoreRooms={self.onShowMoreRooms}
|
||||||
|
showEmpty={showEmpty} />
|
||||||
|
|
||||||
<RoomSubList list={self.state.lists['im.vector.fake.archived']}
|
<RoomSubList list={self.state.lists['im.vector.fake.archived']}
|
||||||
emptyContent={self.props.collapsed ? null :
|
emptyContent={self.props.collapsed ? null :
|
||||||
|
@ -722,7 +735,8 @@ module.exports = React.createClass({
|
||||||
onHeaderClick={self.onArchivedHeaderClick}
|
onHeaderClick={self.onArchivedHeaderClick}
|
||||||
incomingCall={self.state.incomingCall}
|
incomingCall={self.state.incomingCall}
|
||||||
searchFilter={self.props.searchFilter}
|
searchFilter={self.props.searchFilter}
|
||||||
onShowMoreRooms={self.onShowMoreRooms} />
|
onShowMoreRooms={self.onShowMoreRooms}
|
||||||
|
showEmpty={showEmpty} />
|
||||||
</div>
|
</div>
|
||||||
</GeminiScrollbarWrapper>
|
</GeminiScrollbarWrapper>
|
||||||
);
|
);
|
||||||
|
|
|
@ -234,6 +234,7 @@
|
||||||
"Enable URL previews by default for participants in this room": "Enable URL previews by default for participants in this room",
|
"Enable URL previews by default for participants in this room": "Enable URL previews by default for participants in this room",
|
||||||
"Room Colour": "Room Colour",
|
"Room Colour": "Room Colour",
|
||||||
"Enable widget screenshots on supported widgets": "Enable widget screenshots on supported widgets",
|
"Enable widget screenshots on supported widgets": "Enable widget screenshots on supported widgets",
|
||||||
|
"Show empty room list headings": "Show empty room list headings",
|
||||||
"Collecting app version information": "Collecting app version information",
|
"Collecting app version information": "Collecting app version information",
|
||||||
"Collecting logs": "Collecting logs",
|
"Collecting logs": "Collecting logs",
|
||||||
"Uploading report": "Uploading report",
|
"Uploading report": "Uploading report",
|
||||||
|
@ -335,7 +336,9 @@
|
||||||
"You have <a>disabled</a> URL previews by default.": "You have <a>disabled</a> URL previews by default.",
|
"You have <a>disabled</a> URL previews by default.": "You have <a>disabled</a> URL previews by default.",
|
||||||
"URL previews are enabled by default for participants in this room.": "URL previews are enabled by default for participants in this room.",
|
"URL previews are enabled by default for participants in this room.": "URL previews are enabled by default for participants in this room.",
|
||||||
"URL previews are disabled by default for participants in this room.": "URL previews are disabled by default for participants in this room.",
|
"URL previews are disabled by default for participants in this room.": "URL previews are disabled by default for participants in this room.",
|
||||||
|
"In encrypted rooms, like this one, URL previews are disabled by default to ensure that your homeserver (where the previews are generated) cannot gather information about links you see in this room.": "In encrypted rooms, like this one, URL previews are disabled by default to ensure that your homeserver (where the previews are generated) cannot gather information about links you see in this room.",
|
||||||
"URL Previews": "URL Previews",
|
"URL Previews": "URL Previews",
|
||||||
|
"When someone puts a URL in their message, a URL preview can be shown to give more information about that link such as the title, description, and an image from the website.": "When someone puts a URL in their message, a URL preview can be shown to give more information about that link such as the title, description, and an image from the website.",
|
||||||
"Cannot add any more widgets": "Cannot add any more widgets",
|
"Cannot add any more widgets": "Cannot add any more widgets",
|
||||||
"The maximum permitted number of widgets have already been added to this room.": "The maximum permitted number of widgets have already been added to this room.",
|
"The maximum permitted number of widgets have already been added to this room.": "The maximum permitted number of widgets have already been added to this room.",
|
||||||
"Add a widget": "Add a widget",
|
"Add a widget": "Add a widget",
|
||||||
|
@ -575,31 +578,6 @@
|
||||||
"Scroll to unread messages": "Scroll to unread messages",
|
"Scroll to unread messages": "Scroll to unread messages",
|
||||||
"Jump to first unread message.": "Jump to first unread message.",
|
"Jump to first unread message.": "Jump to first unread message.",
|
||||||
"Close": "Close",
|
"Close": "Close",
|
||||||
"Invalid alias format": "Invalid alias format",
|
|
||||||
"'%(alias)s' is not a valid format for an alias": "'%(alias)s' is not a valid format for an alias",
|
|
||||||
"Invalid address format": "Invalid address format",
|
|
||||||
"'%(alias)s' is not a valid format for an address": "'%(alias)s' is not a valid format for an address",
|
|
||||||
"not specified": "not specified",
|
|
||||||
"not set": "not set",
|
|
||||||
"Remote addresses for this room:": "Remote addresses for this room:",
|
|
||||||
"Addresses": "Addresses",
|
|
||||||
"The main address for this room is": "The main address for this room is",
|
|
||||||
"Local addresses for this room:": "Local addresses for this room:",
|
|
||||||
"This room has no local addresses": "This room has no local addresses",
|
|
||||||
"New address (e.g. #foo:%(localDomain)s)": "New address (e.g. #foo:%(localDomain)s)",
|
|
||||||
"Invalid community ID": "Invalid community ID",
|
|
||||||
"'%(groupId)s' is not a valid community ID": "'%(groupId)s' is not a valid community ID",
|
|
||||||
"Flair": "Flair",
|
|
||||||
"Showing flair for these communities:": "Showing flair for these communities:",
|
|
||||||
"This room is not showing flair for any communities": "This room is not showing flair for any communities",
|
|
||||||
"New community ID (e.g. +foo:%(localDomain)s)": "New community ID (e.g. +foo:%(localDomain)s)",
|
|
||||||
"You have <a>enabled</a> URL previews by default.": "You have <a>enabled</a> URL previews by default.",
|
|
||||||
"You have <a>disabled</a> URL previews by default.": "You have <a>disabled</a> URL previews by default.",
|
|
||||||
"URL previews are enabled by default for participants in this room.": "URL previews are enabled by default for participants in this room.",
|
|
||||||
"URL previews are disabled by default for participants in this room.": "URL previews are disabled by default for participants in this room.",
|
|
||||||
"In encrypted rooms, like this one, URL previews are disabled by default to ensure that your homeserver (where the previews are generated) cannot gather information about links you see in this room.": "In encrypted rooms, like this one, URL previews are disabled by default to ensure that your homeserver (where the previews are generated) cannot gather information about links you see in this room.",
|
|
||||||
"URL Previews": "URL Previews",
|
|
||||||
"When someone puts a URL in their message, a URL preview can be shown to give more information about that link such as the title, description, and an image from the website.": "When someone puts a URL in their message, a URL preview can be shown to give more information about that link such as the title, description, and an image from the website.",
|
|
||||||
"Sunday": "Sunday",
|
"Sunday": "Sunday",
|
||||||
"Monday": "Monday",
|
"Monday": "Monday",
|
||||||
"Tuesday": "Tuesday",
|
"Tuesday": "Tuesday",
|
||||||
|
|
|
@ -284,4 +284,9 @@ export const SETTINGS = {
|
||||||
supportedLevels: ['room-device'],
|
supportedLevels: ['room-device'],
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
"RoomSubList.showEmpty": {
|
||||||
|
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
|
||||||
|
displayName: _td('Show empty room list headings'),
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue