Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor watchers functionality #610

Merged
merged 10 commits into from
Dec 28, 2016
Merged

Conversation

anru
Copy link
Contributor

@anru anru commented Dec 24, 2016

this PR doesn't add or remove functionality, just refactoring.

  • get rid of store creator approach for watchers and related to watchers components
  • rewrite WatherTypeahead component into 2 new: UsersTypeahead and AdminsTypeahead, second one is independent container which connect "searching admins" functionality to dumb UsersTypeahead component
  • ShareSearch component now reuse AdminsTypeahead and don't do stupid copy-paste only because WatcherTypeahead was too complicated logic in connecting state to component level
  • there is no more necessity to make "watchers" reducer/actions via makeWatchers function for every entity in the system

@anru anru added the WIP label Dec 24, 2016
@anru anru self-assigned this Dec 24, 2016
@anru anru force-pushed the ashes/get-rid-of-store-creator branch from 9fa6d01 to 6c092fc Compare December 25, 2016 14:32
@anru anru changed the title Get rid of store creator Refactor watchers functionality Dec 27, 2016
@anru anru requested a review from tonypizzicato December 27, 2016 19:08
@anru
Copy link
Contributor Author

anru commented Dec 27, 2016

To reviewers: you don't have to review all changes here. You can just test final functionality for example. But if you want .. you are welcome 😈

@anru anru added the WIP label Dec 27, 2016
@anru anru removed the WIP label Dec 27, 2016
Copy link
Contributor

@tonypizzicato tonypizzicato 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, except excluding users from suggestions list that are already added in select-users component

}

get isParticipantsLoading(): boolean {
return _.get(this.props.asyncActions, 'fetchParticipants.inProgress', false);
Copy link
Contributor

Choose a reason for hiding this comment

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

extract to mapStateToProps?

};

renderCell(user, hidden = false) {
const { props } = this;
Copy link
Contributor

Choose a reason for hiding this comment

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

not needed here as just on props usage below


get usersRow() {
const { props } = this;
const users = this.props.participants;
Copy link
Contributor

Choose a reason for hiding this comment

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

this.props not needed as destructured above ^

};

get usersRow() {
const { props } = this;
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe better destructure to single values?
const { participants , emptyTitle, maxDisplayed, ... } = this.props;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. It's not better. Also I found this approach a little bit ugly and non informative.
It's better then you have clear context where are from this variable or that. It's first point.
Second point is, actually, when you have a lot of variables you have more letters than you might have.


@autobind
handleAddClick() {
const { props } = this;
Copy link
Contributor

Choose a reason for hiding this comment

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

same

}

get usersBlock() {
const { props } = this;
Copy link
Contributor

Choose a reason for hiding this comment

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

not used


const entityTitle = numberize(entity.entityType, 1);
switch (group) {
case 'watchers':
Copy link
Contributor

Choose a reason for hiding this comment

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

i think it's better to extract constants somewhere in paragon or smth

className="fc-add-watcher-modal"
>
<div className="fc-modal-body fc-add-watcher-modal__content">
<AdminsTypeahead
Copy link
Contributor

Choose a reason for hiding this comment

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

why does SelectUsersModal uses AdminsTypeahead?
is it used to work with admin users only? if so, would be better to rename to SelectAdminsModal

@@ -12,11 +12,19 @@ import ContentBox from '../content-box/content-box';

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -0,0 +1,8 @@

type UserType = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Type is used to prevent name collisions?
what if start using T prefix?
lile TUser

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like it

@anru
Copy link
Contributor Author

anru commented Dec 28, 2016

@tonypizzicato I fixed regression

@tonypizzicato
Copy link
Contributor

LGTM!

@tonypizzicato tonypizzicato merged commit ec963b9 into master Dec 28, 2016
@tonypizzicato tonypizzicato deleted the ashes/get-rid-of-store-creator branch December 28, 2016 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants