Skip to content

Commit

Permalink
Merge pull request #6143 from vector-im/luke/dnd-group-view-tag-panel
Browse files Browse the repository at this point in the history
Implement riot-web side of dragging GroupTile avatars to TagPanel
  • Loading branch information
lukebarnard1 committed Feb 15, 2018
2 parents 8c1d2a4 + f64fefa commit f625590
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 61 deletions.
72 changes: 13 additions & 59 deletions src/components/structures/LeftPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@ limitations under the License.
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { DragDropContext } from 'react-beautiful-dnd';
import { MatrixClient } from 'matrix-js-sdk';
import { KeyCode } from 'matrix-react-sdk/lib/Keyboard';
import sdk from 'matrix-react-sdk';
import dis from 'matrix-react-sdk/lib/dispatcher';
import VectorConferenceHandler from '../../VectorConferenceHandler';

import SettingsStore from 'matrix-react-sdk/lib/settings/SettingsStore';
import TagOrderActions from 'matrix-react-sdk/lib/actions/TagOrderActions';
import RoomListActions from 'matrix-react-sdk/lib/actions/RoomListActions';


var LeftPanel = React.createClass({
Expand Down Expand Up @@ -170,47 +167,6 @@ var LeftPanel = React.createClass({
this.setState({ searchFilter: term });
},

onDragEnd: function(result) {
// Dragged to an invalid destination, not onto a droppable
if (!result.destination) {
return;
}

const dest = result.destination.droppableId;

if (dest === 'tag-panel-droppable') {
// Dispatch synchronously so that the TagPanel receives an
// optimistic update from TagOrderStore before the previous
// state is shown.
dis.dispatch(TagOrderActions.moveTag(
this.context.matrixClient,
result.draggableId,
result.destination.index,
), true);
} else {
this.onRoomTileEndDrag(result);
}
},

onRoomTileEndDrag: function(result) {
let newTag = result.destination.droppableId.split('_')[1];
let prevTag = result.source.droppableId.split('_')[1];
if (newTag === 'undefined') newTag = undefined;
if (prevTag === 'undefined') prevTag = undefined;

const roomId = result.draggableId.split('_')[1];

const oldIndex = result.source.index;
const newIndex = result.destination.index;

dis.dispatch(RoomListActions.tagRoom(
this.context.matrixClient,
this.context.matrixClient.getRoom(roomId),
prevTag, newTag,
oldIndex, newIndex,
), true);
},

collectRoomList: function(ref) {
this._roomList = ref;
},
Expand Down Expand Up @@ -250,21 +206,19 @@ var LeftPanel = React.createClass({
);

return (
<DragDropContext onDragEnd={this.onDragEnd}>
<div className={containerClasses}>
{ tagPanel }
<aside className={classes} onKeyDown={ this._onKeyDown } onFocus={ this._onFocus } onBlur={ this._onBlur }>
{ topBox }
<CallPreview ConferenceHandler={VectorConferenceHandler} />
<RoomList
ref={this.collectRoomList}
collapsed={this.props.collapsed}
searchFilter={this.state.searchFilter}
ConferenceHandler={VectorConferenceHandler} />
<BottomLeftMenu collapsed={this.props.collapsed}/>
</aside>
</div>
</DragDropContext>
<div className={containerClasses}>
{ tagPanel }
<aside className={classes} onKeyDown={ this._onKeyDown } onFocus={ this._onFocus } onBlur={ this._onBlur }>
{ topBox }
<CallPreview ConferenceHandler={VectorConferenceHandler} />
<RoomList
ref={this.collectRoomList}
collapsed={this.props.collapsed}
searchFilter={this.state.searchFilter}
ConferenceHandler={VectorConferenceHandler} />
<BottomLeftMenu collapsed={this.props.collapsed}/>
</aside>
</div>
);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ limitations under the License.
text-align: center;
}

.mx_MyGroups_joinedGroups .gm-scroll-view {
.mx_MyGroups_joinedGroups {
border-top: 1px solid $primary-hairline-color;
overflow-x: hidden;

Expand All @@ -104,7 +104,7 @@ limitations under the License.
align-content: flex-start;
}

.mx_MyGroups_joinedGroups .gm-scroll-view .mx_GroupTile {
.mx_MyGroups_joinedGroups .mx_GroupTile {
min-width: 300px;
max-width: 33%;
flex: 1 0 300px;
Expand All @@ -115,6 +115,10 @@ limitations under the License.
cursor: pointer;
}

.mx_GroupTile_avatar {
cursor: grab, -webkit-grab;
}

.mx_GroupTile_profile {
margin-left: 10px;
display: flex;
Expand Down

0 comments on commit f625590

Please sign in to comment.