wire up view_group_grid action from community context menu to new view

This commit is contained in:
Bruno Windels 2018-11-07 16:34:10 +01:00
parent d4748c91df
commit 399d3c5c24
4 changed files with 34 additions and 1 deletions

View file

@ -19,6 +19,7 @@ limitations under the License.
export default { export default {
HomePage: "home_page", HomePage: "home_page",
RoomView: "room_view", RoomView: "room_view",
GroupGridView: "group_grid_view",
UserSettings: "user_settings", UserSettings: "user_settings",
RoomDirectory: "room_directory", RoomDirectory: "room_directory",
UserView: "user_view", UserView: "user_view",

View file

@ -31,6 +31,7 @@ import sessionStore from '../../stores/SessionStore';
import MatrixClientPeg from '../../MatrixClientPeg'; import MatrixClientPeg from '../../MatrixClientPeg';
import SettingsStore from "../../settings/SettingsStore"; import SettingsStore from "../../settings/SettingsStore";
import RoomListStore from "../../stores/RoomListStore"; import RoomListStore from "../../stores/RoomListStore";
import OpenRoomsStore from "../../stores/OpenRoomsStore";
import TagOrderActions from '../../actions/TagOrderActions'; import TagOrderActions from '../../actions/TagOrderActions';
import RoomListActions from '../../actions/RoomListActions'; import RoomListActions from '../../actions/RoomListActions';
@ -416,6 +417,7 @@ const LoggedInView = 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 GroupGridView = sdk.getComponent('structures.GroupGridView');
const MyGroups = sdk.getComponent('structures.MyGroups'); const MyGroups = sdk.getComponent('structures.MyGroups');
const MatrixToolbar = sdk.getComponent('globals.MatrixToolbar'); const MatrixToolbar = sdk.getComponent('globals.MatrixToolbar');
const CookieBar = sdk.getComponent('globals.CookieBar'); const CookieBar = sdk.getComponent('globals.CookieBar');
@ -428,6 +430,12 @@ const LoggedInView = React.createClass({
switch (this.props.page_type) { switch (this.props.page_type) {
case PageTypes.RoomView: case PageTypes.RoomView:
if (!OpenRoomsStore.getCurrentRoomStore()) {
console.warn(`LoggedInView: getCurrentRoomStore not set!`);
}
else if (OpenRoomsStore.getCurrentRoomStore().getRoomId() !== this.props.currentRoomId) {
console.warn(`LoggedInView: room id in store not the same as in props: ${OpenRoomsStore.getCurrentRoomStore().getRoomId()} & ${this.props.currentRoomId}`);
}
page_element = <RoomView page_element = <RoomView
roomViewStore={OpenRoomsStore.getCurrentRoomStore()} roomViewStore={OpenRoomsStore.getCurrentRoomStore()}
ref='roomView' ref='roomView'
@ -443,7 +451,9 @@ const LoggedInView = React.createClass({
ConferenceHandler={this.props.ConferenceHandler} ConferenceHandler={this.props.ConferenceHandler}
/>; />;
break; break;
case PageTypes.GroupGridView:
page_element = <GroupGridView />;
break;
case PageTypes.UserSettings: case PageTypes.UserSettings:
page_element = <UserSettings page_element = <UserSettings
onClose={this.props.onCloseAllSettings} onClose={this.props.onCloseAllSettings}

View file

@ -627,6 +627,9 @@ export default React.createClass({
case 'view_group': case 'view_group':
this._viewGroup(payload); this._viewGroup(payload);
break; break;
case 'view_group_grid':
this._viewGroupGrid(payload);
break;
case 'view_home_page': case 'view_home_page':
this._viewHome(); this._viewHome();
break; break;
@ -834,6 +837,8 @@ export default React.createClass({
// room name and avatar from an invite email) // room name and avatar from an invite email)
_viewRoom: function(roomInfo) { _viewRoom: function(roomInfo) {
this.focusComposer = true; this.focusComposer = true;
console.log("!!! MatrixChat._viewRoom", roomInfo);
console.trace();
const newState = { const newState = {
currentRoomId: roomInfo.room_id || null, currentRoomId: roomInfo.room_id || null,
@ -898,6 +903,11 @@ export default React.createClass({
this.notifyNewScreen('group/' + groupId); this.notifyNewScreen('group/' + groupId);
}, },
_viewGroupGrid: function(payload) {
this._setPage(PageTypes.GroupGridView);
// this.notifyNewScreen('grid/' + payload.group_id);
},
_viewHome: function() { _viewHome: function() {
this._setPage(PageTypes.HomePage); this._setPage(PageTypes.HomePage);
this.notifyNewScreen('home'); this.notifyNewScreen('home');

View file

@ -34,6 +34,7 @@ export default class TagTileContextMenu extends React.Component {
this._onViewCommunityClick = this._onViewCommunityClick.bind(this); this._onViewCommunityClick = this._onViewCommunityClick.bind(this);
this._onRemoveClick = this._onRemoveClick.bind(this); this._onRemoveClick = this._onRemoveClick.bind(this);
this._onViewAsGridClick = this._onViewAsGridClick.bind(this);
} }
_onViewCommunityClick() { _onViewCommunityClick() {
@ -53,6 +54,14 @@ export default class TagTileContextMenu extends React.Component {
this.props.onFinished(); this.props.onFinished();
} }
_onViewAsGridClick() {
dis.dispatch({
action: 'view_group_grid',
group_id: this.props.tag,
});
this.props.onFinished();
}
render() { render() {
const TintableSvg = sdk.getComponent("elements.TintableSvg"); const TintableSvg = sdk.getComponent("elements.TintableSvg");
return <div> return <div>
@ -65,6 +74,9 @@ export default class TagTileContextMenu extends React.Component {
/> />
{ _t('View Community') } { _t('View Community') }
</div> </div>
<div className="mx_TagTileContextMenu_item" onClick={this._onViewAsGridClick} >
{ _t('View as grid') }
</div>
<hr className="mx_TagTileContextMenu_separator" /> <hr className="mx_TagTileContextMenu_separator" />
<div className="mx_TagTileContextMenu_item" onClick={this._onRemoveClick} > <div className="mx_TagTileContextMenu_item" onClick={this._onRemoveClick} >
<img className="mx_TagTileContextMenu_item_icon" src="img/icon_context_delete.svg" width="15" height="15" /> <img className="mx_TagTileContextMenu_item_icon" src="img/icon_context_delete.svg" width="15" height="15" />