Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

PLT-7238 Migration of create_post.jsx to redux #210

Merged
merged 58 commits into from
Dec 14, 2017

Conversation

sudheerDev
Copy link
Contributor

@sudheerDev sudheerDev commented Oct 27, 2017

Summary

WIP: Migration of create_post.jsx to redux

Ticket Link

mattermost/mattermost#7238

Checklist

  • Added or updated unit tests (required for all new features)
  • Has redux changes (please link)
  • Touches critical sections of the codebase (auth, posting, etc.)

@coreyhulen coreyhulen added 2: Dev Review Requires review by a core commiter Work in Progress Not yet ready for review labels Oct 27, 2017
@coreyhulen coreyhulen changed the title PLT 7238 PLT-7238 Migration of create_post.jsx to redux Oct 27, 2017
@sudheerDev sudheerDev force-pushed the PLT-7238 branch 6 times, most recently from b465460 to cc63407 Compare November 3, 2017 12:32

/**
* Data used in notifyiing user for @all and @channel
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just minor correction on spelling - "notifying"

this.showPostDeletedModal = this.showPostDeletedModal.bind(this);
this.hidePostDeletedModal = this.hidePostDeletedModal.bind(this);
this.showShortcuts = this.showShortcuts.bind(this);
this.handleEmojiClick = this.handleEmojiClick.bind(this);
this.handlePostError = this.handlePostError.bind(this);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better if these remaining bind functions are changed into its equivalent arrow functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes of course.

fullWidthTextBox: get(state, Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.CHANNEL_DISPLAY_MODE, Preferences.CHANNEL_DISPLAY_MODE_DEFAULT) === Preferences.CHANNEL_DISPLAY_MODE_FULL_SCREEN,
showTutorialTip: get(state, Preferences.TUTORIAL_STEP, getCurrentUserId(state), 999),
messageInHistoryItem: makeGetMessageInHistoryItem('post')(state)
};
Copy link
Member

@saturninoabril saturninoabril Nov 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same constant here.

@@ -796,7 +846,3 @@ export default class CreatePost extends React.Component {
);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add tests to CreatePost component?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was hoping to add test cases was out on a trip. Just catching up with things. I will add test cases first chance I get.

@@ -46,8 +45,6 @@ export default class CreateComment extends React.Component {
constructor(props) {
super(props);

this.lastTime = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for cleaning up!

@@ -415,35 +468,42 @@ export default class CreatePost extends React.Component {
}

componentWillMount() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggests to have these lifecycle methods to move at top location, just after the constructor and before other functions.

});
e.preventDefault();
if (e.keyCode === Constants.KeyCodes.UP) {
this.props.actions.moveHistoryIndexBack('post').then(() => this.fillMessageFromHistory());
Copy link
Member

@saturninoabril saturninoabril Nov 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better to use constant here:

import {Posts} from 'mattermost-redux/constants';
...
... moveHistoryIndexBack(Posts.MESSAGE_TYPES.POST)

if (e.keyCode === Constants.KeyCodes.UP) {
this.props.actions.moveHistoryIndexBack('post').then(() => this.fillMessageFromHistory());
} else {
this.props.actions.moveHistoryIndexForward('post').then(() => this.fillMessageFromHistory());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same constants here.

@@ -46,8 +45,6 @@ export default class CreateComment extends React.Component {
constructor(props) {
super(props);

this.lastTime = 0;

PostStore.clearCommentDraftUploads();
Copy link
Contributor Author

@sudheerDev sudheerDev Nov 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oo i could change this to use redux actions

@sudheerDev sudheerDev force-pushed the PLT-7238 branch 8 times, most recently from 726f8f8 to 1e6d361 Compare November 17, 2017 03:22
@jwilander
Copy link
Member

Hey @sudheerDev, just checking in on how this is going. Let us know if you need any help and when you're ready for review :)

@sudheerDev
Copy link
Contributor Author

@jwilander I need to make few changes and add test cases as well. I will have a look at it over the weekend and let you know if I need any help.

@jespino
Copy link
Member

jespino commented Nov 21, 2017

Hi, I have changed a thing in create_post.jsx to fix the arrow up to edit. the PR is #339.

@sudheerDev
Copy link
Contributor Author

@jespino Aah thanks. I came across this the other day and I thought I broke something.

@sudheerDev
Copy link
Contributor Author

@saturninoabril @jwilander Still working on this. Need to add some more test cases and will be done. While writing test i am finding things that could be fixed :).

@sudheerDev
Copy link
Contributor Author

This PR is a dependency for this PR.
And this PR is good to have so i can remove the dependency of postStore for the component.

@lindalumitchell
Copy link
Contributor

@jwilander @sudheerDev sorry for the delay on testing this; it looks good to me!

Did a bunch of testing, including having multiple tabs open. Tested posts, replies, editing, deleting, long messages, formatted messages, pinning, flagging, autocomplete for emoji, users, channel names, emoji reactions, mentions, DMs, permalinks, all in combinations between two users and in center and RHS. No issues found!

* Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**

* Fix Tests

* Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**

* Fix Tests

* Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**

* Fix Tests

* Finalized component tests

* Snapshot test
* verifyEmail function test
* Test mattermost-redux action & error display

* Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**
Fix Tests


Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**
Fix Tests


Finalized component tests

* Snapshot test
* verifyEmail function test
* Test mattermost-redux action & error display

* Code Review Fixes

* Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**

* Fix Tests

* Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**

* Fix Tests

* Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**

* Fix Tests

* Finalized component tests

* Snapshot test
* verifyEmail function test
* Test mattermost-redux action & error display

* Code Review Fixes

* WIP: Changes to testing

Work in Progress, last two tests returning errors.

* Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**
Fix Tests


Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**
Fix Tests


Finalized component tests

* Snapshot test
* verifyEmail function test
* Test mattermost-redux action & error display
Code Review Fixes


Fix Tests


Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**
Fix Tests


Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**
WIP: Changes to testing

Work in Progress, last two tests returning errors.
Fix Tests


Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**
Fix Tests


Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**
Fix Tests


Finalized component tests

* Snapshot test
* verifyEmail function test
* Test mattermost-redux action & error display
WIP: Changes to testing

Work in Progress, last two tests returning errors.
Code Review Fixes


Merge remote-tracking branch 'avasconcelos114/PLT-7784' into PLT-7784
Fixed test errors


Fix test name


Merge remote-tracking branch 'avasconcelos114/PLT-7784' into PLT-7784

* Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**
Fix Tests


Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**
Fix Tests


Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**
Fix Tests


Finalized component tests

* Snapshot test
* verifyEmail function test
* Test mattermost-redux action & error display
Code Review Fixes


Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**
Fix Tests


Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**
Fix Tests


Fix Tests


Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**
Fix Tests


Fix Tests


Finalized component tests

* Snapshot test
* verifyEmail function test
* Test mattermost-redux action & error display
Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**
WIP: Changes to testing

Work in Progress, last two tests returning errors.
Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**
Fix Tests


Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**
Fix Tests


Finalized component tests

* Snapshot test
* verifyEmail function test
* Test mattermost-redux action & error display
Code Review Fixes


Fix Tests


Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**
Fix Tests


Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**
WIP: Changes to testing

Work in Progress, last two tests returning errors.
Fix Tests


Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**
Fix Tests


Migrate do_verify_email to Redux

**Should wait until enzyme & react version issues are resolved**
Fix Tests


Finalized component tests

* Snapshot test
* verifyEmail function test
* Test mattermost-redux action & error display
WIP: Changes to testing

Work in Progress, last two tests returning errors.
Code Review Fixes


Merge remote-tracking branch 'avasconcelos114/PLT-7784' into PLT-7784
Fixed test errors


Fix test name


Merge remote-tracking branch 'avasconcelos114/PLT-7784' into PLT-7784
Remove useless Adapter import in test


Merge remote-tracking branch 'avasconcelos114/PLT-7784' into PLT-7784
Merge remote-tracking branch 'avasconcelos114/PLT-7784' into PLT-7784

* Fix merge issue
@saturninoabril
Copy link
Member

@sudheerDev Please give this a rebase and we're good to merge this. Thanks!

sudheer added 7 commits December 14, 2017 15:38
 Remove channelId and channel from state as it is avaialable via props.
 Remove Team store dependency.
 Remove User store dependency
 Remove Preferences store dependency.
  * Remove preferences from store as props change trigger render.
  * Add selector for preferences
 Move REACTION_PATTERN to utils.
 Remove message_history_store dependency.
 Add redux post actions instead of flux actions.
 Change bind functions to class prop arrow functions.
 Add proptype comments.
 Remove couple of unused variables.
* Remove all bind functions.
* Add MESSAGE_TYPES constants.
Remove few postStore dependent functions.
Add getCurrentUsersLatestPostId redux state selector.
Add Test cases for create_post
Remove uploadInprogress and filesInfo from state
Remove unused variable from file_preview which causes mutation on props.
Fix sort on filesInfo for file_preview component.
Fix draft constant
Remove postStore dependecy.
Add edit dispatch from redux.
Add test cases
Fix failing snapshots.
 Change currentChannelMembersCount default value to 1 as user is part of the channel.
@saturninoabril saturninoabril merged commit 8292b1c into mattermost:master Dec 14, 2017
saturninoabril added a commit that referenced this pull request Dec 14, 2017
@lindalumitchell lindalumitchell added the Tests/Done Release tests have been written label Dec 15, 2017
saturninoabril added a commit that referenced this pull request Dec 18, 2017
@hmhealey hmhealey removed the Setup Old Test Server Triggers the creation of a test server label Dec 22, 2017
@mattermod
Copy link
Contributor

Spinmint test server destroyed

@jasonblais jasonblais added Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation labels Jan 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1: PM Review Requires review by a product manager Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation Hacktoberfest Tests/Done Release tests have been written
Projects
None yet
Development

Successfully merging this pull request may close these issues.