Remove DragDropContext from FlairSettings

This also fixes a technical bug where one could drag a community from the settings to the LLP
This commit is contained in:
Travis Ralston 2019-02-22 11:31:17 -07:00
parent bd54a401bc
commit 014e4a2ccf
3 changed files with 51 additions and 50 deletions

View file

@ -68,7 +68,9 @@ export default React.createClass({
render() { render() {
const GroupTile = sdk.getComponent('groups.GroupTile'); const GroupTile = sdk.getComponent('groups.GroupTile');
return <div className="mx_GroupPublicity_toggle"> return <div className="mx_GroupPublicity_toggle">
<GroupTile groupId={this.props.groupId} showDescription={false} avatarHeight={40} /> <GroupTile groupId={this.props.groupId} showDescription={false}
avatarHeight={40} draggable={false}
/>
<ToggleSwitch checked={this.state.isGroupPublicised} <ToggleSwitch checked={this.state.isGroupPublicised}
disabled={!this.state.ready || this.state.busy} disabled={!this.state.ready || this.state.busy}
onChange={this._onPublicityToggle} /> onChange={this._onPublicityToggle} />

View file

@ -33,6 +33,7 @@ const GroupTile = React.createClass({
showDescription: PropTypes.bool, showDescription: PropTypes.bool,
// Height of the group avatar in pixels // Height of the group avatar in pixels
avatarHeight: PropTypes.number, avatarHeight: PropTypes.number,
draggable: PropTypes.bool,
}, },
contextTypes: { contextTypes: {
@ -49,6 +50,7 @@ const GroupTile = React.createClass({
return { return {
showDescription: true, showDescription: true,
avatarHeight: 50, avatarHeight: 50,
draggable: true,
}; };
}, },
@ -78,11 +80,21 @@ const GroupTile = React.createClass({
<div className="mx_GroupTile_desc">{ profile.shortDescription }</div> : <div className="mx_GroupTile_desc">{ profile.shortDescription }</div> :
<div />; <div />;
const httpUrl = profile.avatarUrl ? this.context.matrixClient.mxcUrlToHttp( const httpUrl = profile.avatarUrl ? this.context.matrixClient.mxcUrlToHttp(
profile.avatarUrl, avatarHeight, avatarHeight, "crop", profile.avatarUrl, avatarHeight, avatarHeight, "crop") : null;
) : null;
// XXX: Use onMouseDown as a workaround for https://github.com/atlassian/react-beautiful-dnd/issues/273 let avatarElement = (
// instead of onClick. Otherwise we experience https://github.com/vector-im/riot-web/issues/6156 <div className="mx_GroupTile_avatar">
return <AccessibleButton className="mx_GroupTile" onMouseDown={this.onMouseDown} onClick={nop}> <BaseAvatar
name={name}
idName={this.props.groupId}
url={httpUrl}
width={avatarHeight}
height={avatarHeight} />
</div>
);
if (this.props.draggable) {
const avatarClone = avatarElement;
avatarElement = (
<Droppable droppableId="my-groups-droppable" type="draggable-TagTile"> <Droppable droppableId="my-groups-droppable" type="draggable-TagTile">
{ (droppableProvided, droppableSnapshot) => ( { (droppableProvided, droppableSnapshot) => (
<div ref={droppableProvided.innerRef}> <div ref={droppableProvided.innerRef}>
@ -99,33 +111,23 @@ const GroupTile = React.createClass({
{...provided.draggableProps} {...provided.draggableProps}
{...provided.dragHandleProps} {...provided.dragHandleProps}
> >
<div className="mx_GroupTile_avatar"> {avatarClone}
<BaseAvatar
name={name}
idName={this.props.groupId}
url={httpUrl}
width={avatarHeight}
height={avatarHeight} />
</div>
</div> </div>
{ /* Instead of a blank placeholder, use a copy of the avatar itself. */ } { /* Instead of a blank placeholder, use a copy of the avatar itself. */ }
{ provided.placeholder ? { provided.placeholder ? avatarClone : <div /> }
<div className="mx_GroupTile_avatar">
<BaseAvatar
name={name}
idName={this.props.groupId}
url={httpUrl}
width={avatarHeight}
height={avatarHeight} />
</div> :
<div />
}
</div> </div>
) } ) }
</Draggable> </Draggable>
</div> </div>
) } ) }
</Droppable> </Droppable>
);
}
// XXX: Use onMouseDown as a workaround for https://github.com/atlassian/react-beautiful-dnd/issues/273
// instead of onClick. Otherwise we experience https://github.com/vector-im/riot-web/issues/6156
return <AccessibleButton className="mx_GroupTile" onMouseDown={this.onMouseDown} onClick={nop}>
{ avatarElement }
<div className="mx_GroupTile_profile"> <div className="mx_GroupTile_profile">
<div className="mx_GroupTile_name">{ name }</div> <div className="mx_GroupTile_name">{ name }</div>
{ descElement } { descElement }

View file

@ -16,7 +16,6 @@ limitations under the License.
import React from 'react'; import React from 'react';
import {_t} from "../../../../../languageHandler"; import {_t} from "../../../../../languageHandler";
import {DragDropContext} from "react-beautiful-dnd";
import GroupUserSettings from "../../../groups/GroupUserSettings"; import GroupUserSettings from "../../../groups/GroupUserSettings";
import MatrixClientPeg from "../../../../../MatrixClientPeg"; import MatrixClientPeg from "../../../../../MatrixClientPeg";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
@ -42,9 +41,7 @@ export default class FlairUserSettingsTab extends React.Component {
<div className="mx_SettingsTab"> <div className="mx_SettingsTab">
<span className="mx_SettingsTab_heading">{_t("Flair")}</span> <span className="mx_SettingsTab_heading">{_t("Flair")}</span>
<div className="mx_SettingsTab_section"> <div className="mx_SettingsTab_section">
<DragDropContext>
<GroupUserSettings /> <GroupUserSettings />
</DragDropContext>
</div> </div>
</div> </div>
); );