Implement riot-web side of dragging GroupTile avatars to TagPanel

for adding groups to the TagPanel.
This commit is contained in:
Luke Barnard 2018-02-14 16:37:32 +00:00
parent 8c1d2a4555
commit 453b7d1007
2 changed files with 17 additions and 59 deletions

View File

@ -19,7 +19,6 @@ limitations under the License.
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import classNames from 'classnames'; import classNames from 'classnames';
import { DragDropContext } from 'react-beautiful-dnd';
import { MatrixClient } from 'matrix-js-sdk'; import { MatrixClient } from 'matrix-js-sdk';
import { KeyCode } from 'matrix-react-sdk/lib/Keyboard'; import { KeyCode } from 'matrix-react-sdk/lib/Keyboard';
import sdk from 'matrix-react-sdk'; import sdk from 'matrix-react-sdk';
@ -27,8 +26,6 @@ import dis from 'matrix-react-sdk/lib/dispatcher';
import VectorConferenceHandler from '../../VectorConferenceHandler'; import VectorConferenceHandler from '../../VectorConferenceHandler';
import SettingsStore from 'matrix-react-sdk/lib/settings/SettingsStore'; 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({ var LeftPanel = React.createClass({
@ -170,47 +167,6 @@ var LeftPanel = React.createClass({
this.setState({ searchFilter: term }); 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) { collectRoomList: function(ref) {
this._roomList = ref; this._roomList = ref;
}, },
@ -250,21 +206,19 @@ var LeftPanel = React.createClass({
); );
return ( return (
<DragDropContext onDragEnd={this.onDragEnd}> <div className={containerClasses}>
<div className={containerClasses}> { tagPanel }
{ tagPanel } <aside className={classes} onKeyDown={ this._onKeyDown } onFocus={ this._onFocus } onBlur={ this._onBlur }>
<aside className={classes} onKeyDown={ this._onKeyDown } onFocus={ this._onFocus } onBlur={ this._onBlur }> { topBox }
{ topBox } <CallPreview ConferenceHandler={VectorConferenceHandler} />
<CallPreview ConferenceHandler={VectorConferenceHandler} /> <RoomList
<RoomList ref={this.collectRoomList}
ref={this.collectRoomList} collapsed={this.props.collapsed}
collapsed={this.props.collapsed} searchFilter={this.state.searchFilter}
searchFilter={this.state.searchFilter} ConferenceHandler={VectorConferenceHandler} />
ConferenceHandler={VectorConferenceHandler} /> <BottomLeftMenu collapsed={this.props.collapsed}/>
<BottomLeftMenu collapsed={this.props.collapsed}/> </aside>
</aside> </div>
</div>
</DragDropContext>
); );
} }
}); });

View File

@ -115,6 +115,10 @@ limitations under the License.
cursor: pointer; cursor: pointer;
} }
.mx_GroupTile_avatar {
cursor: -webkit-grab;
}
.mx_GroupTile_profile { .mx_GroupTile_profile {
margin-left: 10px; margin-left: 10px;
display: flex; display: flex;