From e3f2eb5232f1195248ed6d0da0cda536d5f8c360 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 4 Jul 2017 14:44:55 +0100 Subject: [PATCH 1/3] =?UTF-8?q?Take=20RTE=20out=20of=20labs!=20?= =?UTF-8?q?=F0=9F=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This stops react-sdk from tracking any state previously stored for the purposes of enabling or disabling the lab feature that enabled the new MessageComposer. It is now enabled permanently. This is being done with the hope that we can get more feedback for it so that when we release we can be confident that people will be OK with the changes it brings. --- src/UserSettingsStore.js | 11 ++--- src/components/views/rooms/MessageComposer.js | 48 +++++++------------ .../views/rooms/MessageComposerInput-test.js | 4 -- 3 files changed, 20 insertions(+), 43 deletions(-) diff --git a/src/UserSettingsStore.js b/src/UserSettingsStore.js index 009fdabb53..bbc436a1f6 100644 --- a/src/UserSettingsStore.js +++ b/src/UserSettingsStore.js @@ -27,11 +27,7 @@ export default { LABS_FEATURES: [ { name: "-", - id: 'rich_text_editor', - default: false, - }, - { - name: "-", + _tName: "Matrix Apps", // Translated! id: 'matrix_apps', default: false, }, @@ -39,8 +35,9 @@ export default { // horrible but it works. The locality makes this somewhat more palatable. doTranslations: function() { - this.LABS_FEATURES[0].name = _t("New Composer & Autocomplete"); - this.LABS_FEATURES[1].name = _t("Matrix Apps"); + this.LABS_FEATURES.forEach((f) => { + f.name = _t(f._tName); + }); }, loadProfileInfo: function() { diff --git a/src/components/views/rooms/MessageComposer.js b/src/components/views/rooms/MessageComposer.js index c83e32d9a8..7ca08a5a05 100644 --- a/src/components/views/rooms/MessageComposer.js +++ b/src/components/views/rooms/MessageComposer.js @@ -268,8 +268,7 @@ export default class MessageComposer extends React.Component { const uploadInputStyle = {display: 'none'}; const MemberAvatar = sdk.getComponent('avatars.MemberAvatar'); const TintableSvg = sdk.getComponent("elements.TintableSvg"); - const MessageComposerInput = sdk.getComponent("rooms.MessageComposerInput" + - (UserSettingsStore.isFeatureEnabled('rich_text_editor') ? "" : "Old")); + const MessageComposerInput = sdk.getComponent("rooms.MessageComposerInput"); const controls = []; @@ -352,8 +351,7 @@ export default class MessageComposer extends React.Component { title={_t("Show Text Formatting Toolbar")} src="img/button-text-formatting.svg" onClick={this.onToggleFormattingClicked} - style={{visibility: this.state.showFormatting || - !UserSettingsStore.isFeatureEnabled('rich_text_editor') ? 'hidden' : 'visible'}} + style={{visibility: this.state.showFormatting ? 'hidden' : 'visible'}} key="controls_formatting" /> ); @@ -390,18 +388,6 @@ export default class MessageComposer extends React.Component { ); } - let autoComplete; - if (UserSettingsStore.isFeatureEnabled('rich_text_editor')) { - autoComplete =
- -
; - } - - const {style, blockType} = this.state.inputState; const formatButtons = ["bold", "italic", "strike", "underline", "code", "quote", "bullet", "numbullet"].map( (name) => { @@ -429,22 +415,20 @@ export default class MessageComposer extends React.Component { {controls} - {UserSettingsStore.isFeatureEnabled('rich_text_editor') ? -
-
- {formatButtons} -
- - -
-
: null - } +
+
+ {formatButtons} +
+ + +
+
); } diff --git a/test/components/views/rooms/MessageComposerInput-test.js b/test/components/views/rooms/MessageComposerInput-test.js index 80fd158608..6d4b4e69cc 100644 --- a/test/components/views/rooms/MessageComposerInput-test.js +++ b/test/components/views/rooms/MessageComposerInput-test.js @@ -27,14 +27,10 @@ describe('MessageComposerInput', () => { mci = null, room = testUtils.mkStubRoom('!DdJkzRliezrwpNebLk:matrix.org'); - // TODO Remove when RTE is out of labs. - beforeEach(function() { testUtils.beforeEach(this); sandbox = testUtils.stubClient(sandbox); client = MatrixClientPeg.get(); - UserSettingsStore.isFeatureEnabled = sinon.stub() - .withArgs('rich_text_editor').returns(true); parentDiv = document.createElement('div'); document.body.appendChild(parentDiv); From e6ec5742bee6416ab35c2b7469de0840303733f9 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 4 Jul 2017 15:06:24 +0100 Subject: [PATCH 2/3] _t should be used on string literals For scripts to easily find translations --- src/UserSettingsStore.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/UserSettingsStore.js b/src/UserSettingsStore.js index bbc436a1f6..fef84468ec 100644 --- a/src/UserSettingsStore.js +++ b/src/UserSettingsStore.js @@ -27,7 +27,6 @@ export default { LABS_FEATURES: [ { name: "-", - _tName: "Matrix Apps", // Translated! id: 'matrix_apps', default: false, }, @@ -35,9 +34,7 @@ export default { // horrible but it works. The locality makes this somewhat more palatable. doTranslations: function() { - this.LABS_FEATURES.forEach((f) => { - f.name = _t(f._tName); - }); + this.LABS_FEATURES[0].name = _t("Matrix Apps"); }, loadProfileInfo: function() { From 77348e6201edaa5b4302ce150e0be008d0908566 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 4 Jul 2017 15:20:00 +0100 Subject: [PATCH 3/3] Remove spurious, unused code --- src/components/views/rooms/MessageComposer.js | 18 ------------------ .../views/rooms/MessageComposerInput.js | 7 ------- 2 files changed, 25 deletions(-) diff --git a/src/components/views/rooms/MessageComposer.js b/src/components/views/rooms/MessageComposer.js index 7ca08a5a05..69ccc3d2f8 100644 --- a/src/components/views/rooms/MessageComposer.js +++ b/src/components/views/rooms/MessageComposer.js @@ -227,21 +227,6 @@ export default class MessageComposer extends React.Component { this.setState({inputState}); } - onUpArrow() { - return this.refs.autocomplete.onUpArrow(); - } - - onDownArrow() { - return this.refs.autocomplete.onDownArrow(); - } - - _tryComplete(): boolean { - if (this.refs.autocomplete) { - return this.refs.autocomplete.onCompletionClicked(); - } - return false; - } - _onAutocompleteConfirm(range, completion) { if (this.messageComposerInput) { this.messageComposerInput.setDisplayedCompletion(range, completion); @@ -366,10 +351,7 @@ export default class MessageComposer extends React.Component { room={this.props.room} placeholder={placeholderText} tryComplete={this._tryComplete} - onUpArrow={this.onUpArrow} - onDownArrow={this.onDownArrow} onFilesPasted={this.uploadFiles} - tabComplete={this.props.tabComplete} // used for old messagecomposerinput/tabcomplete onContentChanged={this.onInputContentChanged} onInputStateChanged={this.onInputStateChanged} />, formattingButton, diff --git a/src/components/views/rooms/MessageComposerInput.js b/src/components/views/rooms/MessageComposerInput.js index 818c108211..27fd6d4190 100644 --- a/src/components/views/rooms/MessageComposerInput.js +++ b/src/components/views/rooms/MessageComposerInput.js @@ -887,14 +887,7 @@ MessageComposerInput.propTypes = { // called with current plaintext content (as a string) whenever it changes onContentChanged: React.PropTypes.func, - onUpArrow: React.PropTypes.func, - - onDownArrow: React.PropTypes.func, - onFilesPasted: React.PropTypes.func, - // attempts to confirm currently selected completion, returns whether actually confirmed - tryComplete: React.PropTypes.func, - onInputStateChanged: React.PropTypes.func, };