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

Migrate view_image.jsx to be follow the guidline #204

Merged
merged 13 commits into from
Nov 7, 2017

Conversation

cometkim
Copy link
Collaborator

Summary

Migrate view_image.jsx to be follow the guidline.

Ticket Link

mattermost/mattermost#7684

Checklist

  • Added or updated unit tests
  • Has UI changes

@jasonblais jasonblais added the 2: Dev Review Requires review by a core commiter label Oct 25, 2017
@@ -114,7 +141,7 @@ export default class ViewImageModal extends React.Component {
showImage(id) {
this.setState({imageIndex: id});
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 remove function binding above (e.g. this.showImage = this.showImage.bind(this);) and then change corresponding function to e.g. showImage = (id) => { ... } ?

@@ -1,31 +1,58 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import $ from 'jquery';

Copy link
Member

Choose a reason for hiding this comment

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

Nice to see this!

fileInfos: PropTypes.arrayOf(PropTypes.object).isRequired,
startIndex: PropTypes.number
};

function LoadingImagePreview({progress, loading}) {
Copy link
Member

Choose a reason for hiding this comment

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

I suggest the following to be on a separate file as a separate pure component with corresponding component tests:

  • LoadingImagePreview to loading_image_preview.jsx
  • ImagePreview to image_preview.jsx

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@saturninoabril Separating component files is a good idea. They don't have a state, so can I leave it in a stateless-functional style, not a pure component?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it'd be fine as stateless functional component.


expect(wrapper).toMatchSnapshot();
});
});
Copy link
Member

Choose a reason for hiding this comment

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

Test for ViewImageModal is a bit low. You may find related samples at tests/components. I'd suggest to at least cover the following:

  • handleNext
  • handlePrev
  • handleKeyPress
  • onModalShown
  • onModalHidden
  • componentWillReceiveProps
  • showImage
  • loadImage
  • handleImageLoaded
  • handleImageProgress
  • handleGetPublicLink
  • onMouseEnterImage
  • onMouseLeaveImage

screen shot 2017-10-26 at 11 05 40 am

screen shot 2017-10-26 at 11 11 54 am

Copy link
Member

@jwilander jwilander left a comment

Choose a reason for hiding this comment

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

Looks good, other than Saturn's comments

@cometkim
Copy link
Collaborator Author

Thank you @saturninoabril @jwilander for your review!

I will take a look for it soon 😄

@@ -198,7 +211,6 @@ export default class ViewImageModal extends React.Component {
content = (
<ImagePreview
fileInfo={fileInfo}
fileUrl={fileUrl}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hey @saturninoabril @jwilander.

I just moved this line into child component which I separated. Should I do this same for all other preview components, or restore?

Copy link
Member

Choose a reason for hiding this comment

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

No need. If necessary, separate ticket will be created for it.

@cometkim cometkim changed the title Migrate view_image.jsx to be follow the guidline WIP: Migrate view_image.jsx to be follow the guidline Oct 29, 2017
@saturninoabril
Copy link
Member

@cometkim You have failing test, at least in make check-style:
screen shot 2017-10-30 at 10 53 26 pm

@cometkim
Copy link
Collaborator Author

cometkim commented Nov 2, 2017

I don't know why modal component of react-bootstrap makes errors on enzyme rendering...

@saturninoabril
Copy link
Member

@cometkim I'll take a look at this today.

@saturninoabril
Copy link
Member

saturninoabril commented Nov 6, 2017

@cometkim I have pushed one on this commit, adding/fixing tests.

@saturninoabril saturninoabril added the 4: Reviews Complete All reviewers have approved the pull request label Nov 6, 2017
@saturninoabril saturninoabril removed the 2: Dev Review Requires review by a core commiter label Nov 6, 2017
@jasonblais jasonblais changed the title WIP: Migrate view_image.jsx to be follow the guidline Migrate view_image.jsx to be follow the guidline Nov 6, 2017
@cometkim
Copy link
Collaborator Author

cometkim commented Nov 6, 2017

Amazing!! Thank you @saturninoabril
I'm not used to writing tests with enzyme yet. So much learned from your code. 😍

(BTW, I want to see how tests work, but the github is too slow to my internet now)

Copy link
Member

@jwilander jwilander left a comment

Choose a reason for hiding this comment

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

Changes LGTM

@jwilander jwilander added this to the v4.5.0 milestone Nov 6, 2017
@jwilander
Copy link
Member

Nice work on this @cometkim! I'll merge after the 4.4 release branch gets cut

@jwilander jwilander merged commit d05d6f4 into mattermost:master Nov 7, 2017
@lindalumitchell lindalumitchell added the Tests/Not Needed Does not require new release tests label Nov 15, 2017
@jasonblais jasonblais added Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation labels Jan 4, 2018
hmhealey pushed a commit that referenced this pull request Aug 28, 2020
* Add reducers, actions and client functions for user access tokens

* Add utils functions for new roles

* Update role checking utility to prevent false positives

* Add admin reducers for user access tokens

* Add action to clear user access tokens

* Add tracking to access token client functions

* Fix ESLint error

* Updates per feedback
hmhealey pushed a commit that referenced this pull request Mar 17, 2021
* Add reducers, actions and client functions for user access tokens

* Add utils functions for new roles

* Update role checking utility to prevent false positives

* Add admin reducers for user access tokens

* Add action to clear user access tokens

* Add tracking to access token client functions

* Fix ESLint error

* Updates per feedback
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
4: Reviews Complete All reviewers have approved the pull request Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation Hacktoberfest Tests/Not Needed Does not require new release tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants