diff --git a/CHANGELOG.md b/CHANGELOG.md index 01cd3be22f..de10ef48be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,39 @@ +Changes in [1.5.3](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v1.5.3) (2019-09-16) +=================================================================================================== +[Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v1.5.3-rc.3...v1.5.3) + + * Release: Directory should use the alias or server information to join the + room + [\#3448](https://github.com/matrix-org/matrix-react-sdk/pull/3448) + +Changes in [1.5.3-rc.3](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v1.5.3-rc.3) (2019-09-13) +============================================================================================================= +[Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v1.5.3-rc.2...v1.5.3-rc.3) + + * js-sdk rc.1 for report API + +Changes in [1.5.3-rc.2](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v1.5.3-rc.2) (2019-09-13) +============================================================================================================= +[Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v1.5.3-rc.1...v1.5.3-rc.2) + + * Fix: stop propagation click handler for doesn't run + [\#3443](https://github.com/matrix-org/matrix-react-sdk/pull/3443) + * Add way to report the content of a message + [\#3442](https://github.com/matrix-org/matrix-react-sdk/pull/3442) + * Fix synapse deactivate button for release + [\#3436](https://github.com/matrix-org/matrix-react-sdk/pull/3436) + * Fix: clicking on a room directory item takes you to the room + [\#3440](https://github.com/matrix-org/matrix-react-sdk/pull/3440) + +Changes in [1.5.3-rc.1](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v1.5.3-rc.1) (2019-09-12) +============================================================================================================= +[Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v1.5.2...v1.5.3-rc.1) + + * Fix: only hide clear filter button when blurred & no more search term + [\#3435](https://github.com/matrix-org/matrix-react-sdk/pull/3435) + * Dont wrap text in room directory buttons + [\#3434](https://github.com/matrix-org/matrix-react-sdk/pull/3434) + Changes in [1.5.2](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v1.5.2) (2019-09-12) =================================================================================================== [Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v1.5.2-rc.1...v1.5.2) diff --git a/package.json b/package.json index 93e9f4ecc7..1ad85e034a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matrix-react-sdk", - "version": "1.5.2", + "version": "1.5.3", "description": "SDK for matrix.org using React", "author": "matrix.org", "repository": { @@ -84,7 +84,7 @@ "linkifyjs": "^2.1.6", "lodash": "^4.17.14", "lolex": "2.3.2", - "matrix-js-sdk": "2.3.1", + "matrix-js-sdk": "2.3.2", "optimist": "^0.6.1", "pako": "^1.0.5", "png-chunks-extract": "^1.0.0", diff --git a/res/css/structures/_RoomDirectory.scss b/res/css/structures/_RoomDirectory.scss index 6b7a4ff0c7..4b49332af7 100644 --- a/res/css/structures/_RoomDirectory.scss +++ b/res/css/structures/_RoomDirectory.scss @@ -107,6 +107,7 @@ limitations under the License. .mx_RoomDirectory_join, .mx_RoomDirectory_preview { width: 80px; text-align: center; + white-space: nowrap; } .mx_RoomDirectory_name { diff --git a/src/components/structures/RoomDirectory.js b/src/components/structures/RoomDirectory.js index 19db128ba3..332ea5e731 100644 --- a/src/components/structures/RoomDirectory.js +++ b/src/components/structures/RoomDirectory.js @@ -369,32 +369,29 @@ module.exports = React.createClass({ } }, - onPreviewClick: function(room) { + onPreviewClick: function(ev, room) { this.props.onFinished(); dis.dispatch({ action: 'view_room', room_id: room.room_id, should_peek: true, }); + ev.stopPropagation(); }, - onViewClick: function(room) { + onViewClick: function(ev, room) { this.props.onFinished(); dis.dispatch({ action: 'view_room', room_id: room.room_id, should_peek: false, }); + ev.stopPropagation(); }, - onJoinClick: function(room) { - this.props.onFinished(); - MatrixClientPeg.get().joinRoom(room.room_id); - dis.dispatch({ - action: 'view_room', - room_id: room.room_id, - joining: true, - }); + onJoinClick: function(ev, room) { + this.showRoom(room, null, true); + ev.stopPropagation(); }, onCreateRoomClick: function(room) { @@ -458,16 +455,16 @@ module.exports = React.createClass({ if (room.world_readable && !hasJoinedRoom) { previewButton = ( - this.onPreviewClick(room)}>{_t("Preview")} + this.onPreviewClick(ev, room)}>{_t("Preview")} ); } if (hasJoinedRoom) { joinOrViewButton = ( - this.onViewClick(room)}>{_t("View")} + this.onViewClick(ev, room)}>{_t("View")} ); } else if (!isGuest || room.guest_can_join) { joinOrViewButton = ( - this.onJoinClick(room)}>{_t("Join")} + this.onJoinClick(ev, room)}>{_t("Join")} ); } @@ -487,7 +484,7 @@ module.exports = React.createClass({ ); return ( this.onRoomClicked(room)} + onClick={(ev) => this.onRoomClicked(room, ev)} // cancel onMouseDown otherwise shift-clicking highlights text onMouseDown={(ev) => {ev.preventDefault();}} > diff --git a/src/components/structures/SearchBox.js b/src/components/structures/SearchBox.js index 007ac88db2..74dadbf2c4 100644 --- a/src/components/structures/SearchBox.js +++ b/src/components/structures/SearchBox.js @@ -125,7 +125,7 @@ module.exports = React.createClass({ if (this.props.collapsed) { return null; } - const clearButton = !this.state.blurred ? + const clearButton = (!this.state.blurred || this.state.searchTerm) ? ( {this._clearSearch("button"); } }> diff --git a/src/components/views/context_menus/MessageContextMenu.js b/src/components/views/context_menus/MessageContextMenu.js index 04bc7c75ef..4b7b1f8545 100644 --- a/src/components/views/context_menus/MessageContextMenu.js +++ b/src/components/views/context_menus/MessageContextMenu.js @@ -1,6 +1,7 @@ /* Copyright 2015, 2016 OpenMarket Ltd Copyright 2018 New Vector Ltd +Copyright 2019 Michael Telatynski <7t3chguy@gmail.com> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -116,6 +117,14 @@ module.exports = React.createClass({ this.closeMenu(); }, + onReportEventClick: function() { + const ReportEventDialog = sdk.getComponent("dialogs.ReportEventDialog"); + Modal.createTrackedDialog('Report Event', '', ReportEventDialog, { + mxEvent: this.props.mxEvent, + }, 'mx_Dialog_reportEvent'); + this.closeMenu(); + }, + onViewSourceClick: function() { const ViewSource = sdk.getComponent('structures.ViewSource'); Modal.createTrackedDialog('View Event Source', '', ViewSource, { @@ -278,6 +287,8 @@ module.exports = React.createClass({ }, render: function() { + const cli = MatrixClientPeg.get(); + const me = cli.getUserId(); const mxEvent = this.props.mxEvent; const eventStatus = mxEvent.status; const editStatus = mxEvent.replacingEvent() && mxEvent.replacingEvent().status; @@ -445,6 +456,15 @@ module.exports = React.createClass({ ; } + let reportEventButton; + if (mxEvent.getSender() !== me) { + reportEventButton = ( +
+ { _t('Report Content') } +
+ ); + } + return (
{ resendButton } @@ -463,6 +483,7 @@ module.exports = React.createClass({ { externalURLButton } { collapseReplyThread } { e2eInfo } + { reportEventButton }
); }, diff --git a/src/components/views/dialogs/ReportEventDialog.js b/src/components/views/dialogs/ReportEventDialog.js new file mode 100644 index 0000000000..394e5ad47d --- /dev/null +++ b/src/components/views/dialogs/ReportEventDialog.js @@ -0,0 +1,137 @@ +/* +Copyright 2019 Michael Telatynski <7t3chguy@gmail.com> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import React, {PureComponent} from 'react'; +import sdk from '../../../index'; +import { _t } from '../../../languageHandler'; +import PropTypes from "prop-types"; +import {MatrixEvent} from "matrix-js-sdk"; +import MatrixClientPeg from "../../../MatrixClientPeg"; + +/* + * A dialog for reporting an event. + */ +export default class ReportEventDialog extends PureComponent { + static propTypes = { + mxEvent: PropTypes.instanceOf(MatrixEvent).isRequired, + onFinished: PropTypes.func.isRequired, + }; + + constructor(props, context) { + super(props, context); + + this.state = { + reason: "", + busy: false, + err: null, + }; + } + + _onReasonChange = ({target: {value: reason}}) => { + this.setState({ reason }); + }; + + _onCancel = () => { + this.props.onFinished(false); + }; + + _onSubmit = async () => { + if (!this.state.reason || !this.state.reason.trim()) { + this.setState({ + err: _t("Please fill why you're reporting."), + }); + return; + } + + this.setState({ + busy: true, + err: null, + }); + + try { + const ev = this.props.mxEvent; + await MatrixClientPeg.get().reportEvent(ev.getRoomId(), ev.getId(), -100, this.state.reason.trim()); + this.props.onFinished(true); + } catch (e) { + this.setState({ + busy: false, + err: e.message, + }); + } + }; + + render() { + const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); + const DialogButtons = sdk.getComponent('views.elements.DialogButtons'); + const Loader = sdk.getComponent('elements.Spinner'); + const Field = sdk.getComponent('elements.Field'); + + let error = null; + if (this.state.err) { + error =
+ {this.state.err} +
; + } + + let progress = null; + if (this.state.busy) { + progress = ( +
+ +
+ ); + } + + return ( + +
+

+ { + _t("Reporting this message will send its unique 'event ID' to the administrator of " + + "your homeserver. If messages in this room are encrypted, your homeserver " + + "administrator will not be able to read the message text or view any files or images.") + } +

+ + + {progress} + {error} +
+ +
+ ); + } +} diff --git a/src/components/views/rooms/MemberInfo.js b/src/components/views/rooms/MemberInfo.js index 867e50ba0d..914e2df3d0 100644 --- a/src/components/views/rooms/MemberInfo.js +++ b/src/components/views/rooms/MemberInfo.js @@ -636,8 +636,20 @@ module.exports = withMatrixClient(React.createClass({ }, _calculateOpsPermissions: async function(member) { + let canDeactivate = false; + if (this.context.matrixClient) { + try { + canDeactivate = await this.context.matrixClient.isSynapseAdministrator(); + } catch (e) { + console.error(e); + } + } + const defaultPerms = { - can: {}, + can: { + // Calculate permissions for Synapse before doing the PL checks + synapseDeactivate: canDeactivate, + }, muted: false, }; const room = this.props.matrixClient.getRoom(member.roomId); @@ -651,9 +663,10 @@ module.exports = withMatrixClient(React.createClass({ const them = member; return { - can: await this._calculateCanPermissions( - me, them, powerLevels.getContent(), - ), + can: { + ...defaultPerms.can, + ...await this._calculateCanPermissions(me, them, powerLevels.getContent()), + }, muted: this._isMuted(them, powerLevels.getContent()), isTargetMod: them.powerLevel > powerLevels.getContent().users_default, }; @@ -670,9 +683,6 @@ module.exports = withMatrixClient(React.createClass({ redactMessages: false, }; - // Calculate permissions for Synapse before doing the PL checks - can.synapseDeactivate = await this.context.matrixClient.isSynapseAdministrator(); - const canAffectUser = them.powerLevel < me.powerLevel || isMe; if (!canAffectUser) { //console.log("Cannot affect user: %s >= %s", them.powerLevel, me.powerLevel); diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 90edd32660..dcd4f1fdcb 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1225,6 +1225,10 @@ "To help avoid duplicate issues, please view existing issues first (and add a +1) or create a new issue if you can't find it.": "To help avoid duplicate issues, please view existing issues first (and add a +1) or create a new issue if you can't find it.", "Report bugs & give feedback": "Report bugs & give feedback", "Go back": "Go back", + "Please fill why you're reporting.": "Please fill why you're reporting.", + "Report Content to Your Homeserver Administrator": "Report Content to Your Homeserver Administrator", + "Reporting this message will send its unique 'event ID' to the administrator of your homeserver. If messages in this room are encrypted, your homeserver administrator will not be able to read the message text or view any files or images.": "Reporting this message will send its unique 'event ID' to the administrator of your homeserver. If messages in this room are encrypted, your homeserver administrator will not be able to read the message text or view any files or images.", + "Send report": "Send report", "Room Settings - %(roomName)s": "Room Settings - %(roomName)s", "Failed to upgrade room": "Failed to upgrade room", "The room upgrade could not be completed": "The room upgrade could not be completed", @@ -1347,6 +1351,7 @@ "Source URL": "Source URL", "Collapse Reply Thread": "Collapse Reply Thread", "End-to-end encryption information": "End-to-end encryption information", + "Report Content": "Report Content", "Failed to set Direct Message status of room": "Failed to set Direct Message status of room", "unknown error code": "unknown error code", "Failed to forget room %(errCode)s": "Failed to forget room %(errCode)s", diff --git a/yarn.lock b/yarn.lock index b8abf285f8..19782941f2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4958,10 +4958,10 @@ mathml-tag-names@^2.0.1: resolved "https://registry.yarnpkg.com/mathml-tag-names/-/mathml-tag-names-2.1.1.tgz#6dff66c99d55ecf739ca53c492e626f1d12a33cc" integrity sha512-pWB896KPGSGkp1XtyzRBftpTzwSOL0Gfk0wLvxt4f2mgzjY19o0LxJ3U25vNWTzsh7da+KTbuXQoQ3lOJZ8WHw== -matrix-js-sdk@2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/matrix-js-sdk/-/matrix-js-sdk-2.3.1.tgz#c0ebe90d43611cf28422317ec0c04f5d41acb2ad" - integrity sha512-lf2pGHp0o4bDVrSZ5ReLAkMMiX9PngGMxNAtzztdDvQ20lfYZvhwif9PUbi3tt8kwXlfs7s34eWxz5Rg37mdGg== +matrix-js-sdk@2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/matrix-js-sdk/-/matrix-js-sdk-2.3.2.tgz#341491e8396edbfe93cd034bce34acc6841af322" + integrity sha512-sWSqIvB0qEQgl3hPXLvhL0QPyH8161i37266yb6IAkprsJj4n0V/fiwzPd6Oft3Rv8ti4hBqsLN93dzYDPcupA== dependencies: another-json "^0.2.0" babel-runtime "^6.26.0"