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

Accurately reflect pairing status on cached levels #44462

Merged
merged 5 commits into from
Jan 26, 2022

Conversation

jamescodeorg
Copy link
Contributor

@jamescodeorg jamescodeorg commented Jan 21, 2022

This change reworks and extends the changes in PR #43716 so that the user menu on the levels page for cached levels is populated from the existing /api/user_menu endpoint. This fixes the issue where cached levels did not properly show pairing status.

This is intended to be a short-term fix to support this scenario and will be revisited when we separate pegasus from dashboard. This fix is not an ideal long-term fix because of the following:

  • The /api/user_menu endpoint returns a rendered user_menu in html. Ideally, we would probably have an api return the data needed, put that data in redux and have react components that connected to that data. This would require rewriting the existing haml-based rendering of the user menu to react. There are also some additional complexities related to how this code is shared between pegasus and dashboard which will hopefully be clarified as we separate pegasus and dashboard.
  • The /api/user_menu endpoint currently returns both the create menu and the sign-in button / user menu. At the point where we call the api, we don't have the level information needed to determine whether the create menu should be shown. As a hacky-ish workaround, we plumb through a flag that allows this code path to maintain the current state of the create menu. A better solution would be to separate the create menu from the sign-in button / user menu but that was a bit more complicated, again due to how pegasus and dashboard share code here.
Screen.Recording.2022-01-24.at.7.06.21.PM.mov

Links

Testing story

Deployment strategy

Follow-up work

Privacy

Security

Caching

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@jamescodeorg jamescodeorg force-pushed the jamescodeorg/cached-level-pairing branch 2 times, most recently from aa4d416 to e5a9bfb Compare January 22, 2022 17:50
@jamescodeorg jamescodeorg force-pushed the jamescodeorg/cached-level-pairing branch 2 times, most recently from e6348eb to 50ec929 Compare January 25, 2022 07:29
@jamescodeorg jamescodeorg requested a review from a team January 25, 2022 17:25
@jamescodeorg jamescodeorg force-pushed the jamescodeorg/cached-level-pairing branch from 50ec929 to 56e2081 Compare January 25, 2022 17:27
Copy link
Contributor

@maureensturgeon maureensturgeon 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 video in the description! I just have a couple small comments/questions

local_assigns[:level] :
false
# Determine if we want to show the create menu
if local_assigns[:show_create_menu]
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need to check defined? here? (defined?(local_assigns))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My understanding is that local_assigns is a method (https://apidock.com/rails/v5.0.0.1/ActionView/Template/local_assigns) so we don't need to check if it's defined? (I think the original code wasn't checking what it looked like it was checking for.)

# We want to show the Create button for all pages except when working on a
# course level. Specifically, for any page except non-project levels.
should_show_create_menu = !level || level.try(:is_project_level)
level = defined?(local_assigns) ?
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need to keep this? Is level used anywhere?

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, I don't need this anymore, nice catch!

-# by the client.
- if @public_caching
:javascript
dashboard.header.buildUserMenu()
Copy link
Contributor

Choose a reason for hiding this comment

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

I forget, is this also called in pegasus? For pegasus cached pages is the pairing status right?

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, this is dashboard only. The pairing status for pegasus may still be wrong. (The main goal of this fix was to fix this issue for the levels and script overview pages, but it does fix it for all of dashboard.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants