Add "Add a User/Room" buttons and always display default lists

pull/21833/head
Luke Barnard 2017-09-20 14:41:29 +01:00
parent 6ad4ba767b
commit 1c6cecbd43
2 changed files with 22 additions and 15 deletions

View File

@ -54,16 +54,24 @@ const CategoryRoomList = React.createClass({
}, },
render: function() { render: function() {
const TintableSvg = sdk.getComponent("elements.TintableSvg");
const roomNodes = this.props.rooms.map((r) => { const roomNodes = this.props.rooms.map((r) => {
return <FeaturedRoom key={r.room_id} summaryInfo={r} />; return <FeaturedRoom key={r.room_id} summaryInfo={r} />;
}); });
let catHeader = null; let catHeader = null;
if (this.props.category && this.props.category.profile) { if (this.props.category && this.props.category.profile) {
catHeader = <div className="mx_GroupView_featuredThings_category">{this.props.category.profile.name}</div>; catHeader = <div className="mx_GroupView_featuredThings_category">{this.props.category.profile.name}</div>;
} }
return <div> return <div className="mx_GroupView_featuredThings_container">
{catHeader} {catHeader}
{roomNodes} {roomNodes}
<div className="mx_GroupView_featuredThings_addButton">
<TintableSvg src="img/icons-create-room.svg" width="64" height="64"/>
<div className="mx_GroupView_featuredThings_addButton_label">
{_t('Add a Room')}
</div>
</div>
</div>; </div>;
}, },
}); });
@ -125,6 +133,7 @@ const RoleUserList = React.createClass({
}, },
render: function() { render: function() {
const TintableSvg = sdk.getComponent("elements.TintableSvg");
const userNodes = this.props.users.map((u) => { const userNodes = this.props.users.map((u) => {
return <FeaturedUser key={u.user_id} summaryInfo={u} />; return <FeaturedUser key={u.user_id} summaryInfo={u} />;
}); });
@ -132,9 +141,15 @@ const RoleUserList = React.createClass({
if (this.props.role && this.props.role.profile) { if (this.props.role && this.props.role.profile) {
roleHeader = <div className="mx_GroupView_featuredThings_category">{this.props.role.profile.name}</div>; roleHeader = <div className="mx_GroupView_featuredThings_category">{this.props.role.profile.name}</div>;
} }
return <div> return <div className="mx_GroupView_featuredThings_container">
{roleHeader} {roleHeader}
{userNodes} {userNodes}
<div className="mx_GroupView_featuredThings_addButton">
<TintableSvg src="img/icons-create-room.svg" width="64" height="64"/>
<div className="mx_GroupView_featuredThings_addButton_label">
{_t('Add a User')}
</div>
</div>
</div>; </div>;
}, },
}); });
@ -369,8 +384,6 @@ export default React.createClass({
_getFeaturedRoomsNode() { _getFeaturedRoomsNode() {
const summary = this.state.summary; const summary = this.state.summary;
if (summary.rooms_section.rooms.length == 0) return null;
const defaultCategoryRooms = []; const defaultCategoryRooms = [];
const categoryRooms = {}; const categoryRooms = {};
summary.rooms_section.rooms.forEach((r) => { summary.rooms_section.rooms.forEach((r) => {
@ -386,10 +399,7 @@ export default React.createClass({
} }
}); });
let defaultCategoryNode = null; const defaultCategoryNode = <CategoryRoomList rooms={defaultCategoryRooms} />;
if (defaultCategoryRooms.length > 0) {
defaultCategoryNode = <CategoryRoomList rooms={defaultCategoryRooms} />;
}
const categoryRoomNodes = Object.keys(categoryRooms).map((catId) => { const categoryRoomNodes = Object.keys(categoryRooms).map((catId) => {
const cat = summary.rooms_section.categories[catId]; const cat = summary.rooms_section.categories[catId];
return <CategoryRoomList key={catId} rooms={categoryRooms[catId]} category={cat} />; return <CategoryRoomList key={catId} rooms={categoryRooms[catId]} category={cat} />;
@ -407,8 +417,6 @@ export default React.createClass({
_getFeaturedUsersNode() { _getFeaturedUsersNode() {
const summary = this.state.summary; const summary = this.state.summary;
if (summary.users_section.users.length == 0) return null;
const noRoleUsers = []; const noRoleUsers = [];
const roleUsers = {}; const roleUsers = {};
summary.users_section.users.forEach((u) => { summary.users_section.users.forEach((u) => {
@ -424,10 +432,7 @@ export default React.createClass({
} }
}); });
let noRoleNode = null; const noRoleNode = <RoleUserList users={noRoleUsers} />;
if (noRoleUsers.length > 0) {
noRoleNode = <RoleUserList users={noRoleUsers} />;
}
const roleUserNodes = Object.keys(roleUsers).map((roleId) => { const roleUserNodes = Object.keys(roleUsers).map((roleId) => {
const role = summary.users_section.roles[roleId]; const role = summary.users_section.roles[roleId];
return <RoleUserList key={roleId} users={roleUsers[roleId]} role={role} />; return <RoleUserList key={roleId} users={roleUsers[roleId]} role={role} />;

View File

@ -886,5 +886,7 @@
"Leave %(groupName)s?": "Leave %(groupName)s?", "Leave %(groupName)s?": "Leave %(groupName)s?",
"%(widgetName)s widget modified by %(senderName)s": "%(widgetName)s widget modified by %(senderName)s", "%(widgetName)s widget modified by %(senderName)s": "%(widgetName)s widget modified by %(senderName)s",
"Robot check is currently unavailable on desktop - please use a <a>web browser</a>": "Robot check is currently unavailable on desktop - please use a <a>web browser</a>", "Robot check is currently unavailable on desktop - please use a <a>web browser</a>": "Robot check is currently unavailable on desktop - please use a <a>web browser</a>",
"Flair": "Flair" "Flair": "Flair",
"Add a Room": "Add a Room",
"Add a User": "Add a User"
} }