Merge pull request #3909 from matrix-org/t3chguy/invite_reject_ignore

Add Reject & Ignore user button to invites view
This commit is contained in:
Michael Telatynski 2020-01-23 14:59:19 +00:00 committed by GitHub
commit 26aa4bb4f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 57 additions and 4 deletions

View file

@ -123,6 +123,11 @@ limitations under the License.
& > * { & > * {
margin-top: 12px; margin-top: 12px;
} }
.mx_AccessibleButton.mx_AccessibleButton_kind_primary {
// to account for the padding of the primary button which causes inconsistent look between
// subsequent secondary (text) buttons
margin-bottom: 7px;
}
} }
} }

View file

@ -1367,6 +1367,41 @@ export default createReactClass({
}); });
}, },
onRejectAndIgnoreClick: async function() {
this.setState({
rejecting: true,
});
const cli = MatrixClientPeg.get();
try {
const myMember = this.state.room.getMember(cli.getUserId());
const inviteEvent = myMember.events.member;
const ignoredUsers = MatrixClientPeg.get().getIgnoredUsers();
ignoredUsers.push(inviteEvent.getSender()); // de-duped internally in the js-sdk
await cli.setIgnoredUsers(ignoredUsers);
await cli.leave(this.state.roomId);
dis.dispatch({ action: 'view_next_room' });
this.setState({
rejecting: false,
});
} catch (error) {
console.error("Failed to reject invite: %s", error);
const msg = error.message ? error.message : JSON.stringify(error);
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
Modal.createTrackedDialog('Failed to reject invite', '', ErrorDialog, {
title: _t("Failed to reject invite"),
description: msg,
});
self.setState({
rejecting: false,
rejectError: error,
});
}
},
onRejectThreepidInviteButtonClicked: function(ev) { onRejectThreepidInviteButtonClicked: function(ev) {
// We can reject 3pid invites in the same way that we accept them, // We can reject 3pid invites in the same way that we accept them,
// using /leave rather than /join. In the short term though, we // using /leave rather than /join. In the short term though, we
@ -1671,9 +1706,11 @@ export default createReactClass({
return ( return (
<div className="mx_RoomView"> <div className="mx_RoomView">
<ErrorBoundary> <ErrorBoundary>
<RoomPreviewBar onJoinClick={this.onJoinButtonClicked} <RoomPreviewBar
onJoinClick={this.onJoinButtonClicked}
onForgetClick={this.onForgetClick} onForgetClick={this.onForgetClick}
onRejectClick={this.onRejectButtonClicked} onRejectClick={this.onRejectButtonClicked}
onRejectAndIgnoreClick={this.onRejectAndIgnoreClick}
inviterName={inviterName} inviterName={inviterName}
canPreview={false} canPreview={false}
joining={this.state.joining} joining={this.state.joining}

View file

@ -49,6 +49,7 @@ export default createReactClass({
propTypes: { propTypes: {
onJoinClick: PropTypes.func, onJoinClick: PropTypes.func,
onRejectClick: PropTypes.func, onRejectClick: PropTypes.func,
onRejectAndIgnoreClick: PropTypes.func,
onForgetClick: PropTypes.func, onForgetClick: PropTypes.func,
// if inviterName is specified, the preview bar will shown an invite to the room. // if inviterName is specified, the preview bar will shown an invite to the room.
// You should also specify onRejectClick if specifiying inviterName // You should also specify onRejectClick if specifiying inviterName
@ -282,6 +283,7 @@ export default createReactClass({
render: function() { render: function() {
const Spinner = sdk.getComponent('elements.Spinner'); const Spinner = sdk.getComponent('elements.Spinner');
const AccessibleButton = sdk.getComponent('elements.AccessibleButton');
let showSpinner = false; let showSpinner = false;
let darkStyle = false; let darkStyle = false;
@ -292,6 +294,7 @@ export default createReactClass({
let secondaryActionHandler; let secondaryActionHandler;
let secondaryActionLabel; let secondaryActionLabel;
let footer; let footer;
const extraComponents = [];
const messageCase = this._getMessageCase(); const messageCase = this._getMessageCase();
switch (messageCase) { switch (messageCase) {
@ -469,6 +472,14 @@ export default createReactClass({
primaryActionHandler = this.props.onJoinClick; primaryActionHandler = this.props.onJoinClick;
secondaryActionLabel = _t("Reject"); secondaryActionLabel = _t("Reject");
secondaryActionHandler = this.props.onRejectClick; secondaryActionHandler = this.props.onRejectClick;
if (this.props.onRejectAndIgnoreClick) {
extraComponents.push(
<AccessibleButton kind="secondary" onClick={this.props.onRejectAndIgnoreClick} key="ignore">
{ _t("Reject & Ignore user") }
</AccessibleButton>,
);
}
break; break;
} }
case MessageCase.ViewingRoom: { case MessageCase.ViewingRoom: {
@ -505,8 +516,6 @@ export default createReactClass({
} }
} }
const AccessibleButton = sdk.getComponent('elements.AccessibleButton');
let subTitleElements; let subTitleElements;
if (subTitle) { if (subTitle) {
if (!Array.isArray(subTitle)) { if (!Array.isArray(subTitle)) {
@ -554,6 +563,7 @@ export default createReactClass({
</div> </div>
<div className="mx_RoomPreviewBar_actions"> <div className="mx_RoomPreviewBar_actions">
{ secondaryButton } { secondaryButton }
{ extraComponents }
{ primaryButton } { primaryButton }
</div> </div>
<div className="mx_RoomPreviewBar_footer"> <div className="mx_RoomPreviewBar_footer">

View file

@ -1046,6 +1046,7 @@
"Do you want to join %(roomName)s?": "Do you want to join %(roomName)s?", "Do you want to join %(roomName)s?": "Do you want to join %(roomName)s?",
"<userName/> invited you": "<userName/> invited you", "<userName/> invited you": "<userName/> invited you",
"Reject": "Reject", "Reject": "Reject",
"Reject & Ignore user": "Reject & Ignore user",
"You're previewing %(roomName)s. Want to join it?": "You're previewing %(roomName)s. Want to join it?", "You're previewing %(roomName)s. Want to join it?": "You're previewing %(roomName)s. Want to join it?",
"%(roomName)s can't be previewed. Do you want to join it?": "%(roomName)s can't be previewed. Do you want to join it?", "%(roomName)s can't be previewed. Do you want to join it?": "%(roomName)s can't be previewed. Do you want to join it?",
"%(roomName)s does not exist.": "%(roomName)s does not exist.", "%(roomName)s does not exist.": "%(roomName)s does not exist.",