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

Extend make visible in stats #2168

Merged
merged 25 commits into from
Oct 20, 2022
Merged

Extend make visible in stats #2168

merged 25 commits into from
Oct 20, 2022

Conversation

uzorjchibuzor
Copy link
Contributor

Closes #2142


Reviewing this pull request? Check out our Code Review Practices guide if you haven't already!

Copy link
Member

@julianguyen julianguyen left a comment

Choose a reason for hiding this comment

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

Thanks for taking this on! 🎉 Looking good so far!

@@ -10,6 +10,7 @@ import {
faDoorOpen,
faDoorClosed,
faExclamationTriangle,
faEyeSlash,
Copy link
Member

Choose a reason for hiding this comment

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

You'll want to update this part of the file to use this new icon.

Copy link
Contributor Author

@uzorjchibuzor uzorjchibuzor Oct 12, 2022

Choose a reason for hiding this comment

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

I was able to use the icon eventually. I repeated it everywhere the tooltip is displayed. What I did is to pass the visibility status as a prop key. I will post the diff here for reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is where the conditional rendering is effected.

@uzorjchibuzor
Copy link
Contributor Author

Is there a reason why the tests that are failing are not even remotely related to the things I did?

@uzorjchibuzor uzorjchibuzor removed the wip label Oct 12, 2022
@LMulvey
Copy link
Contributor

LMulvey commented Oct 12, 2022

Is there a reason why the tests that are failing are not even remotely related to the things I did?

@uzorjchibuzor You likely have conflicting local settings for things like ESLint and Prettier–I know I did. Navigate to ifme/client and run yarn lint locally and then commit those changes–that will sync everything up with what CI expects! 💪🏻

@uzorjchibuzor
Copy link
Contributor Author

Is there a reason why the tests that are failing are not even remotely related to the things I did?

@uzorjchibuzor You likely have conflicting local settings for things like ESLint and Prettier–I know I did. Navigate to ifme/client and run yarn lint locally and then commit those changes–that will sync everything up with what CI expects! 💪🏻

I wanted to install a VSCode extension before I tried your suggestion. Hope it works. My Linting is horrible.

@uzorjchibuzor
Copy link
Contributor Author

I think I passed ESLint, CircleCI is Capybara, Let me know if I need to fix anything.

Copy link
Member

@julianguyen julianguyen left a comment

Choose a reason for hiding this comment

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

Thanks so much for taking this on 🎉 Awesome work 🙌

app/helpers/categories_helper.rb Outdated Show resolved Hide resolved
app/helpers/moments_helper.rb Outdated Show resolved Hide resolved
app/helpers/viewers_helper.rb Show resolved Hide resolved
sible, not_visible) resolves to false, it will be removed from the returned hash
 so as not to cause a Type error in the StoryAction.jsx
Copy link
Member

@julianguyen julianguyen left a comment

Choose a reason for hiding this comment

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

This is coming along really well 🙌 🎉 Thanks for all the updates!

There's one edge case that we should address!

@@ -127,6 +127,6 @@ def associated_strategies
Strategy.where(user: @viewers).each do |strategy|
strategy_ids << strategy.id if strategy.viewer?(current_user)
end
Strategy.where(id: strategy_ids).order(created_at: :desc)
Strategy.is_visible.where(id: strategy_ids).order(created_at: :desc)
Copy link
Member

@julianguyen julianguyen Oct 15, 2022

Choose a reason for hiding this comment

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

An edge case that we should account for is what happens when we create a Moment with a Strategy/Category/Mood OR a Strategy with a Category that is visible when created, but is later edited to be not visible?

Example:

  1. Create a Moment with a Strategy that is visible

image

  1. Edit the Strategy and make it not visible

image

  1. View the Moment and the non-visible Strategy is still listed (this is fine!)

image

  1. Edit the Moment and the Strategy is not in the list (this is the issue!)

image


I think the expected behaviour for 4) should be that we can view the selected Strategy. If we uncheck the box for it and save our changes, then we can no longer add it back.

Copy link
Contributor Author

@uzorjchibuzor uzorjchibuzor Oct 15, 2022

Choose a reason for hiding this comment

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

Do you mean that if an element is tagged, it should remain visible to the parent?

Copy link
Member

Choose a reason for hiding this comment

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

I think if it's already tagged, but the tag is made not visible, it should still be visible to the post (or parent like you said) that it's being used in.

Copy link
Contributor Author

@uzorjchibuzor uzorjchibuzor Oct 15, 2022

Choose a reason for hiding this comment

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

I think I understand now. It's late here but I should have a commit tomorrow, I will have to do away with the scope Concern though.

Copy link
Member

@julianguyen julianguyen left a comment

Choose a reason for hiding this comment

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

Thanks for the updates and adding tests along the way! This is coming along great 🎉

@@ -142,6 +151,18 @@
end
end

it 'reders associated category in dropdown regardless of visibility status' do
Copy link
Member

Choose a reason for hiding this comment

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

Grammar: reders should be spelled as renders

@@ -109,9 +109,9 @@ def moment_params
end

def set_association_variables!
@categories = current_user.categories.order(created_at: :desc)
@categories = current_user.categories.is_visible.or(Category.where(id: @moment.category_ids)).order(created_at: :desc)
Copy link
Member

Choose a reason for hiding this comment

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

I found a bug:

  1. Create a Moment with a visible Category
  2. Edit the Category to be not visible
  3. Edit the Moment and uncheck the Category and hit "Submit"
  4. The Category is not removed (it should be removed)

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 think I understand but I want to recreate this to be sure,

Copy link
Member

Choose a reason for hiding this comment

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

The issue is that if we're editing a Moment or Strategy, we're overriding tags that are removed before they are saved.

@category = Category.new
@moods = current_user.moods.order(created_at: :desc)
@moods = current_user.moods.is_visible.or(Mood.where(id: @moment.mood_ids)).order(created_at: :desc)
Copy link
Member

Choose a reason for hiding this comment

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

Similar bug as above, but for Moods!

@@ -127,6 +127,6 @@ def associated_strategies
Strategy.where(user: @viewers).each do |strategy|
strategy_ids << strategy.id if strategy.viewer?(current_user)
end
Strategy.where(id: strategy_ids).order(created_at: :desc)
Strategy.is_visible.where(id: strategy_ids).or(Strategy.where(id: @moment.strategy_ids)).order(created_at: :desc)
Copy link
Member

Choose a reason for hiding this comment

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

Similar bug as above, but for Strategies!

@@ -52,7 +52,7 @@ def edit
redirect_to_path(strategy_path(@strategy))
end
@viewers = current_user.allies_by_status(:accepted)
@categories = current_user.categories.order('created_at DESC')
@categories = current_user.categories.is_visible.or(Category.where(id: @strategy.category_ids)).order('created_at DESC')
Copy link
Member

Choose a reason for hiding this comment

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

I found a bug:

  1. Create a Strategy with a visible Category
  2. Edit the Category to be not visible
  3. Edit the Strategy and uncheck the Category and hit "Submit"
  4. The Category is not removed (it should be removed)

Copy link
Contributor Author

@uzorjchibuzor uzorjchibuzor left a comment

Choose a reason for hiding this comment

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

the commit message is supposed to say Moment and Strategy is now able to remove associations when no params is passed to the controller by a before_save callback

…s is passed to the controller by a before_save callback
Copy link
Member

@julianguyen julianguyen left a comment

Choose a reason for hiding this comment

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

Fantastic work!! Thanks for all the updates as well 🎉

@julianguyen julianguyen merged commit a3e05a8 into main Oct 20, 2022
@delete-merged-branch delete-merged-branch bot deleted the extend_make_visible_in_stats branch October 20, 2022 23:56
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.

Extend "Make visible in stats?" toggle in Categories, Moods, and Strategies editor
3 participants