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

fix: display programs only if the url is configured #479

Merged
merged 3 commits into from
Nov 18, 2024

Conversation

dcoa
Copy link
Contributor

@dcoa dcoa commented Oct 18, 2024

Description

This PR removes the link of programs from the Header if the service is not configured.

It aims to solve the following issue #372

How to test

  1. Create a instance with frontend-app-learner-dashobord mounted in the current branch.
  2. Launch the instance and open it in the browser.
  3. Access the learner dashboard.
  4. By default you should not see help nav button.
  5. Configure programs service following the instructions here https://github.com/overhangio/tutor-discovery.
  6. Now the tab should be available.

@dcoa dcoa requested a review from a team as a code owner October 18, 2024 13:39
@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Oct 18, 2024
@openedx-webhooks
Copy link

Thanks for the pull request, @dcoa!

What's next?

Please work through the following steps to get your changes ready for engineering review:

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.

🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads

🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

🔘 Let us know that your PR is ready for review:

Who will review my changes?

This repository is currently maintained by @2U-aperture. Tag them in a comment and let them know that your changes are ready for review.

Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

Copy link

codecov bot commented Oct 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.43%. Comparing base (bf2bc40) to head (a9cca14).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #479      +/-   ##
==========================================
+ Coverage   97.40%   97.43%   +0.02%     
==========================================
  Files         157      157              
  Lines        1387     1403      +16     
  Branches      230      232       +2     
==========================================
+ Hits         1351     1367      +16     
  Misses         34       34              
  Partials        2        2              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dcoa dcoa force-pushed the dcoa/fix-programs-tab branch from 46e2e9a to b5014b2 Compare October 18, 2024 21:46
@arbrandes arbrandes self-requested a review October 21, 2024 14:57
Copy link
Contributor

@arbrandes arbrandes left a comment

Choose a reason for hiding this comment

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

I reviewed the code and I think the approach makes total sense. It hits a generic django-config-models table that is automatically cached, so it shouldn't be a performance problem.

I also tested it and it works perfectly. Congrats!

It would be better to pass the coverage CI tests, though, as noted in a review comment.

const fetchProgramsConfig = async () => {
try {
const { data } = await api.getProgramsConfig();
setConfig(data);
Copy link
Contributor

Choose a reason for hiding this comment

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

If you manage to get test coverage on this line (it shouldn't be too hard, maybe by mocking getProgramsConfig), we can fix the CI failure.

Copy link
Contributor

Choose a reason for hiding this comment

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

++ to getting this covered!

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems this line is still uncovered, @dcoa.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@arbrandes it is covered now :)

@arbrandes
Copy link
Contributor

@openedx/2u-aperture (@MaxFrank13, @jsnwesson), any objections to the approach, here? We'd love to get this in before the Sumac cutoff, tomorrow.

@jsnwesson
Copy link
Contributor

I can confirm that this PR still allows me to see "Programs" in my hosted devstack! @arbrandes I have no objections, as long as some test coverage can be added in the api.js file, as you mentioned.

Screenshot 2024-10-22 at 2 21 09 PM

@dcoa dcoa force-pushed the dcoa/fix-programs-tab branch from b5014b2 to bfbfe67 Compare October 24, 2024 08:07
@itsjeyd itsjeyd requested a review from arbrandes October 24, 2024 09:11
@dcoa
Copy link
Contributor Author

dcoa commented Oct 24, 2024

@arbrandes @jsnwesson , thank you for reviewing this PR, I covered the lines in the api hook file.

Copy link
Contributor

@arbrandes arbrandes left a comment

Choose a reason for hiding this comment

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

Still requires a couple of changes. Thanks, though!

const fetchProgramsConfig = async () => {
try {
const { data } = await api.getProgramsConfig();
setConfig(data);
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems this line is still uncovered, @dcoa.

src/hooks/api.js Outdated
const { data } = await api.getProgramsConfig();
setConfig(data);
} catch (error) {
console.error('Error accessing programs configuration', error);
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, I'm not a huge fan of leaving console() calls in production code. It would be better to remove it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, what would your thoughts be on using a log.Error from frontend-platform, since this error would be useful to capture for anyone with a logging service?

Copy link
Contributor Author

@dcoa dcoa Oct 29, 2024

Choose a reason for hiding this comment

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

@jsnwesson you are right I should use the logError from frontend-platoform 👍 Do you think like that is okay or just passing the error is enough?

Copy link
Contributor

Choose a reason for hiding this comment

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

@jsnwesson, yeah, log.Error is a much better way to handle it.

@dcoa dcoa force-pushed the dcoa/fix-programs-tab branch 2 times, most recently from 04856f5 to 11284e3 Compare October 31, 2024 08:30
@itsjeyd itsjeyd added core contributor PR author is a Core Contributor (who may or may not have write access to this repo). waiting for eng review PR is ready for review. Review and merge it, or suggest changes. labels Oct 31, 2024
@itsjeyd itsjeyd requested a review from arbrandes November 7, 2024 09:11
@dcoa dcoa force-pushed the dcoa/fix-programs-tab branch from 11284e3 to b3f02d8 Compare November 13, 2024 04:38
@dcoa
Copy link
Contributor Author

dcoa commented Nov 13, 2024

@arbrandes, do you thing there is any additional change here to be addressed?

@dcoa dcoa force-pushed the dcoa/fix-programs-tab branch from b3f02d8 to a9cca14 Compare November 18, 2024 05:17
Copy link
Contributor

@arbrandes arbrandes left a comment

Choose a reason for hiding this comment

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

Looks like we're good! Thanks, @dcoa!

@arbrandes arbrandes merged commit e8886c9 into openedx:master Nov 18, 2024
6 checks passed
@arbrandes
Copy link
Contributor

@dcoa, do you mind creating a backport of this to the sumac.master branch?

@deborahgu
Copy link
Member

@dcoa @arbrandes

I'm going to roll this back, it is broken in a live (ie. non-tutor, non-devstack) environment. The code determines if programs is active by baseAppUrl('/config/programs');. The URL is permissioned and is inaccessible under production circumstances. This will need another method. Possibilities: a URL that's reachable by any logged in user, or a server-side check, or looking to see if this is exposed via a standard config setting. (That last would be ideal.)

deborahgu added a commit that referenced this pull request Nov 18, 2024
deborahgu added a commit that referenced this pull request Nov 18, 2024
@itsjeyd itsjeyd removed the waiting for eng review PR is ready for review. Review and merge it, or suggest changes. label Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U
Projects
Status: Done
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants