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: set upstream link for re-copied block from course originally from library #35784

Merged
merged 3 commits into from
Nov 7, 2024

Conversation

navinkarkera
Copy link
Contributor

Description

Sets upstream link to library block for blocks that were copied from a course block which were originally copied/imported from a library.

Fix for #35752

Supporting information

Testing instructions

Follow instructions from issue: https://github.com/openedx/edx-platform/issues/35752\

Deadline

ASAP

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Nov 6, 2024
@openedx-webhooks
Copy link

openedx-webhooks commented Nov 6, 2024

Thanks for the pull request, @navinkarkera!

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/wg-maintenance-edx-platform. 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.

@navinkarkera navinkarkera marked this pull request as ready for review November 6, 2024 10:44
@kdmccormick kdmccormick self-requested a review November 6, 2024 16:35
Copy link
Contributor

@pomegranited pomegranited left a comment

Choose a reason for hiding this comment

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

👍 Works perfectly, great job @navinkarkera ! Left a couple of minor suggestions.

  • I tested this using the instructions from the issue with the [contentstore.new_studio_mfe.use_new_unit_page](http://local.edly.io:8000/admin/waffle/flag/43/change/) waffle flag disabled, so I could use the legacy Studio UI to see the "update available" links.
  • I read through the code
  • I checked for accessibility issues by using my keyboard to navigate N/A
  • Includes great documentation :)
  • User-facing strings are extracted for translation N/A

* the xblock is copied from a v2 library; the library block is set as upstream.
* the xblock is copied from a course; no upstream is set, only copied_from_block is set.
* the xblock is copied from a course where the source block was imported from a library; the original libary block
is set as upstream.
Copy link
Contributor

Choose a reason for hiding this comment

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

Your documentation here is so good -- it's really helpful to see all the many ways we manage links between blocks. Thank you for taking the time to explain!

Comment on lines 339 to 340
if copied_from_block is None:
return
Copy link
Contributor

Choose a reason for hiding this comment

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

[opinion] Can we make copied_from_block a required string parameter instead of returning here? I think that would be clearer.

Suggested change
if copied_from_block is None:
return
assert copied_from_block

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did not add assert, but updated the type and moved the check to caller function.

Comment on lines +561 to +564
# first verify link for copied block from library
new_block_key = _copy_paste_and_assert_link(self.lib_block_key)
# next verify link for copied block from the pasted block
_copy_paste_and_assert_link(new_block_key)
Copy link
Contributor

Choose a reason for hiding this comment

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

Oo that's nice!

@@ -323,6 +323,58 @@ def import_staged_content_from_user_clipboard(parent_key: UsageKey, request) ->
return new_xblock, notices


def fetch_and_set_upstream_link(
Copy link
Contributor

Choose a reason for hiding this comment

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

This function seems pretty local to _import_xml_node_to_parent.. should it be an internal function to discourage use outside of this module?

Suggested change
def fetch_and_set_upstream_link(
def _fetch_and_set_upstream_link(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. Updated.

…m library

Sets upstream link to library block for blocks that were copied from a
course block which were originally copied/imported from a library.
@@ -436,7 +465,7 @@ def _import_xml_node_to_parent(
# Allow an XBlock to do anything fancy it may need to when pasted from the clipboard.
# These blocks may handle their own children or parenting if needed. Let them return booleans to
# let us know if we need to handle these or not.
children_handed = new_xblock.studio_post_paste(store, node)
children_handled = new_xblock.studio_post_paste(store, node)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Typo in variable causing children_handed to always be False.

Comment on lines 339 to 340
if copied_from_block is None:
return
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did not add assert, but updated the type and moved the check to caller function.

@@ -323,6 +323,58 @@ def import_staged_content_from_user_clipboard(parent_key: UsageKey, request) ->
return new_xblock, notices


def fetch_and_set_upstream_link(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. Updated.

@ChrisChV ChrisChV merged commit d82aada into openedx:master Nov 7, 2024
49 checks passed
@ChrisChV ChrisChV deleted the navin/fix-copy-copied-upstream branch November 7, 2024 14:54
navinkarkera added a commit to open-craft/edx-platform that referenced this pull request Nov 7, 2024
…m library (openedx#35784)

Sets upstream link to library block for blocks that were copied from a course block which were originally copied/imported from a library.

(cherry picked from commit d82aada)
ChrisChV pushed a commit that referenced this pull request Nov 7, 2024
…m library (#35784) (#35801)

Sets upstream link to library block for blocks that were copied from a course block which were originally copied/imported from a library.

(cherry picked from commit d82aada)
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

1 similar comment
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

1 similar comment
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

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
None yet
Development

Successfully merging this pull request may close these issues.

5 participants