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

feat: publish single library component #1407

Merged

Conversation

DanielVZ96
Copy link
Contributor

@DanielVZ96 DanielVZ96 commented Oct 19, 2024

Description

Implements and enables the publish button functionality in the libraries v2 component sidebar.

Supporting information

Testing instructions

$ tutor dev run lms ./manage.py lms shell -c "from waffle.models import Flag; Flag.objects.update_or_create(name='contentstore.new_studio_mfe.disable_legacy_libraries', defaults={'everyone': False}); Flag.objects.update_or_create(name='contentstore.new_studio_mfe.disable_new_libraries', defaults={'everyone': False})"
  • Create a new library and two components inside it.
  • Click on one component and then click on Publish Component at the sidebar. Verify the button gets disabled.
  • In the Components tab, order by Recently Publish to verify that only the published component appears.
  • Click on the published component and Edit it. Verity that after saving it, the publish button is enabled again [THIS IS NOT WORKING BECAUSE THE EDITOR COMPONENT IS NOT INVALIDATING THE componentMetadata QUERY]

Deadline

ASAP

@openedx-webhooks
Copy link

openedx-webhooks commented Oct 19, 2024

Thanks for the pull request, @DanielVZ96!

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 @openedx/2u-tnl. 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.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Oct 19, 2024
@DanielVZ96 DanielVZ96 force-pushed the dvz/publish-single-component branch 2 times, most recently from 8f31a41 to 6140adb Compare October 21, 2024 11:13
Copy link

codecov bot commented Oct 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.12%. Comparing base (57e7baf) to head (f21b63f).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1407      +/-   ##
==========================================
+ Coverage   93.11%   93.12%   +0.01%     
==========================================
  Files        1051     1051              
  Lines       20207    20237      +30     
  Branches     4300     4302       +2     
==========================================
+ Hits        18816    18846      +30     
  Misses       1331     1331              
  Partials       60       60              

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

@DanielVZ96 DanielVZ96 force-pushed the dvz/publish-single-component branch from f3ce68c to 1cbc96b Compare October 22, 2024 15:17
const publishComponent = usePublishComponent(usageKey);
const { data: componentMetadata } = useLibraryBlockMetadata(usageKey);
// Only can be published when the component has been modified after the last published date.
const canPublish = (new Date(componentMetadata?.modified ?? 0)) > (new Date(componentMetadata?.lastPublished ?? 0));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if we don't have data about the modified date we shouldn't be able to publish, and because of this we default the date to 0.

@DanielVZ96 DanielVZ96 force-pushed the dvz/publish-single-component branch from 3931057 to 1eca22f Compare October 22, 2024 15:26
@bradenmacdonald
Copy link
Contributor

@DanielVZ96 Let me know when this is ready for review, and don't forget to un-mark it as draft.

@DanielVZ96 DanielVZ96 force-pushed the dvz/publish-single-component branch from 1eca22f to 9227b47 Compare October 22, 2024 15:35
@DanielVZ96 DanielVZ96 marked this pull request as ready for review October 22, 2024 15:37
@DanielVZ96 DanielVZ96 requested a review from a team as a code owner October 22, 2024 15:37
@DanielVZ96
Copy link
Contributor Author

@bradenmacdonald ready for review!

@bradenmacdonald
Copy link
Contributor

Configure waffle flags to enable libraries v2:

That's not necessary unless they were previously disabled. They're now on by default, so all you have to do is not enable those waffle flags :)

Copy link
Contributor

@bradenmacdonald bradenmacdonald 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, and seems to be working well in my tests. Just found one very tiny nit on comment formatting.

@bradenmacdonald bradenmacdonald force-pushed the dvz/publish-single-component branch from d2b86de to 7fb017d Compare October 22, 2024 17:16
@bradenmacdonald
Copy link
Contributor

Rebased because there is some weird CI error in eslint that's not happening locally

@bradenmacdonald bradenmacdonald force-pushed the dvz/publish-single-component branch from 7fb017d to f7c757b Compare October 22, 2024 17:19
@bradenmacdonald
Copy link
Contributor

Ah, turns out it was testing the merged version, and there was actually a duplicate. Fixed now :)

@bradenmacdonald bradenmacdonald enabled auto-merge (squash) October 22, 2024 17:25
@bradenmacdonald bradenmacdonald merged commit 966e1c3 into openedx:master Oct 22, 2024
6 checks passed
@bradenmacdonald bradenmacdonald deleted the dvz/publish-single-component branch October 22, 2024 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants